Compare commits
2 Commits
node24
...
thboop/nod
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4314d44d94 | ||
|
|
28c3d5cef9 |
@@ -1,6 +0,0 @@
|
|||||||
# Ignore list
|
|
||||||
/*
|
|
||||||
|
|
||||||
# Do not ignore these folders:
|
|
||||||
!__tests__/
|
|
||||||
!src/
|
|
||||||
51
.eslintrc.js
51
.eslintrc.js
@@ -1,51 +0,0 @@
|
|||||||
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
|
|
||||||
module.exports = {
|
|
||||||
extends: [
|
|
||||||
'eslint:recommended',
|
|
||||||
'plugin:@typescript-eslint/recommended',
|
|
||||||
'plugin:eslint-plugin-jest/recommended',
|
|
||||||
'eslint-config-prettier'
|
|
||||||
],
|
|
||||||
parser: '@typescript-eslint/parser',
|
|
||||||
plugins: ['@typescript-eslint', 'eslint-plugin-node', 'eslint-plugin-jest'],
|
|
||||||
rules: {
|
|
||||||
'@typescript-eslint/no-require-imports': 'error',
|
|
||||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
||||||
'@typescript-eslint/no-explicit-any': 'off',
|
|
||||||
'@typescript-eslint/no-empty-function': 'off',
|
|
||||||
'@typescript-eslint/ban-ts-comment': [
|
|
||||||
'error',
|
|
||||||
{
|
|
||||||
'ts-ignore': 'allow-with-description'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'no-console': 'error',
|
|
||||||
'yoda': 'error',
|
|
||||||
'prefer-const': [
|
|
||||||
'error',
|
|
||||||
{
|
|
||||||
destructuring: 'all'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'no-control-regex': 'off',
|
|
||||||
'no-constant-condition': ['error', {checkLoops: false}],
|
|
||||||
'node/no-extraneous-import': 'error'
|
|
||||||
},
|
|
||||||
overrides: [
|
|
||||||
{
|
|
||||||
files: ['**/*{test,spec}.ts'],
|
|
||||||
rules: {
|
|
||||||
'@typescript-eslint/no-unused-vars': 'off',
|
|
||||||
'jest/no-standalone-expect': 'off',
|
|
||||||
'jest/no-conditional-expect': 'off',
|
|
||||||
'no-console': 'off',
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
env: {
|
|
||||||
node: true,
|
|
||||||
es6: true,
|
|
||||||
'jest/globals': true
|
|
||||||
}
|
|
||||||
};
|
|
||||||
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1,2 +1 @@
|
|||||||
* text=auto eol=lf
|
|
||||||
.licenses/** -diff linguist-generated=true
|
.licenses/** -diff linguist-generated=true
|
||||||
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -7,7 +7,7 @@ assignees: ''
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<!--- Please direct any generic questions related to actions to our support community forum at https://github.com/orgs/community/discussions/categories/actions --->
|
<!--- Please direct any generic questions related to actions to our support community forum at https://github.community/c/code-to-cloud/github-actions/41 --->
|
||||||
<!--- Before opening up a new bug report, please make sure to check for similar existing issues -->
|
<!--- Before opening up a new bug report, please make sure to check for similar existing issues -->
|
||||||
|
|
||||||
**Description:**
|
**Description:**
|
||||||
|
|||||||
2
.github/ISSUE_TEMPLATE/config.yml
vendored
2
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1 +1 @@
|
|||||||
blank_issues_enabled: false
|
blank_issues_enabled: false
|
||||||
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -5,7 +5,7 @@ title: ''
|
|||||||
labels: feature request, needs triage
|
labels: feature request, needs triage
|
||||||
assignees: ''
|
assignees: ''
|
||||||
---
|
---
|
||||||
<!--- Please direct any generic questions related to actions to our support community forum at https://github.com/orgs/community/discussions/categories/actions --->
|
<!--- Please direct any generic questions related to actions to our support community forum at https://github.community/c/code-to-cloud/github-actions/41 --->
|
||||||
<!--- Before opening up a new feature request, please make sure to check for similar existing issues and pull requests -->
|
<!--- Before opening up a new feature request, please make sure to check for similar existing issues and pull requests -->
|
||||||
|
|
||||||
**Description:**
|
**Description:**
|
||||||
|
|||||||
22
.github/dependabot.yml
vendored
22
.github/dependabot.yml
vendored
@@ -1,22 +0,0 @@
|
|||||||
# To get started with Dependabot version updates, you'll need to specify which
|
|
||||||
# package ecosystems to update and where the package manifests are located.
|
|
||||||
# Please see the documentation for all configuration options:
|
|
||||||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
|
||||||
|
|
||||||
version: 2
|
|
||||||
updates:
|
|
||||||
# Enable version updates for npm
|
|
||||||
- package-ecosystem: 'npm'
|
|
||||||
# Look for `package.json` and `lock` files in the `root` directory
|
|
||||||
directory: '/'
|
|
||||||
# Check the npm registry for updates every day (weekdays)
|
|
||||||
schedule:
|
|
||||||
interval: 'weekly'
|
|
||||||
|
|
||||||
# Enable version updates for GitHub Actions
|
|
||||||
- package-ecosystem: 'github-actions'
|
|
||||||
# Workflow files stored in the default location of `.github/workflows`
|
|
||||||
# You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.
|
|
||||||
directory: '/'
|
|
||||||
schedule:
|
|
||||||
interval: 'weekly'
|
|
||||||
18
.github/workflows/basic-validation.yml
vendored
18
.github/workflows/basic-validation.yml
vendored
@@ -1,18 +0,0 @@
|
|||||||
name: Basic validation
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
pull_request:
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
call-basic-validation:
|
|
||||||
name: Basic validation
|
|
||||||
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
|
|
||||||
with:
|
|
||||||
node-version: '20'
|
|
||||||
42
.github/workflows/check-dist.yml
vendored
42
.github/workflows/check-dist.yml
vendored
@@ -1,3 +1,8 @@
|
|||||||
|
# `dist/index.js` is a special file in Actions.
|
||||||
|
# When you reference an action with `uses:` in a workflow,
|
||||||
|
# `index.js` is the code that will run.
|
||||||
|
# For our project, we generate this file through a build process from other source files.
|
||||||
|
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
|
||||||
name: Check dist/
|
name: Check dist/
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@@ -12,8 +17,35 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
call-check-dist:
|
check-dist:
|
||||||
name: Check dist/
|
runs-on: ubuntu-latest
|
||||||
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
|
|
||||||
with:
|
steps:
|
||||||
node-version: '20'
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set Node.js 16.x
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 16.x
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Rebuild the dist/ directory
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
|
- name: Compare the expected and actual dist/ directories
|
||||||
|
run: |
|
||||||
|
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
|
||||||
|
echo "Detected uncommitted changes after build. See status below:"
|
||||||
|
git diff
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
id: diff
|
||||||
|
|
||||||
|
# If index.js was different than expected, upload the expected version as an artifact
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||||
|
with:
|
||||||
|
name: dist
|
||||||
|
path: dist/
|
||||||
|
|||||||
14
.github/workflows/codeql-analysis.yml
vendored
14
.github/workflows/codeql-analysis.yml
vendored
@@ -1,14 +0,0 @@
|
|||||||
name: CodeQL analysis
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
schedule:
|
|
||||||
- cron: '0 3 * * 0'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
call-codeQL-analysis:
|
|
||||||
name: CodeQL analysis
|
|
||||||
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main
|
|
||||||
16
.github/workflows/licensed.yml
vendored
16
.github/workflows/licensed.yml
vendored
@@ -9,6 +9,16 @@ on:
|
|||||||
- main
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
call-licensed:
|
test:
|
||||||
name: Licensed
|
runs-on: ubuntu-latest
|
||||||
uses: actions/reusable-workflows/.github/workflows/licensed.yml@main
|
name: Check licenses
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- run: npm ci
|
||||||
|
- name: Install licensed
|
||||||
|
run: |
|
||||||
|
cd $RUNNER_TEMP
|
||||||
|
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.12.2/licensed-2.12.2-linux-x64.tar.gz
|
||||||
|
sudo tar -xzf licensed.tar.gz
|
||||||
|
sudo mv licensed /usr/local/bin/licensed
|
||||||
|
- run: licensed status
|
||||||
|
|||||||
20
.github/workflows/publish-immutable-actions.yml
vendored
20
.github/workflows/publish-immutable-actions.yml
vendored
@@ -1,20 +0,0 @@
|
|||||||
name: 'Publish Immutable Action Version'
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
id-token: write
|
|
||||||
packages: write
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checking out
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Publish
|
|
||||||
id: publish
|
|
||||||
uses: actions/publish-immutable-action@v0.0.4
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
name: Release new action version
|
name: Release new action version
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [released]
|
types: [released]
|
||||||
@@ -22,7 +21,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Update the ${{ env.TAG_NAME }} tag
|
- name: Update the ${{ env.TAG_NAME }} tag
|
||||||
uses: actions/publish-action@v0.3.0
|
uses: actions/publish-action@v0.1.0
|
||||||
with:
|
with:
|
||||||
source-tag: ${{ env.TAG_NAME }}
|
source-tag: ${{ env.TAG_NAME }}
|
||||||
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
||||||
|
|||||||
11
.github/workflows/update-config-files.yml
vendored
11
.github/workflows/update-config-files.yml
vendored
@@ -1,11 +0,0 @@
|
|||||||
name: Update configuration files
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 3 * * 0'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
call-update-configuration-files:
|
|
||||||
name: Update configuration files
|
|
||||||
uses: actions/reusable-workflows/.github/workflows/update-config-files.yml@main
|
|
||||||
159
.github/workflows/versions.yml
vendored
159
.github/workflows/versions.yml
vendored
@@ -1,5 +1,4 @@
|
|||||||
name: Validate 'setup-go'
|
name: Validate 'setup-go'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@@ -13,76 +12,17 @@ on:
|
|||||||
- cron: 0 0 * * *
|
- cron: 0 0 * * *
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
stable:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Setup Go Stable
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version: stable
|
|
||||||
- name: Verify Go
|
|
||||||
run: go version
|
|
||||||
|
|
||||||
oldstable:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Setup Go oldStable
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version: oldstable
|
|
||||||
- name: Verify Go
|
|
||||||
run: go version
|
|
||||||
|
|
||||||
aliases-arch:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
|
||||||
version: [stable, oldstable]
|
|
||||||
architecture: [x64, x32]
|
|
||||||
exclude:
|
|
||||||
- os: macos-latest
|
|
||||||
architecture: x32
|
|
||||||
- os: macos-13
|
|
||||||
architecture: x32
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }}
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.version }}
|
|
||||||
architecture: ${{ matrix.architecture }}
|
|
||||||
- name: Verify Go
|
|
||||||
run: go version
|
|
||||||
|
|
||||||
local-cache:
|
local-cache:
|
||||||
name: Setup local-cache version
|
name: Setup local-cache version
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest, macos-13]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
go: [1.21.13, 1.22.8, 1.23.2]
|
go: [1.12, 1.13, 1.14]
|
||||||
include:
|
|
||||||
- os: windows-latest
|
|
||||||
go: 1.20.14
|
|
||||||
exclude:
|
|
||||||
- os: windows-latest
|
|
||||||
go: 1.23.2
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: setup-go ${{ matrix.go }}
|
- name: setup-go ${{ matrix.go }}
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -93,85 +33,38 @@ jobs:
|
|||||||
run: __tests__/verify-go.sh ${{ matrix.go }}
|
run: __tests__/verify-go.sh ${{ matrix.go }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
check-latest:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
|
||||||
go-version: ['1.20', '1.21', '1.22', '1.23']
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Setup Go and check latest
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.go-version }}
|
|
||||||
check-latest: true
|
|
||||||
- name: Verify Go
|
|
||||||
run: go version
|
|
||||||
|
|
||||||
go-version-file:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Setup Go and check latest
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version-file: __tests__/data/go.mod
|
|
||||||
- name: verify go
|
|
||||||
run: __tests__/verify-go.sh 1.20.14
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
go-version-file-with-gowork:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Setup Go and check latest
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version-file: __tests__/data/go.work
|
|
||||||
- name: verify go
|
|
||||||
run: __tests__/verify-go.sh 1.21
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
setup-versions-from-manifest:
|
setup-versions-from-manifest:
|
||||||
|
name: Setup ${{ matrix.go }} ${{ matrix.os }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest, macos-13]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
go: [1.20.14, 1.21.10, 1.22.8, 1.23.2]
|
go: [1.12.16, 1.13.11, 1.14.3]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: setup-go ${{ matrix.go }}
|
- name: setup-go ${{ matrix.go }}
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
- name: verify go
|
- name: verify go
|
||||||
run: __tests__/verify-go.sh ${{ matrix.go }}
|
run: __tests__/verify-go.sh ${{ matrix.go }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
setup-versions-from-dist:
|
setup-versions-from-dist:
|
||||||
|
name: Setup ${{ matrix.go }} ${{ matrix.os }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [windows-latest, ubuntu-latest, macos-13]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
go: [1.11.12]
|
go: [1.7, 1.8.6]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: setup-go ${{ matrix.go }}
|
- name: setup-go ${{ matrix.go }}
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -181,29 +74,3 @@ jobs:
|
|||||||
- name: verify go
|
- name: verify go
|
||||||
run: __tests__/verify-go.sh ${{ matrix.go }}
|
run: __tests__/verify-go.sh ${{ matrix.go }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
architecture:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
|
||||||
go-version: [1.20.14, 1.21, 1.22, 1.23]
|
|
||||||
include:
|
|
||||||
- os: macos-latest
|
|
||||||
architecture: arm64
|
|
||||||
- os: ubuntu-latest
|
|
||||||
architecture: x64
|
|
||||||
- os: windows-latest
|
|
||||||
architecture: x64
|
|
||||||
- os: macos-13
|
|
||||||
architecture: x64
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Setup Go and check latest
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.go-version }}
|
|
||||||
architecture: ${{ matrix.architecture }}
|
|
||||||
- name: Verify Go
|
|
||||||
run: go version
|
|
||||||
|
|||||||
136
.github/workflows/windows-validation.yml
vendored
136
.github/workflows/windows-validation.yml
vendored
@@ -1,136 +0,0 @@
|
|||||||
name: Validate Windows installation
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
pull_request:
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
create-link-if-not-default:
|
|
||||||
runs-on: windows-latest
|
|
||||||
name: 'Validate if symlink is created'
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
cache: [false, true]
|
|
||||||
go: [1.20.1]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: 'Setup ${{ matrix.cache }}, cache: ${{ matrix.go }}'
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.go }}
|
|
||||||
cache: ${{ matrix.cache }}
|
|
||||||
|
|
||||||
- name: 'Drive C: should have zero size link'
|
|
||||||
run: |
|
|
||||||
du -m -s 'C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'
|
|
||||||
# make sure drive c: contains only a link
|
|
||||||
size=$(du -m -s 'C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'|cut -f1 -d$'\t')
|
|
||||||
if [ $size -ne 0 ];then
|
|
||||||
echo 'Size of the link created on drive c: must be 0'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
# Drive D: is small, take care the action does not eat up the space
|
|
||||||
- name: 'Drive D: space usage should be below 1G'
|
|
||||||
run: |
|
|
||||||
du -m -s 'D:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'
|
|
||||||
size=$(du -m -s 'D:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'|cut -f1 -d$'\t')
|
|
||||||
# make sure archive does not take lot of space
|
|
||||||
if [ $size -gt 999 ];then
|
|
||||||
echo 'Size of installed on drive d: go is too big';
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
# make sure the Go installation has not been changed to the end user
|
|
||||||
- name: Test paths and environments
|
|
||||||
run: |
|
|
||||||
echo $PATH
|
|
||||||
which go
|
|
||||||
go version
|
|
||||||
go env
|
|
||||||
if [ $(which go) != '/c/hostedtoolcache/windows/go/${{ matrix.go }}/x64/bin/go' ];then
|
|
||||||
echo 'which go should return "/c/hostedtoolcache/windows/go/${{ matrix.go }}/x64/bin/go"'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ $(go env GOROOT) != 'C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64' ];then
|
|
||||||
echo 'go env GOROOT should return "C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64"'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
find-default-go:
|
|
||||||
name: 'Find default go version'
|
|
||||||
runs-on: windows-latest
|
|
||||||
outputs:
|
|
||||||
version: ${{ steps.goversion.outputs.version }}
|
|
||||||
steps:
|
|
||||||
- run: |
|
|
||||||
version=`go env GOVERSION|sed s/^go//`
|
|
||||||
echo "default go version: $version"
|
|
||||||
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
||||||
id: goversion
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
dont-create-link-if-default:
|
|
||||||
name: 'Validate if symlink is not created for default go'
|
|
||||||
runs-on: windows-latest
|
|
||||||
needs: find-default-go
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
cache: [false, true]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: 'Setup default go, cache: ${{ matrix.cache }}'
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version: ${{ needs.find-default-go.outputs.version }}
|
|
||||||
cache: ${{ matrix.cache }}
|
|
||||||
|
|
||||||
- name: 'Drive C: should have Go installation, cache: ${{ matrix.cache}}'
|
|
||||||
run: |
|
|
||||||
size=$(du -m -s 'C:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64'|cut -f1 -d$'\t')
|
|
||||||
if [ $size -eq 0 ];then
|
|
||||||
echo 'Size of the hosted go installed on drive c: must be above zero'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: 'Drive D: should not have Go installation, cache: ${{ matrix.cache }}'
|
|
||||||
run: |
|
|
||||||
if [ -e 'D:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64' ];then
|
|
||||||
echo 'D:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64 should not exist for hosted version of go';
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
hostedtoolcache:
|
|
||||||
name: 'Validate if hostedtoolcache works as expected'
|
|
||||||
runs-on: windows-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
cache: [false]
|
|
||||||
go: [1.20.1]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}'
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.go }}
|
|
||||||
cache: ${{ matrix.cache }}
|
|
||||||
|
|
||||||
- name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }} (from hostedtoolcache)'
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.go }}
|
|
||||||
cache: ${{ matrix.cache }}
|
|
||||||
39
.github/workflows/workflow.yml
vendored
Normal file
39
.github/workflows/workflow.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
name: build-test
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
jobs:
|
||||||
|
run:
|
||||||
|
name: Run
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, windows-latest]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup node 16
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
cache: npm
|
||||||
|
|
||||||
|
- name: npm install
|
||||||
|
run: npm install
|
||||||
|
|
||||||
|
- name: Lint
|
||||||
|
run: npm run format-check
|
||||||
|
|
||||||
|
- name: npm test
|
||||||
|
run: npm test
|
||||||
|
|
||||||
|
- name: audit packages
|
||||||
|
run: npm audit --audit-level=high
|
||||||
|
if: matrix.operating-system == 'ubuntu-latest'
|
||||||
@@ -9,7 +9,6 @@ allowed:
|
|||||||
- mit
|
- mit
|
||||||
- cc0-1.0
|
- cc0-1.0
|
||||||
- unlicense
|
- unlicense
|
||||||
- 0bsd
|
|
||||||
|
|
||||||
reviewed:
|
reviewed:
|
||||||
npm:
|
npm:
|
||||||
BIN
.licenses/npm/@actions/cache.dep.yml
generated
BIN
.licenses/npm/@actions/cache.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/core.dep.yml
generated
BIN
.licenses/npm/@actions/core.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/exec.dep.yml
generated
BIN
.licenses/npm/@actions/exec.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/glob-0.1.2.dep.yml
generated
BIN
.licenses/npm/@actions/glob-0.1.2.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/glob-0.5.0.dep.yml
generated
BIN
.licenses/npm/@actions/glob-0.5.0.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/http-client.dep.yml
generated
BIN
.licenses/npm/@actions/http-client.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/io.dep.yml
generated
BIN
.licenses/npm/@actions/io.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/tool-cache.dep.yml
generated
BIN
.licenses/npm/@actions/tool-cache.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/abort-controller.dep.yml
generated
BIN
.licenses/npm/@azure/abort-controller.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-auth.dep.yml
generated
BIN
.licenses/npm/@azure/core-auth.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-http.dep.yml
generated
BIN
.licenses/npm/@azure/core-http.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-lro.dep.yml
generated
BIN
.licenses/npm/@azure/core-lro.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-paging.dep.yml
generated
BIN
.licenses/npm/@azure/core-paging.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-tracing.dep.yml
generated
BIN
.licenses/npm/@azure/core-tracing.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-util.dep.yml
generated
BIN
.licenses/npm/@azure/core-util.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/logger.dep.yml
generated
BIN
.licenses/npm/@azure/logger.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/ms-rest-js.dep.yml
generated
BIN
.licenses/npm/@azure/ms-rest-js.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/storage-blob.dep.yml
generated
BIN
.licenses/npm/@azure/storage-blob.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@fastify/busboy.dep.yml
generated
BIN
.licenses/npm/@fastify/busboy.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@opentelemetry/api.dep.yml
generated
BIN
.licenses/npm/@opentelemetry/api.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/plugin-framework.dep.yml
generated
BIN
.licenses/npm/@protobuf-ts/plugin-framework.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/plugin.dep.yml
generated
BIN
.licenses/npm/@protobuf-ts/plugin.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/protoc.dep.yml
generated
BIN
.licenses/npm/@protobuf-ts/protoc.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/runtime-rpc.dep.yml
generated
BIN
.licenses/npm/@protobuf-ts/runtime-rpc.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/runtime.dep.yml
generated
BIN
.licenses/npm/@protobuf-ts/runtime.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@types/node-fetch.dep.yml
generated
BIN
.licenses/npm/@types/node-fetch.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@types/node.dep.yml
generated
BIN
.licenses/npm/@types/node.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@types/tunnel.dep.yml
generated
BIN
.licenses/npm/@types/tunnel.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/abort-controller.dep.yml
generated
BIN
.licenses/npm/abort-controller.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/asynckit.dep.yml
generated
BIN
.licenses/npm/asynckit.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/balanced-match.dep.yml
generated
BIN
.licenses/npm/balanced-match.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/brace-expansion.dep.yml
generated
BIN
.licenses/npm/brace-expansion.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/call-bind-apply-helpers.dep.yml
generated
BIN
.licenses/npm/call-bind-apply-helpers.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/combined-stream.dep.yml
generated
BIN
.licenses/npm/combined-stream.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/concat-map.dep.yml
generated
BIN
.licenses/npm/concat-map.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/delayed-stream.dep.yml
generated
BIN
.licenses/npm/delayed-stream.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/dunder-proto.dep.yml
generated
BIN
.licenses/npm/dunder-proto.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/es-define-property.dep.yml
generated
BIN
.licenses/npm/es-define-property.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/es-errors.dep.yml
generated
BIN
.licenses/npm/es-errors.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/es-object-atoms.dep.yml
generated
BIN
.licenses/npm/es-object-atoms.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/es-set-tostringtag.dep.yml
generated
BIN
.licenses/npm/es-set-tostringtag.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/event-target-shim.dep.yml
generated
BIN
.licenses/npm/event-target-shim.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/events.dep.yml
generated
BIN
.licenses/npm/events.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/form-data-2.5.5.dep.yml
generated
BIN
.licenses/npm/form-data-2.5.5.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/form-data-4.0.4.dep.yml
generated
BIN
.licenses/npm/form-data-4.0.4.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/function-bind.dep.yml
generated
BIN
.licenses/npm/function-bind.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/get-intrinsic.dep.yml
generated
BIN
.licenses/npm/get-intrinsic.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/get-proto.dep.yml
generated
BIN
.licenses/npm/get-proto.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/gopd.dep.yml
generated
BIN
.licenses/npm/gopd.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/has-symbols.dep.yml
generated
BIN
.licenses/npm/has-symbols.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/has-tostringtag.dep.yml
generated
BIN
.licenses/npm/has-tostringtag.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/hasown.dep.yml
generated
BIN
.licenses/npm/hasown.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/math-intrinsics.dep.yml
generated
BIN
.licenses/npm/math-intrinsics.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/mime-db.dep.yml
generated
BIN
.licenses/npm/mime-db.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/mime-types.dep.yml
generated
BIN
.licenses/npm/mime-types.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/minimatch.dep.yml
generated
BIN
.licenses/npm/minimatch.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/node-fetch.dep.yml
generated
BIN
.licenses/npm/node-fetch.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/process.dep.yml
generated
BIN
.licenses/npm/process.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/safe-buffer.dep.yml
generated
BIN
.licenses/npm/safe-buffer.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/sax.dep.yml
generated
BIN
.licenses/npm/sax.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/semver-7.7.1.dep.yml
generated
BIN
.licenses/npm/semver-7.7.1.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/tr46.dep.yml
generated
BIN
.licenses/npm/tr46.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/tslib-1.14.1.dep.yml
generated
BIN
.licenses/npm/tslib-1.14.1.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/tslib-2.6.2.dep.yml
generated
BIN
.licenses/npm/tslib-2.6.2.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/typescript.dep.yml
generated
BIN
.licenses/npm/typescript.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/undici-types.dep.yml
generated
BIN
.licenses/npm/undici-types.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/undici.dep.yml
generated
BIN
.licenses/npm/undici.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/uuid.dep.yml
generated
BIN
.licenses/npm/uuid.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/webidl-conversions.dep.yml
generated
BIN
.licenses/npm/webidl-conversions.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/whatwg-url.dep.yml
generated
BIN
.licenses/npm/whatwg-url.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/xml2js.dep.yml
generated
BIN
.licenses/npm/xml2js.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/xmlbuilder.dep.yml
generated
BIN
.licenses/npm/xmlbuilder.dep.yml
generated
Binary file not shown.
@@ -1,7 +0,0 @@
|
|||||||
# Ignore list
|
|
||||||
/*
|
|
||||||
|
|
||||||
# Do not ignore these folders:
|
|
||||||
!__tests__/
|
|
||||||
!.github/
|
|
||||||
!src/
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
|
|
||||||
module.exports = {
|
|
||||||
printWidth: 80,
|
|
||||||
tabWidth: 2,
|
|
||||||
useTabs: false,
|
|
||||||
semi: true,
|
|
||||||
singleQuote: true,
|
|
||||||
trailingComma: 'none',
|
|
||||||
bracketSpacing: false,
|
|
||||||
arrowParens: 'avoid'
|
|
||||||
};
|
|
||||||
11
.prettierrc.json
Normal file
11
.prettierrc.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 80,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"useTabs": false,
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "none",
|
||||||
|
"bracketSpacing": false,
|
||||||
|
"arrowParens": "avoid",
|
||||||
|
"parser": "typescript"
|
||||||
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
* @actions/setup-actions-team
|
* @actions/spark
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ a project may be further defined and clarified by project maintainers.
|
|||||||
## Enforcement
|
## Enforcement
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
reported by contacting the project team at opensource+actions/setup-go@github.com. All
|
reported by contacting the project team at opensource@github.com. All
|
||||||
complaints will be reviewed and investigated and will result in a response that
|
complaints will be reviewed and investigated and will result in a response that
|
||||||
is deemed necessary and appropriate to the circumstances. The project team is
|
is deemed necessary and appropriate to the circumstances. The project team is
|
||||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||||
@@ -73,4 +73,4 @@ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.ht
|
|||||||
[homepage]: https://www.contributor-covenant.org
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|
||||||
For answers to common questions about this code of conduct, see
|
For answers to common questions about this code of conduct, see
|
||||||
https://www.contributor-covenant.org/faq
|
https://www.contributor-covenant.org/faq
|
||||||
252
README.md
252
README.md
@@ -1,96 +1,44 @@
|
|||||||
# setup-go
|
# setup-go
|
||||||
|
|
||||||
[](https://github.com/actions/setup-go/actions/workflows/basic-validation.yml)
|
<p align="left">
|
||||||
[](https://github.com/actions/setup-go/actions/workflows/versions.yml)
|
<a href="https://github.com/actions/setup-go/actions"><img alt="GitHub Actions status" src="https://github.com/actions/setup-go/workflows/build-test/badge.svg"></a>
|
||||||
|
|
||||||
|
<a href="https://github.com/actions/setup-go/actions"><img alt="versions status" src="https://github.com/actions/setup-go/workflows/go-versions/badge.svg"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
This action sets up a go environment for use in actions by:
|
This action sets up a go environment for use in actions by:
|
||||||
|
|
||||||
- Optionally downloading and caching a version of Go by version and adding to `PATH`.
|
- optionally downloading and caching a version of Go by version and adding to PATH
|
||||||
- Registering problem matchers for error output.
|
- registering problem matchers for error output
|
||||||
|
|
||||||
# V5
|
# V2
|
||||||
|
|
||||||
The V5 edition of the action offers:
|
The V2 offers:
|
||||||
|
- Adds GOBIN to the PATH
|
||||||
- Upgraded Node.js runtime from node16 to node20
|
- Proxy Support
|
||||||
|
- stable input
|
||||||
See full release notes on the [releases page](https://github.com/actions/setup-go/releases).
|
|
||||||
|
|
||||||
# V4
|
|
||||||
|
|
||||||
The V4 edition of the action offers:
|
|
||||||
|
|
||||||
- Enabled caching by default
|
|
||||||
|
|
||||||
The action will try to enable caching unless the `cache` input is explicitly set to false.
|
|
||||||
|
|
||||||
Please see "[Caching dependency files and build outputs](https://github.com/actions/setup-go#caching-dependency-files-and-build-outputs)" for more information.
|
|
||||||
|
|
||||||
# V3
|
|
||||||
|
|
||||||
The V3 edition of the action offers:
|
|
||||||
|
|
||||||
- Adds `GOBIN` to the `PATH`
|
|
||||||
- Proxy support
|
|
||||||
- Check latest version
|
|
||||||
- Caching packages dependencies
|
|
||||||
- stable and oldstable aliases
|
|
||||||
- Bug Fixes (including issues around version matching and semver)
|
- Bug Fixes (including issues around version matching and semver)
|
||||||
|
|
||||||
The action will first check the local cache for a version match. If a version is not found locally, it will pull it from
|
It will first check the local cache for a version match. If version is not found locally, It will pull it from `main` branch of [go-versions](https://github.com/actions/go-versions/blob/main/versions-manifest.json) repository and on miss or failure, it will fall back to the previous behavior of download directly from [go dist](https://storage.googleapis.com/golang).
|
||||||
the `main` branch of the [go-versions](https://github.com/actions/go-versions/blob/main/versions-manifest.json)
|
|
||||||
repository. On miss or failure, it will fall back to downloading directly
|
|
||||||
from [go dist](https://storage.googleapis.com/golang). To change the default behavior, please use
|
|
||||||
the [check-latest input](#check-latest-version).
|
|
||||||
|
|
||||||
**Note:** The `setup-go` action uses executable binaries which are built by Golang side. The action does not build
|
|
||||||
golang from source code.
|
|
||||||
|
|
||||||
Matching by [semver spec](https://github.com/npm/node-semver):
|
Matching by [semver spec](https://github.com/npm/node-semver):
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: '^1.13.1' # The Go version to download (if necessary) and use.
|
go-version: '^1.13.1' # The Go version to download (if necessary) and use.
|
||||||
- run: go version
|
- run: go version
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: '>=1.17.0'
|
|
||||||
- run: go version
|
|
||||||
```
|
|
||||||
|
|
||||||
> **Note**: Due to the peculiarities of YAML parsing, it is recommended to wrap the version in single quotation marks:
|
|
||||||
>
|
|
||||||
> ```yaml
|
|
||||||
> go-version: '1.20'
|
|
||||||
> ```
|
|
||||||
>
|
|
||||||
> The recommendation is based on the YAML parser's behavior, which interprets non-wrapped values as numbers and, in the case of version 1.20, trims it down to 1.2, which may not be very obvious.
|
|
||||||
|
|
||||||
Matching an unstable pre-release:
|
Matching an unstable pre-release:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: '1.18.0-rc.1' # The Go version to download (if necessary) and use.
|
stable: 'false'
|
||||||
- run: go version
|
go-version: '1.14.0-rc1' # The Go version to download (if necessary) and use.
|
||||||
```
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: '1.16.0-beta.1' # The Go version to download (if necessary) and use.
|
|
||||||
- run: go version
|
- run: go version
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -98,121 +46,17 @@ steps:
|
|||||||
|
|
||||||
See [action.yml](action.yml)
|
See [action.yml](action.yml)
|
||||||
|
|
||||||
## Basic
|
Basic:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@master
|
||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: '1.16.1' # The Go version to download (if necessary) and use.
|
go-version: '1.9.3' # The Go version to download (if necessary) and use.
|
||||||
- run: go run hello.go
|
- run: go run hello.go
|
||||||
```
|
```
|
||||||
|
|
||||||
## Check latest version
|
Matrix Testing:
|
||||||
|
|
||||||
The `check-latest` flag defaults to `false`. Use the default or set `check-latest` to `false` if you prefer stability
|
|
||||||
and if you want to ensure a specific Go version is always used.
|
|
||||||
|
|
||||||
If `check-latest` is set to `true`, the action first checks if the cached version is the latest one. If the locally
|
|
||||||
cached version is not the most up-to-date, a Go version will then be downloaded. Set `check-latest` to `true` if you
|
|
||||||
want the most up-to-date Go version to always be used.
|
|
||||||
|
|
||||||
> Setting `check-latest` to `true` has performance implications as downloading Go versions is slower than using cached
|
|
||||||
> versions.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: '1.14'
|
|
||||||
check-latest: true
|
|
||||||
- run: go run hello.go
|
|
||||||
```
|
|
||||||
|
|
||||||
## Using stable/oldstable aliases
|
|
||||||
|
|
||||||
If `stable` is provided, action will get the latest stable version from
|
|
||||||
the [`go-versions`](https://github.com/actions/go-versions/blob/main/versions-manifest.json) repository manifest.
|
|
||||||
|
|
||||||
If `oldstable` is provided, when current release is 1.19.x, action will resolve version as 1.18.x, where x is the latest
|
|
||||||
patch release.
|
|
||||||
|
|
||||||
**Note:** using these aliases will result in same version as using corresponding minor release with `check-latest` input
|
|
||||||
set to `true`
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: 'stable'
|
|
||||||
- run: go run hello.go
|
|
||||||
```
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: 'oldstable'
|
|
||||||
- run: go run hello.go
|
|
||||||
```
|
|
||||||
|
|
||||||
## Caching dependency files and build outputs:
|
|
||||||
|
|
||||||
The action has a built-in functionality for caching and restoring go modules and build outputs. It
|
|
||||||
uses [toolkit/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under the hood but requires less configuration settings.
|
|
||||||
The `cache` input is optional, and caching is turned on by default.
|
|
||||||
|
|
||||||
The action defaults to search for the dependency file - go.sum in the repository root, and uses its hash as a part of
|
|
||||||
the cache key. Use `cache-dependency-path` input for cases when multiple dependency files are used, or they are located
|
|
||||||
in different subdirectories. The input supports glob patterns.
|
|
||||||
|
|
||||||
If some problem that prevents success caching happens then the action issues the warning in the log and continues the execution of the pipeline.
|
|
||||||
|
|
||||||
**Caching in monorepos**
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: '1.17'
|
|
||||||
check-latest: true
|
|
||||||
cache-dependency-path: |
|
|
||||||
subdir/go.sum
|
|
||||||
tools/go.sum
|
|
||||||
# cache-dependency-path: "**/*.sum"
|
|
||||||
|
|
||||||
- run: go run hello.go
|
|
||||||
```
|
|
||||||
|
|
||||||
## Getting go version from the go.mod file
|
|
||||||
|
|
||||||
The `go-version-file` input accepts a path to a `go.mod` file or a `go.work` file that contains the version of Go to be used by a project.
|
|
||||||
|
|
||||||
The `go` directive in `go.mod` can specify a patch version or omit it altogether (e.g., `go 1.22.0` or `go 1.22`).
|
|
||||||
If a patch version is specified, that specific patch version will be used.
|
|
||||||
If no patch version is specified, it will search for the latest available patch version in the cache,
|
|
||||||
[versions-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json), and the
|
|
||||||
[official Go language website](https://golang.org/dl/?mode=json&include=all), in that order.
|
|
||||||
|
|
||||||
If both the `go-version` and the `go-version-file` inputs are provided then the `go-version` input is used.
|
|
||||||
> The action will search for the `go.mod` file relative to the repository root
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version-file: 'path/to/go.mod'
|
|
||||||
- run: go version
|
|
||||||
```
|
|
||||||
|
|
||||||
## Matrix testing
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -222,54 +66,20 @@ jobs:
|
|||||||
go: [ '1.14', '1.13' ]
|
go: [ '1.14', '1.13' ]
|
||||||
name: Go ${{ matrix.go }} sample
|
name: Go ${{ matrix.go }} sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v2
|
||||||
- name: Setup go
|
- name: Setup go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
- run: go run hello.go
|
- run: go run hello.go
|
||||||
```
|
```
|
||||||
|
|
||||||
### Supported version syntax
|
### Supported version syntax
|
||||||
|
|
||||||
The `go-version` input supports the following syntax:
|
The `go-version` input supports the following syntax:
|
||||||
|
|
||||||
- Specific versions: `1.15`, `1.16.1`, `1.17.0-rc.2`, `1.16.0-beta.1`
|
Specific versions: `1.15`, `1.16.1`, `1.17.0-rc2`, `1.16.0-beta1`
|
||||||
- SemVer's version range syntax: `^1.13.1`, `>=1.18.0-rc.1`
|
SemVer's version range syntax: `^1.13.1`
|
||||||
|
For more information about semantic versioning please refer [semver](https://github.com/npm/node-semver) documentation
|
||||||
For more information about semantic versioning, please refer to [semver](https://github.com/npm/node-semver)
|
|
||||||
documentation.
|
|
||||||
|
|
||||||
## Using `setup-go` on GHES
|
|
||||||
|
|
||||||
`setup-go` comes pre-installed on the appliance with GHES if Actions is enabled.
|
|
||||||
When dynamically downloading Go distributions, `setup-go` downloads distributions from [`actions/go-versions`](https://github.com/actions/go-versions) on github.com (outside of the appliance).
|
|
||||||
|
|
||||||
These calls to `actions/go-versions` are made via unauthenticated requests, which are limited to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting).
|
|
||||||
If more requests are made within the time frame, then the action leverages the `raw API` to retrieve the version-manifest. This approach does not impose a rate limit and hence facilitates unrestricted consumption. This is particularly beneficial for GHES runners, which often share the same IP, to avoid the quick exhaustion of the unauthenticated rate limit.
|
|
||||||
If that fails as well the action will try to download versions directly from https://storage.googleapis.com/golang.
|
|
||||||
|
|
||||||
If that fails as well you can get a higher rate limit with [generating a personal access token on github.com](https://github.com/settings/tokens/new) and passing it as the `token` input to the action:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GH_DOTCOM_TOKEN }}
|
|
||||||
go-version: '1.18'
|
|
||||||
```
|
|
||||||
|
|
||||||
If the runner is not able to access github.com, any Go versions requested during a workflow run must come from the runner's tool cache.
|
|
||||||
See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server@3.2/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)"
|
|
||||||
for more information.
|
|
||||||
|
|
||||||
## Recommended permissions
|
|
||||||
|
|
||||||
When using the `setup-go` action in your GitHub Actions workflow, it is recommended to set the following permissions to ensure proper functionality:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
permissions:
|
|
||||||
contents: read # access to check out code and install dependencies
|
|
||||||
```
|
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
@@ -277,8 +87,8 @@ The scripts and documentation in this project are released under the [MIT Licens
|
|||||||
|
|
||||||
# Contributions
|
# Contributions
|
||||||
|
|
||||||
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
||||||
|
|
||||||
## Code of Conduct
|
## Code of Conduct
|
||||||
|
|
||||||
:wave: Be nice. See [our code of conduct](CODE_OF_CONDUCT.md)
|
:wave: Be nice. See [our code of conduct](CONDUCT)
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
import * as cache from '@actions/cache';
|
|
||||||
import * as core from '@actions/core';
|
|
||||||
import * as glob from '@actions/glob';
|
|
||||||
|
|
||||||
import * as cacheRestore from '../src/cache-restore';
|
|
||||||
import * as cacheUtils from '../src/cache-utils';
|
|
||||||
import {PackageManagerInfo} from '../src/package-managers';
|
|
||||||
|
|
||||||
describe('restoreCache', () => {
|
|
||||||
//Arrange
|
|
||||||
const hashFilesSpy = jest.spyOn(glob, 'hashFiles');
|
|
||||||
const getCacheDirectoryPathSpy = jest.spyOn(
|
|
||||||
cacheUtils,
|
|
||||||
'getCacheDirectoryPath'
|
|
||||||
);
|
|
||||||
const restoreCacheSpy = jest.spyOn(cache, 'restoreCache');
|
|
||||||
const infoSpy = jest.spyOn(core, 'info');
|
|
||||||
const setOutputSpy = jest.spyOn(core, 'setOutput');
|
|
||||||
|
|
||||||
const versionSpec = '1.13.1';
|
|
||||||
const packageManager = 'default';
|
|
||||||
const cacheDependencyPath = 'path';
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
getCacheDirectoryPathSpy.mockImplementation(
|
|
||||||
(PackageManager: PackageManagerInfo) => {
|
|
||||||
return new Promise<string[]>(resolve => {
|
|
||||||
resolve(['cache_directory_path', 'cache_directory_path']);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw if dependency file path is not valid', async () => {
|
|
||||||
//Arrange
|
|
||||||
hashFilesSpy.mockImplementation((somePath: string) => {
|
|
||||||
return new Promise<string>(resolve => {
|
|
||||||
resolve('');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//Act + Assert
|
|
||||||
await expect(async () => {
|
|
||||||
await cacheRestore.restoreCache(
|
|
||||||
versionSpec,
|
|
||||||
packageManager,
|
|
||||||
cacheDependencyPath
|
|
||||||
);
|
|
||||||
}).rejects.toThrow(
|
|
||||||
'Some specified paths were not resolved, unable to cache dependencies.'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should inform if cache hit is not occured', async () => {
|
|
||||||
//Arrange
|
|
||||||
hashFilesSpy.mockImplementation((somePath: string) => {
|
|
||||||
return new Promise<string>(resolve => {
|
|
||||||
resolve('file_hash');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
restoreCacheSpy.mockImplementation(() => {
|
|
||||||
return new Promise<string>(resolve => {
|
|
||||||
resolve('');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//Act + Assert
|
|
||||||
await cacheRestore.restoreCache(
|
|
||||||
versionSpec,
|
|
||||||
packageManager,
|
|
||||||
cacheDependencyPath
|
|
||||||
);
|
|
||||||
expect(infoSpy).toHaveBeenCalledWith(`Cache is not found`);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set output if cache hit is occured', async () => {
|
|
||||||
//Arrange
|
|
||||||
hashFilesSpy.mockImplementation((somePath: string) => {
|
|
||||||
return new Promise<string>(resolve => {
|
|
||||||
resolve('file_hash');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
restoreCacheSpy.mockImplementation(() => {
|
|
||||||
return new Promise<string>(resolve => {
|
|
||||||
resolve('cache_key');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//Act + Assert
|
|
||||||
await cacheRestore.restoreCache(
|
|
||||||
versionSpec,
|
|
||||||
packageManager,
|
|
||||||
cacheDependencyPath
|
|
||||||
);
|
|
||||||
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,249 +0,0 @@
|
|||||||
import * as exec from '@actions/exec';
|
|
||||||
import * as cache from '@actions/cache';
|
|
||||||
import * as core from '@actions/core';
|
|
||||||
import * as cacheUtils from '../src/cache-utils';
|
|
||||||
import {PackageManagerInfo} from '../src/package-managers';
|
|
||||||
|
|
||||||
describe('getCommandOutput', () => {
|
|
||||||
//Arrange
|
|
||||||
const getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
|
||||||
|
|
||||||
it('should return trimmed stdout in case of successful exit code', async () => {
|
|
||||||
//Arrange
|
|
||||||
const stdoutResult = ' stdout ';
|
|
||||||
const trimmedStdout = stdoutResult.trim();
|
|
||||||
|
|
||||||
getExecOutputSpy.mockImplementation((commandLine: string) => {
|
|
||||||
return new Promise<exec.ExecOutput>(resolve => {
|
|
||||||
resolve({exitCode: 0, stdout: stdoutResult, stderr: ''});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//Act + Assert
|
|
||||||
return cacheUtils
|
|
||||||
.getCommandOutput('command')
|
|
||||||
.then(data => expect(data).toBe(trimmedStdout));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return error in case of unsuccessful exit code', async () => {
|
|
||||||
//Arrange
|
|
||||||
const stderrResult = 'error message';
|
|
||||||
|
|
||||||
getExecOutputSpy.mockImplementation((commandLine: string) => {
|
|
||||||
return new Promise<exec.ExecOutput>(resolve => {
|
|
||||||
resolve({exitCode: 10, stdout: '', stderr: stderrResult});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//Act + Assert
|
|
||||||
await expect(async () => {
|
|
||||||
await cacheUtils.getCommandOutput('command');
|
|
||||||
}).rejects.toThrow();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getPackageManagerInfo', () => {
|
|
||||||
it('should return package manager info in case of valid package manager name', async () => {
|
|
||||||
//Arrange
|
|
||||||
const packageManagerName = 'default';
|
|
||||||
const expectedResult = {
|
|
||||||
dependencyFilePattern: 'go.sum',
|
|
||||||
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
|
|
||||||
};
|
|
||||||
|
|
||||||
//Act + Assert
|
|
||||||
return cacheUtils
|
|
||||||
.getPackageManagerInfo(packageManagerName)
|
|
||||||
.then(data => expect(data).toEqual(expectedResult));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw the error in case of invalid package manager name', async () => {
|
|
||||||
//Arrange
|
|
||||||
const packageManagerName = 'invalidName';
|
|
||||||
|
|
||||||
//Act + Assert
|
|
||||||
await expect(async () => {
|
|
||||||
await cacheUtils.getPackageManagerInfo(packageManagerName);
|
|
||||||
}).rejects.toThrow();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getCacheDirectoryPath', () => {
|
|
||||||
//Arrange
|
|
||||||
const getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
|
||||||
|
|
||||||
const validPackageManager: PackageManagerInfo = {
|
|
||||||
dependencyFilePattern: 'go.sum',
|
|
||||||
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
|
|
||||||
};
|
|
||||||
|
|
||||||
it('should return path to the cache folders which specified package manager uses', async () => {
|
|
||||||
//Arrange
|
|
||||||
getExecOutputSpy.mockImplementation((commandLine: string) => {
|
|
||||||
return new Promise<exec.ExecOutput>(resolve => {
|
|
||||||
resolve({exitCode: 0, stdout: 'path/to/cache/folder', stderr: ''});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const expectedResult = ['path/to/cache/folder', 'path/to/cache/folder'];
|
|
||||||
|
|
||||||
//Act + Assert
|
|
||||||
return cacheUtils
|
|
||||||
.getCacheDirectoryPath(validPackageManager)
|
|
||||||
.then(data => expect(data).toEqual(expectedResult));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return path to the cache folder if one command return empty str', async () => {
|
|
||||||
//Arrange
|
|
||||||
getExecOutputSpy.mockImplementationOnce((commandLine: string) => {
|
|
||||||
return new Promise<exec.ExecOutput>(resolve => {
|
|
||||||
resolve({exitCode: 0, stdout: 'path/to/cache/folder', stderr: ''});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
getExecOutputSpy.mockImplementationOnce((commandLine: string) => {
|
|
||||||
return new Promise<exec.ExecOutput>(resolve => {
|
|
||||||
resolve({exitCode: 0, stdout: '', stderr: ''});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const expectedResult = ['path/to/cache/folder'];
|
|
||||||
|
|
||||||
//Act + Assert
|
|
||||||
return cacheUtils
|
|
||||||
.getCacheDirectoryPath(validPackageManager)
|
|
||||||
.then(data => expect(data).toEqual(expectedResult));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw if the both commands return empty str', async () => {
|
|
||||||
getExecOutputSpy.mockImplementation((commandLine: string) => {
|
|
||||||
return new Promise<exec.ExecOutput>(resolve => {
|
|
||||||
resolve({exitCode: 10, stdout: '', stderr: ''});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//Act + Assert
|
|
||||||
await expect(async () => {
|
|
||||||
await cacheUtils.getCacheDirectoryPath(validPackageManager);
|
|
||||||
}).rejects.toThrow();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw if the specified package name is invalid', async () => {
|
|
||||||
getExecOutputSpy.mockImplementation((commandLine: string) => {
|
|
||||||
return new Promise<exec.ExecOutput>(resolve => {
|
|
||||||
resolve({exitCode: 10, stdout: '', stderr: 'Error message'});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//Act + Assert
|
|
||||||
await expect(async () => {
|
|
||||||
await cacheUtils.getCacheDirectoryPath(validPackageManager);
|
|
||||||
}).rejects.toThrow();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('isCacheFeatureAvailable', () => {
|
|
||||||
//Arrange
|
|
||||||
const isFeatureAvailableSpy = jest.spyOn(cache, 'isFeatureAvailable');
|
|
||||||
const warningSpy = jest.spyOn(core, 'warning');
|
|
||||||
|
|
||||||
it('should return true when cache feature is available', () => {
|
|
||||||
//Arrange
|
|
||||||
isFeatureAvailableSpy.mockImplementation(() => {
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
//Act
|
|
||||||
const functionResult = cacheUtils.isCacheFeatureAvailable();
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(functionResult).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should warn when cache feature is unavailable and GHES is not used', () => {
|
|
||||||
//Arrange
|
|
||||||
isFeatureAvailableSpy.mockImplementation(() => {
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
process.env['GITHUB_SERVER_URL'] = 'https://github.com';
|
|
||||||
|
|
||||||
const warningMessage =
|
|
||||||
'The runner was not able to contact the cache service. Caching will be skipped';
|
|
||||||
|
|
||||||
//Act
|
|
||||||
cacheUtils.isCacheFeatureAvailable();
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(warningSpy).toHaveBeenCalledWith(warningMessage);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false when cache feature is unavailable', () => {
|
|
||||||
//Arrange
|
|
||||||
isFeatureAvailableSpy.mockImplementation(() => {
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
process.env['GITHUB_SERVER_URL'] = 'https://github.com';
|
|
||||||
|
|
||||||
//Act
|
|
||||||
const functionResult = cacheUtils.isCacheFeatureAvailable();
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(functionResult).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should warn when cache feature is unavailable and GHES is used', () => {
|
|
||||||
//Arrange
|
|
||||||
isFeatureAvailableSpy.mockImplementation(() => {
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
process.env['GITHUB_SERVER_URL'] = 'https://nongithub.com';
|
|
||||||
|
|
||||||
const warningMessage =
|
|
||||||
'Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.';
|
|
||||||
|
|
||||||
//Act + Assert
|
|
||||||
expect(cacheUtils.isCacheFeatureAvailable()).toBeFalsy();
|
|
||||||
expect(warningSpy).toHaveBeenCalledWith(warningMessage);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('isGhes', () => {
|
|
||||||
const pristineEnv = process.env;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
jest.resetModules();
|
|
||||||
process.env = {...pristineEnv};
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(() => {
|
|
||||||
process.env = pristineEnv;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns false when the GITHUB_SERVER_URL environment variable is not defined', async () => {
|
|
||||||
delete process.env['GITHUB_SERVER_URL'];
|
|
||||||
expect(cacheUtils.isGhes()).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns false when the GITHUB_SERVER_URL environment variable is set to github.com', async () => {
|
|
||||||
process.env['GITHUB_SERVER_URL'] = 'https://github.com';
|
|
||||||
expect(cacheUtils.isGhes()).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL', async () => {
|
|
||||||
process.env['GITHUB_SERVER_URL'] = 'https://contoso.ghe.com';
|
|
||||||
expect(cacheUtils.isGhes()).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix', async () => {
|
|
||||||
process.env['GITHUB_SERVER_URL'] = 'https://mock-github.localhost';
|
|
||||||
expect(cacheUtils.isGhes()).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns true when the GITHUB_SERVER_URL environment variable is set to some other URL', async () => {
|
|
||||||
process.env['GITHUB_SERVER_URL'] = 'https://src.onpremise.fabrikam.com';
|
|
||||||
expect(cacheUtils.isGhes()).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
module example.com/mymodule
|
|
||||||
|
|
||||||
go 1.20
|
|
||||||
|
|
||||||
require (
|
|
||||||
example.com/othermodule v1.2.3
|
|
||||||
example.com/thismodule v1.2.3
|
|
||||||
example.com/thatmodule v1.2.3
|
|
||||||
)
|
|
||||||
|
|
||||||
replace example.com/thatmodule => ../thatmodule
|
|
||||||
exclude example.com/thismodule v1.3.0
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user