mirror of
https://github.com/actions/setup-go.git
synced 2026-06-25 15:07:42 +00:00
Compare commits
136 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
924ae3a1cd | ||
|
|
e91cc3bfe0 | ||
|
|
4a2405e6ae | ||
|
|
78961f6f84 | ||
|
|
4a3601121d | ||
|
|
8f19afcc70 | ||
|
|
27fdb267c1 | ||
|
|
def8c394e3 | ||
|
|
4b73464bb3 | ||
|
|
a5f9b05d2d | ||
|
|
7a3fe6cf4c | ||
|
|
b9adafd441 | ||
|
|
d73f6bcfc2 | ||
|
|
ae252ee6fb | ||
|
|
bf7446afaf | ||
|
|
02aadfee7f | ||
|
|
4aaadf4266 | ||
|
|
4dc6199c7b | ||
|
|
f3787be646 | ||
|
|
3a0c2c8245 | ||
|
|
faf52423ec | ||
|
|
7bc60db215 | ||
|
|
c0137caad7 | ||
|
|
4469467582 | ||
|
|
e093d1e9bb | ||
|
|
1d76b952eb | ||
|
|
e75c3e80bc | ||
|
|
8e57b58e57 | ||
|
|
7c0b336c9a | ||
|
|
6f26dcc668 | ||
|
|
8d4083a006 | ||
|
|
fa96338abe | ||
|
|
4de67c04ab | ||
|
|
d35c59abb0 | ||
|
|
29694d72cd | ||
|
|
78535dd5f2 | ||
|
|
bb65d8857b | ||
|
|
7f17e836c0 | ||
|
|
dca8468d37 | ||
|
|
691cc3533f | ||
|
|
0aaccfd150 | ||
|
|
c4c1141886 | ||
|
|
5a083d0e9a | ||
|
|
1d82324e53 | ||
|
|
f111f3307d | ||
|
|
3d10edb4c2 | ||
|
|
43e13893cf | ||
|
|
f81f022188 | ||
|
|
3041bf56c9 | ||
|
|
41dfa10bad | ||
|
|
941977282c | ||
|
|
d60b41a563 | ||
|
|
e09f57f6a9 | ||
|
|
df1a11710e | ||
|
|
49582f6476 | ||
|
|
b26d40294f | ||
|
|
0a12ed9d6a | ||
|
|
4ab57d7ea2 | ||
|
|
cdcb360436 | ||
|
|
99176a8f9a | ||
|
|
be1aa1186e | ||
|
|
6c1fd22b67 | ||
|
|
0c52d547c9 | ||
|
|
bfd2fb341f | ||
|
|
3d65fa57fc | ||
|
|
8a505c9cf2 | ||
|
|
883490dfd0 | ||
|
|
d45ebba0ce | ||
|
|
317c6617fa | ||
|
|
f90673ad64 | ||
|
|
8018234347 | ||
|
|
d085b4fe57 | ||
|
|
48ac8fd236 | ||
|
|
89a192af9d | ||
|
|
aabcd82874 | ||
|
|
93397bea11 | ||
|
|
27eec5b982 | ||
|
|
ecfc77a56f | ||
|
|
1b80a11e05 | ||
|
|
b1c343484c | ||
|
|
0bb97b1c5c | ||
|
|
4220624b80 | ||
|
|
db8764c1e2 | ||
|
|
08b314a573 | ||
|
|
4e0b6c77c6 | ||
|
|
a4d10f0ea4 | ||
|
|
992f068900 | ||
|
|
0e6baa5a93 | ||
|
|
a6259e5d50 | ||
|
|
49bc3307c5 | ||
|
|
f350b3e5db | ||
|
|
06a11aedec | ||
|
|
56b159bb76 | ||
|
|
fac708d667 | ||
|
|
dd84a9531a | ||
|
|
41c2024c46 | ||
|
|
8dbf352f06 | ||
|
|
4d34df0c23 | ||
|
|
fdc0d672a1 | ||
|
|
ebfdf6ac95 | ||
|
|
b27d76912e | ||
|
|
c51a720768 | ||
|
|
6b848af622 | ||
|
|
12741cc209 | ||
|
|
7a77a6aab6 | ||
|
|
42a0cc8e14 | ||
|
|
7406d654ad | ||
|
|
a3d889c34c | ||
|
|
b8eec33327 | ||
|
|
807559307d | ||
|
|
b27afcd9c2 | ||
|
|
65f50caf42 | ||
|
|
89d7939d38 | ||
|
|
2e7414f276 | ||
|
|
de201a09c0 | ||
|
|
21459d0b7b | ||
|
|
4347c698e3 | ||
|
|
fa319ab135 | ||
|
|
32705aee25 | ||
|
|
49b445323b | ||
|
|
991a6a2c3e | ||
|
|
9c64203f1d | ||
|
|
8ecad12159 | ||
|
|
1661eebbbd | ||
|
|
9acc3d3da9 | ||
|
|
5b3907ef5c | ||
|
|
c0e82e3ff3 | ||
|
|
e01c74b690 | ||
|
|
17106403fa | ||
|
|
bb5ff97ab9 | ||
|
|
e417811a6d | ||
|
|
59e7baba60 | ||
|
|
1370292ad9 | ||
|
|
339692abda | ||
|
|
de99728cc5 | ||
|
|
5d1561a0b7 |
6
.eslintignore
Normal file
6
.eslintignore
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Ignore list
|
||||||
|
/*
|
||||||
|
|
||||||
|
# Do not ignore these folders:
|
||||||
|
!__tests__/
|
||||||
|
!src/
|
||||||
51
.eslintrc.js
Normal file
51
.eslintrc.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// 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
|
||||||
|
}
|
||||||
|
};
|
||||||
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1,2 +1,2 @@
|
|||||||
* text=auto
|
* 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.community/c/code-to-cloud/github-actions/41 --->
|
<!--- Please direct any generic questions related to actions to our support community forum at https://github.com/orgs/community/discussions/categories/actions --->
|
||||||
<!--- 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/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.community/c/code-to-cloud/github-actions/41 --->
|
<!--- Please direct any generic questions related to actions to our support community forum at https://github.com/orgs/community/discussions/categories/actions --->
|
||||||
<!--- 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
Normal file
22
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# 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
Normal file
18
.github/workflows/basic-validation.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
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: '24.x'
|
||||||
41
.github/workflows/check-dist.yml
vendored
41
.github/workflows/check-dist.yml
vendored
@ -1,8 +1,3 @@
|
|||||||
# `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:
|
||||||
@ -17,36 +12,8 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-dist:
|
call-check-dist:
|
||||||
runs-on: ubuntu-latest
|
name: Check dist/
|
||||||
|
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Set Node.js 16.x
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: '24.x'
|
||||||
cache: npm
|
|
||||||
|
|
||||||
- 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@v3
|
|
||||||
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
|
||||||
with:
|
|
||||||
name: dist
|
|
||||||
path: dist/
|
|
||||||
|
|||||||
14
.github/workflows/codeql-analysis.yml
vendored
Normal file
14
.github/workflows/codeql-analysis.yml
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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
|
||||||
20
.github/workflows/licensed.yml
vendored
20
.github/workflows/licensed.yml
vendored
@ -9,20 +9,6 @@ on:
|
|||||||
- main
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
call-licensed:
|
||||||
runs-on: ubuntu-latest
|
name: Licensed
|
||||||
name: Check licenses
|
uses: actions/reusable-workflows/.github/workflows/licensed.yml@main
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Set Node.js 16.x
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: 16.x
|
|
||||||
- run: npm ci
|
|
||||||
- name: Install licensed
|
|
||||||
run: |
|
|
||||||
cd $RUNNER_TEMP
|
|
||||||
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.4.4/licensed-3.4.4-linux-x64.tar.gz
|
|
||||||
sudo tar -xzf licensed.tar.gz
|
|
||||||
sudo mv licensed /usr/local/bin/licensed
|
|
||||||
- run: licensed status
|
|
||||||
|
|||||||
143
.github/workflows/microsoft-validation.yml
vendored
Normal file
143
.github/workflows/microsoft-validation.yml
vendored
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
name: Validate Microsoft build of Go
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
microsoft-basic:
|
||||||
|
name: 'Microsoft build of Go ${{ matrix.go-version }} on ${{ matrix.os }}'
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
go-version: ['1.25', '1.24']
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Setup Microsoft build of Go ${{ matrix.go-version }}
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go-version }}
|
||||||
|
go-download-base-url: 'https://aka.ms/golang/release/latest'
|
||||||
|
cache: false
|
||||||
|
|
||||||
|
- name: Verify Go installation
|
||||||
|
run: go version
|
||||||
|
|
||||||
|
- name: Verify Go env
|
||||||
|
run: go env
|
||||||
|
|
||||||
|
- name: Verify Go is functional
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
# Create a simple Go program and run it
|
||||||
|
mkdir -p /tmp/test-go && cd /tmp/test-go
|
||||||
|
cat > main.go << 'EOF'
|
||||||
|
package main
|
||||||
|
import "fmt"
|
||||||
|
func main() {
|
||||||
|
fmt.Println("Hello from Microsoft build of Go!")
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
go run main.go
|
||||||
|
|
||||||
|
microsoft-env-var:
|
||||||
|
name: 'Microsoft build of Go via env var on ${{ matrix.os }}'
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
env:
|
||||||
|
GO_DOWNLOAD_BASE_URL: 'https://aka.ms/golang/release/latest'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Setup Microsoft build of Go via environment variable
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
go-version: '1.25'
|
||||||
|
cache: false
|
||||||
|
|
||||||
|
- name: Verify Go installation
|
||||||
|
run: go version
|
||||||
|
|
||||||
|
- name: Verify Go is functional
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir -p /tmp/test-go && cd /tmp/test-go
|
||||||
|
cat > main.go << 'EOF'
|
||||||
|
package main
|
||||||
|
import "fmt"
|
||||||
|
func main() {
|
||||||
|
fmt.Println("Hello from Microsoft build of Go via env var!")
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
go run main.go
|
||||||
|
|
||||||
|
microsoft-architecture:
|
||||||
|
name: 'Microsoft build of Go arch ${{ matrix.architecture }} on ${{ matrix.os }}'
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
|
architecture: [x64]
|
||||||
|
include:
|
||||||
|
- os: macos-latest
|
||||||
|
architecture: arm64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Setup Microsoft build of Go with architecture
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
go-version: '1.25'
|
||||||
|
go-download-base-url: 'https://aka.ms/golang/release/latest'
|
||||||
|
architecture: ${{ matrix.architecture }}
|
||||||
|
cache: false
|
||||||
|
|
||||||
|
- name: Verify Go installation
|
||||||
|
run: go version
|
||||||
|
|
||||||
|
microsoft-with-cache:
|
||||||
|
name: 'Microsoft build of Go with caching on ${{ matrix.os }}'
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Setup Microsoft build of Go with caching
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
go-version: '1.25'
|
||||||
|
go-download-base-url: 'https://aka.ms/golang/release/latest'
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
- name: Verify Go installation
|
||||||
|
run: go version
|
||||||
|
|
||||||
|
- name: Verify Go is functional
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir -p /tmp/test-go && cd /tmp/test-go
|
||||||
|
go mod init test
|
||||||
|
cat > main.go << 'EOF'
|
||||||
|
package main
|
||||||
|
import "fmt"
|
||||||
|
func main() {
|
||||||
|
fmt.Println("Hello from cached Microsoft build of Go!")
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
go run main.go
|
||||||
20
.github/workflows/publish-immutable-actions.yml
vendored
Normal file
20
.github/workflows/publish-immutable-actions.yml
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
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@v6
|
||||||
|
- name: Publish
|
||||||
|
id: publish
|
||||||
|
uses: actions/publish-immutable-action@v0.0.4
|
||||||
@ -1,4 +1,5 @@
|
|||||||
name: Release new action version
|
name: Release new action version
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [released]
|
types: [released]
|
||||||
@ -21,7 +22,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.2.1
|
uses: actions/publish-action@v0.4.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
Normal file
11
.github/workflows/update-config-files.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
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
|
||||||
110
.github/workflows/versions.yml
vendored
110
.github/workflows/versions.yml
vendored
@ -1,4 +1,5 @@
|
|||||||
name: Validate 'setup-go'
|
name: Validate 'setup-go'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@ -17,9 +18,9 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: Setup Go Stable
|
- name: Setup Go Stable
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -32,9 +33,9 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: Setup Go oldStable
|
- name: Setup Go oldStable
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -47,14 +48,16 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
version: [stable, oldstable]
|
version: [stable, oldstable]
|
||||||
architecture: [x64, x32]
|
architecture: [x64, x32]
|
||||||
exclude:
|
exclude:
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
architecture: x32
|
architecture: x32
|
||||||
|
- os: macos-latest-large
|
||||||
|
architecture: x32
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }}
|
- name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }}
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -69,11 +72,17 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest, macos-latest-large]
|
||||||
go: [1.17, 1.18, 1.19]
|
go: [1.21.13, 1.22.8, 1.23.2]
|
||||||
|
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@v3
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: setup-go ${{ matrix.go }}
|
- name: setup-go ${{ matrix.go }}
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -89,10 +98,10 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
go-version: [1.16, 1.17]
|
go-version: ['1.20', '1.21', '1.22', '1.23']
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: Setup Go and check latest
|
- name: Setup Go and check latest
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -106,15 +115,15 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: Setup Go and check latest
|
- name: Setup Go and check latest
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
go-version-file: __tests__/data/go.mod
|
go-version-file: __tests__/data/go.mod
|
||||||
- name: verify go
|
- name: verify go
|
||||||
run: __tests__/verify-go.sh 1.14
|
run: __tests__/verify-go.sh 1.20.14
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
go-version-file-with-gowork:
|
go-version-file-with-gowork:
|
||||||
@ -122,28 +131,59 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: Setup Go and check latest
|
- name: Setup Go and check latest
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
go-version-file: __tests__/data/go.work
|
go-version-file: __tests__/data/go.work
|
||||||
- name: verify go
|
- name: verify go
|
||||||
run: __tests__/verify-go.sh 1.19
|
run: __tests__/verify-go.sh 1.21
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
setup-versions-from-manifest:
|
go-version-file-with-tool-versions:
|
||||||
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]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
go: [1.12.16, 1.13.11, 1.14.3]
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup Go and check latest
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
go-version-file: __tests__/data/.tool-versions
|
||||||
|
- name: verify go
|
||||||
|
run: __tests__/verify-go.sh 1.23.2
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
go-version-file-with-go-version:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup Go from .go-version file
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
go-version-file: __tests__/data/.go-version
|
||||||
|
- name: verify go
|
||||||
|
run: __tests__/verify-go.sh 1.22.4
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
setup-versions-from-manifest:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest, windows-latest, ubuntu-latest, macos-latest-large]
|
||||||
|
go: [1.20.14, 1.21.10, 1.22.8, 1.23.2]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: setup-go ${{ matrix.go }}
|
- name: setup-go ${{ matrix.go }}
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -155,16 +195,15 @@ jobs:
|
|||||||
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: [macos-latest, windows-latest, ubuntu-latest]
|
os: [windows-latest, ubuntu-latest, macos-latest-large]
|
||||||
go: [1.9, 1.8.6]
|
go: [1.11.12]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: setup-go ${{ matrix.go }}
|
- name: setup-go ${{ matrix.go }}
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -180,14 +219,23 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
go-version: [1.16, 1.17]
|
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-latest-large
|
||||||
|
architecture: x64
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: Setup Go and check latest
|
- name: Setup Go and check latest
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go-version }}
|
go-version: ${{ matrix.go-version }}
|
||||||
architecture: x64
|
architecture: ${{ matrix.architecture }}
|
||||||
- name: Verify Go
|
- name: Verify Go
|
||||||
run: go version
|
run: go version
|
||||||
|
|||||||
136
.github/workflows/windows-validation.yml
vendored
Normal file
136
.github/workflows/windows-validation.yml
vendored
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
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@v6
|
||||||
|
|
||||||
|
- 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@v6
|
||||||
|
|
||||||
|
- 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@v6
|
||||||
|
|
||||||
|
- 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
39
.github/workflows/workflow.yml
vendored
@ -1,39 +0,0 @@
|
|||||||
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@v3
|
|
||||||
|
|
||||||
- name: Setup node 16
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: 16
|
|
||||||
cache: npm
|
|
||||||
|
|
||||||
- name: npm ci
|
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- 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'
|
|
||||||
@ -13,3 +13,4 @@ allowed:
|
|||||||
|
|
||||||
reviewed:
|
reviewed:
|
||||||
npm:
|
npm:
|
||||||
|
- "@actions/http-client"
|
||||||
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.2.1.dep.yml
generated
BIN
.licenses/npm/@actions/glob-0.2.1.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@actions/http-client-1.0.11.dep.yml
generated
BIN
.licenses/npm/@actions/http-client-1.0.11.dep.yml
generated
Binary file not shown.
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.
Binary file not shown.
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-client.dep.yml
generated
Normal file
BIN
.licenses/npm/@azure/core-client.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@azure/core-http-compat.dep.yml
generated
Normal file
BIN
.licenses/npm/@azure/core-http-compat.dep.yml
generated
Normal file
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-rest-pipeline.dep.yml
generated
Normal file
BIN
.licenses/npm/@azure/core-rest-pipeline.dep.yml
generated
Normal file
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
Normal file
BIN
.licenses/npm/@azure/core-util.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@azure/core-xml.dep.yml
generated
Normal file
BIN
.licenses/npm/@azure/core-xml.dep.yml
generated
Normal file
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.
Binary file not shown.
BIN
.licenses/npm/@nodable/entities.dep.yml
generated
Normal file
BIN
.licenses/npm/@nodable/entities.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/runtime.dep.yml
generated
Normal file
BIN
.licenses/npm/@protobuf-ts/runtime.dep.yml
generated
Normal file
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/@typespec/ts-http-runtime.dep.yml
generated
Normal file
BIN
.licenses/npm/@typespec/ts-http-runtime.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
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/combined-stream.dep.yml
generated
BIN
.licenses/npm/combined-stream.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/debug.dep.yml
generated
Normal file
BIN
.licenses/npm/debug.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/delayed-stream.dep.yml
generated
BIN
.licenses/npm/delayed-stream.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/fast-xml-parser.dep.yml
generated
Normal file
BIN
.licenses/npm/fast-xml-parser.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/form-data-2.5.1.dep.yml
generated
BIN
.licenses/npm/form-data-2.5.1.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/form-data-3.0.1.dep.yml
generated
BIN
.licenses/npm/form-data-3.0.1.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/form-data-4.0.0.dep.yml
generated
BIN
.licenses/npm/form-data-4.0.0.dep.yml
generated
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/ip-regex.dep.yml
generated
BIN
.licenses/npm/ip-regex.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.
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/path-expression-matcher.dep.yml
generated
Normal file
BIN
.licenses/npm/path-expression-matcher.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/psl.dep.yml
generated
BIN
.licenses/npm/psl.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/punycode.dep.yml
generated
BIN
.licenses/npm/punycode.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.
Binary file not shown.
BIN
.licenses/npm/semver-7.8.5.dep.yml
generated
Normal file
BIN
.licenses/npm/semver-7.8.5.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/tough-cookie-3.0.1.dep.yml
generated
BIN
.licenses/npm/tough-cookie-3.0.1.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/tough-cookie-4.0.0.dep.yml
generated
BIN
.licenses/npm/tough-cookie-4.0.0.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.3.1.dep.yml
generated
BIN
.licenses/npm/tslib-2.3.1.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/tslib.dep.yml
generated
Normal file
BIN
.licenses/npm/tslib.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/undici.dep.yml
generated
Normal file
BIN
.licenses/npm/undici.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/universalify.dep.yml
generated
BIN
.licenses/npm/universalify.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/uuid-3.4.0.dep.yml
generated
BIN
.licenses/npm/uuid-3.4.0.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/uuid-8.3.2.dep.yml
generated
BIN
.licenses/npm/uuid-8.3.2.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/xml-naming.dep.yml
generated
Normal file
BIN
.licenses/npm/xml-naming.dep.yml
generated
Normal file
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.
7
.prettierignore
Normal file
7
.prettierignore
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Ignore list
|
||||||
|
/*
|
||||||
|
|
||||||
|
# Do not ignore these folders:
|
||||||
|
!__tests__/
|
||||||
|
!.github/
|
||||||
|
!src/
|
||||||
11
.prettierrc.js
Normal file
11
.prettierrc.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// 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'
|
||||||
|
};
|
||||||
@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"printWidth": 80,
|
|
||||||
"tabWidth": 2,
|
|
||||||
"useTabs": false,
|
|
||||||
"semi": true,
|
|
||||||
"singleQuote": true,
|
|
||||||
"trailingComma": "none",
|
|
||||||
"bracketSpacing": false,
|
|
||||||
"arrowParens": "avoid",
|
|
||||||
"parser": "typescript"
|
|
||||||
}
|
|
||||||
@ -1 +1 @@
|
|||||||
* @actions/actions-service
|
* @actions/setup-actions-team
|
||||||
|
|||||||
280
README.md
280
README.md
@ -1,224 +1,148 @@
|
|||||||
# setup-go
|
# setup-go
|
||||||
|
|
||||||
[](https://github.com/actions/setup-go/actions/workflows/workflow.yml)
|
[](https://github.com/actions/setup-go/actions/workflows/basic-validation.yml)
|
||||||
[](https://github.com/actions/setup-go/actions/workflows/versions.yml)
|
[](https://github.com/actions/setup-go/actions/workflows/versions.yml)
|
||||||
|
|
||||||
This action sets up a go environment for use in actions by:
|
This action sets up a Go environment for use in GitHub 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 it to the PATH
|
||||||
- Registering problem matchers for error output.
|
- Optionally caching Go modules and build outputs
|
||||||
|
- Registering problem matchers for error output
|
||||||
|
|
||||||
# V3
|
## Breaking changes in V6
|
||||||
|
|
||||||
The V3 edition of the action offers:
|
The V6 edition of the action includes:
|
||||||
|
- **Upgraded Node.js runtime from node20 to node24**
|
||||||
|
> Make sure your runner is on version v2.327.1 or later to ensure compatibility with this release. See [Release Notes](https://github.com/actions/runner/releases/tag/v2.327.1)
|
||||||
|
|
||||||
- Adds `GOBIN` to the `PATH`
|
- **Go toolchain**
|
||||||
- Proxy support
|
- Supports both `go` and `toolchain` directives in `go.mod`. If the `toolchain` directive is present, its version is used; otherwise, the action falls back to the `go` directive.
|
||||||
- Check latest version
|
|
||||||
- Caching packages dependencies
|
|
||||||
- stable and oldstable aliases
|
|
||||||
- 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 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).
|
- **Cache key update**
|
||||||
|
- By default, the cache key for Go modules is based on `go.mod`. To use `go.sum`, configure the `cache-dependency-path` input.
|
||||||
|
|
||||||
**Note:** The `setup-go` action uses executable binaries which are built by Golang side. The action does not build golang from source code.
|
See full release notes on the [releases page](https://github.com/actions/setup-go/releases).
|
||||||
|
|
||||||
Matching by [semver spec](https://github.com/npm/node-semver):
|
## Usage
|
||||||
|
|
||||||
|
See [action.yml](action.yml).
|
||||||
|
|
||||||
|
<!-- start usage -->
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
- uses: actions/setup-go@v6
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
with:
|
||||||
go-version: '^1.13.1' # The Go version to download (if necessary) and use.
|
# Version or version range of Go to use
|
||||||
- run: go version
|
go-version: '1.23'
|
||||||
```
|
|
||||||
|
|
||||||
```yaml
|
# Path to go.mod, go.work, .go-version, or .tool-versions file
|
||||||
steps:
|
# Note: if both go-version and go-version-file are provided, go-version takes precedence.
|
||||||
- uses: actions/checkout@v3
|
go-version-file: 'go.mod'
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: '>=1.17.0'
|
|
||||||
- run: go version
|
|
||||||
```
|
|
||||||
|
|
||||||
Matching an unstable pre-release:
|
# Set this option if you want the action to check for the latest available version
|
||||||
|
# Default: false
|
||||||
|
check-latest: false
|
||||||
|
|
||||||
```yaml
|
# GitHub token for authentication
|
||||||
steps:
|
token: ${{ github.token }}
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: '1.18.0-rc.1' # The Go version to download (if necessary) and use.
|
|
||||||
- run: go version
|
|
||||||
```
|
|
||||||
|
|
||||||
```yaml
|
# Used to specify whether caching is needed.
|
||||||
steps:
|
# Default: true
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: '1.16.0-beta.1' # The Go version to download (if necessary) and use.
|
|
||||||
- run: go version
|
|
||||||
```
|
|
||||||
|
|
||||||
# Usage
|
|
||||||
|
|
||||||
See [action.yml](action.yml)
|
|
||||||
|
|
||||||
## Basic
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: '1.16.1' # The Go version to download (if necessary) and use.
|
|
||||||
- run: go run hello.go
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Check latest version
|
|
||||||
|
|
||||||
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@v3
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
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@v3
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: 'stable'
|
|
||||||
- run: go run hello.go
|
|
||||||
```
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
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 [actions/cache](https://github.com/actions/cache) under the hood but requires less configuration settings. The `cache` input is optional, and caching is turned off 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.
|
|
||||||
|
|
||||||
**Caching without specifying dependency file path**
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: '1.17'
|
|
||||||
check-latest: true
|
|
||||||
cache: true
|
cache: true
|
||||||
- run: go run hello.go
|
|
||||||
|
# Path to dependency files for caching
|
||||||
|
cache-dependency-path: 'go.sum'
|
||||||
|
|
||||||
|
# Architecture to install (auto-detected if not specified)
|
||||||
|
architecture: 'x64'
|
||||||
|
|
||||||
|
# Custom base URL for Go downloads (e.g., for mirrors)
|
||||||
|
go-download-base-url: ''
|
||||||
```
|
```
|
||||||
|
<!-- end usage -->
|
||||||
|
|
||||||
**Caching in monorepos**
|
**Basic:**
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: '1.17'
|
|
||||||
check-latest: true
|
|
||||||
cache: true
|
|
||||||
cache-dependency-path: subdir/go.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. As the `go.mod` file contains only major and minor (e.g. 1.18) tags, the action will search for the latest available patch version sequentially in the runner's directory with the cached tools, in the [version-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json) file or at the go servers.
|
|
||||||
|
|
||||||
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
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- uses: actions/setup-go@v3
|
- uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
go-version-file: 'path/to/go.mod'
|
go-version: '1.25' # The Go version to download (if necessary) and use.
|
||||||
- run: go version
|
|
||||||
```
|
|
||||||
|
|
||||||
## Matrix testing
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
go: [ '1.14', '1.13' ]
|
|
||||||
name: Go ${{ matrix.go }} sample
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Setup go
|
|
||||||
uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.go }}
|
|
||||||
- run: go run hello.go
|
- run: go run hello.go
|
||||||
```
|
```
|
||||||
|
|
||||||
### Supported version syntax
|
**Version resolution behavior:**
|
||||||
|
|
||||||
|
The action resolves the requested version in the following order:
|
||||||
|
1. **Local cache** - Checks the local tool cache for a matching [semver](https://github.com/npm/node-semver#versions) version.
|
||||||
|
2. **go-versions repository** - If the requested version isn’t available in the tool cache, it pulls the version manifest from the `main` branch of the [go-versions repository](https://github.com/actions/go-versions/blob/main/versions-manifest.json).
|
||||||
|
3. **Direct download** - If that lookup misses or fails, it will fall back to downloading directly from the [official Go distribution site](https://go.dev/dl).
|
||||||
|
|
||||||
|
To change the default behavior, please use
|
||||||
|
the [check-latest input](docs/advanced-usage.md#check-latest-version).
|
||||||
|
|
||||||
|
> **Note**: The `setup-go` action uses executable binaries built by the Go team and does not build Go binaries from source code.
|
||||||
|
|
||||||
|
## 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.25`, `1.24.11`, `1.24.0-rc.1`, `1.23.0-beta.1`
|
||||||
- SemVer's version range syntax: `^1.13.1`, `>=1.18.0-rc.1`
|
- SemVer version range syntax: `^1.25.1`, `~1.24.1`, `>=1.25.0-rc.1`, `<1.25.0`, `>=1.22.0 <1.24.0`
|
||||||
|
- Aliases: `stable`, `oldstable`
|
||||||
|
- Wildcards: `1.25.x`, `1.x`
|
||||||
|
|
||||||
For more information about semantic versioning, please refer to [semver](https://github.com/npm/node-semver) documentation.
|
For details on Semantic Versioning, see [the semver package documentation](https://github.com/npm/node-semver).
|
||||||
|
|
||||||
## Using `setup-go` on GHES
|
> **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.
|
||||||
|
|
||||||
`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 you will start to see rate-limit errors during downloading that looks like: `##[error]API rate limit exceeded for...`. After that error the action will try to download versions directly from https://storage.googleapis.com/golang, but it also can have rate limit so it's better to put token.
|
For more usage examples, please refer to the section: [Using go-version input](docs/advanced-usage.md#using-the-go-version-input) of the [Advanced usage](docs/advanced-usage.md) guide.
|
||||||
|
|
||||||
To get a higher rate limit, you can [generate a personal access token on github.com](https://github.com/settings/tokens/new) and pass it as the `token` input for the action:
|
## 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
|
```yaml
|
||||||
uses: actions/setup-go@v3
|
permissions:
|
||||||
with:
|
contents: read # access to check out code and install dependencies
|
||||||
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.
|
## Caching dependency files and build outputs
|
||||||
|
|
||||||
# License
|
The action includes built-in caching and restoration for 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.
|
||||||
|
The `cache` input is optional, and caching is enabled by default. To disable caching, set `cache: false`.
|
||||||
|
|
||||||
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
By default, the action looks for `go.mod` in the repository root and uses its hash as part of the cache key. Use the `cache-dependency-path` input when you have multiple dependency files, or when they’re located in different subdirectories. This input supports glob patterns.
|
||||||
|
|
||||||
# Contributions
|
If caching cannot be performed for any reason, the action logs a warning and continues workflow execution.
|
||||||
|
|
||||||
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
For examples of using `cache-dependency-path`, see the [Caching](docs/advanced-usage.md#caching) section of the [Advanced usage](docs/advanced-usage.md) guide.
|
||||||
|
|
||||||
|
|
||||||
|
## Advanced usage
|
||||||
|
|
||||||
|
- [Using the go-version input](docs/advanced-usage.md#using-the-go-version-input)
|
||||||
|
- [Using the go-version-file input](docs/advanced-usage.md#using-the-go-version-file-input)
|
||||||
|
- [Check latest version](docs/advanced-usage.md#check-latest-version)
|
||||||
|
- [Caching](docs/advanced-usage.md#caching)
|
||||||
|
- [Outputs](docs/advanced-usage.md#outputs)
|
||||||
|
- [Custom download URL](docs/advanced-usage.md#custom-download-url)
|
||||||
|
- [Using `setup-go` on GHES](docs/advanced-usage.md#using-setup-go-on-ghes)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
The scripts and documentation in this project are released under the [MIT License](LICENSE).
|
||||||
|
|
||||||
|
## Contributions
|
||||||
|
|
||||||
|
Contributions are welcome! See our [Contributor's Guide](docs/contributors.md).
|
||||||
|
|
||||||
## Code of Conduct
|
## Code of Conduct
|
||||||
|
|
||||||
|
|||||||
@ -1,99 +1,102 @@
|
|||||||
import * as cache from '@actions/cache';
|
import * as cache from '@actions/cache';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as glob from '@actions/glob';
|
import * as glob from '@actions/glob';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
import * as cacheRestore from '../src/cache-restore';
|
import * as cacheRestore from '../src/cache-restore';
|
||||||
import * as cacheUtils from '../src/cache-utils';
|
import * as cacheUtils from '../src/cache-utils';
|
||||||
import {PackageManagerInfo} from '../src/package-managers';
|
import {PackageManagerInfo} from '../src/package-managers';
|
||||||
|
|
||||||
describe('restoreCache', () => {
|
describe('restoreCache', () => {
|
||||||
//Arrange
|
let hashFilesSpy: jest.SpyInstance;
|
||||||
let hashFilesSpy = jest.spyOn(glob, 'hashFiles');
|
let getCacheDirectoryPathSpy: jest.SpyInstance;
|
||||||
let getCacheDirectoryPathSpy = jest.spyOn(
|
let restoreCacheSpy: jest.SpyInstance;
|
||||||
cacheUtils,
|
let infoSpy: jest.SpyInstance;
|
||||||
'getCacheDirectoryPath'
|
let setOutputSpy: jest.SpyInstance;
|
||||||
);
|
|
||||||
let restoreCacheSpy = jest.spyOn(cache, 'restoreCache');
|
|
||||||
let infoSpy = jest.spyOn(core, 'info');
|
|
||||||
let setOutputSpy = jest.spyOn(core, 'setOutput');
|
|
||||||
|
|
||||||
const versionSpec = '1.13.1';
|
const versionSpec = '1.13.1';
|
||||||
const packageManager = 'default';
|
const packageManager = 'default';
|
||||||
const cacheDependencyPath = 'path';
|
const cacheDependencyPath = 'path';
|
||||||
|
|
||||||
|
let originalWorkspace: string | undefined;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
originalWorkspace = process.env.GITHUB_WORKSPACE;
|
||||||
|
process.env.GITHUB_WORKSPACE = '/test/workspace';
|
||||||
|
//Arrange
|
||||||
|
hashFilesSpy = jest.spyOn(glob, 'hashFiles');
|
||||||
|
getCacheDirectoryPathSpy = jest.spyOn(cacheUtils, 'getCacheDirectoryPath');
|
||||||
|
restoreCacheSpy = jest.spyOn(cache, 'restoreCache');
|
||||||
|
infoSpy = jest.spyOn(core, 'info');
|
||||||
|
setOutputSpy = jest.spyOn(core, 'setOutput');
|
||||||
|
|
||||||
getCacheDirectoryPathSpy.mockImplementation(
|
getCacheDirectoryPathSpy.mockImplementation(
|
||||||
(PackageManager: PackageManagerInfo) => {
|
(PackageManager: PackageManagerInfo) => {
|
||||||
return new Promise<string[]>(resolve => {
|
return Promise.resolve([
|
||||||
resolve(['cache_directory_path', 'cache_directory_path']);
|
'cache_directory_path',
|
||||||
});
|
'cache_directory_path'
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if dependency file path is not valid', async () => {
|
afterEach(() => {
|
||||||
//Arrange
|
process.env.GITHUB_WORKSPACE = originalWorkspace;
|
||||||
hashFilesSpy.mockImplementation((somePath: string) => {
|
jest.restoreAllMocks();
|
||||||
return new Promise<string>(resolve => {
|
|
||||||
resolve('');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//Act + Assert
|
it('should throw if dependency file path is not valid', async () => {
|
||||||
expect(async () => {
|
// Arrange
|
||||||
await cacheRestore.restoreCache(
|
hashFilesSpy.mockImplementation(() => Promise.resolve(''));
|
||||||
|
// Act + Assert
|
||||||
|
await expect(
|
||||||
|
cacheRestore.restoreCache(
|
||||||
versionSpec,
|
versionSpec,
|
||||||
packageManager,
|
packageManager,
|
||||||
cacheDependencyPath
|
cacheDependencyPath
|
||||||
);
|
)
|
||||||
}).rejects.toThrowError(
|
).rejects.toThrow(
|
||||||
'Some specified paths were not resolved, unable to cache dependencies.'
|
'Some specified paths were not resolved, unable to cache dependencies.'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should inform if cache hit is not occured', async () => {
|
it('should inform if cache hit is not occurred', async () => {
|
||||||
//Arrange
|
// Arrange
|
||||||
hashFilesSpy.mockImplementation((somePath: string) => {
|
hashFilesSpy.mockImplementation(() => Promise.resolve('file_hash'));
|
||||||
return new Promise<string>(resolve => {
|
restoreCacheSpy.mockImplementation(() => Promise.resolve(''));
|
||||||
resolve('file_hash');
|
// Act + Assert
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
restoreCacheSpy.mockImplementation(() => {
|
|
||||||
return new Promise<string>(resolve => {
|
|
||||||
resolve('');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//Act + Assert
|
|
||||||
await cacheRestore.restoreCache(
|
await cacheRestore.restoreCache(
|
||||||
versionSpec,
|
versionSpec,
|
||||||
packageManager,
|
packageManager,
|
||||||
cacheDependencyPath
|
cacheDependencyPath
|
||||||
);
|
);
|
||||||
expect(infoSpy).toBeCalledWith(`Cache is not found`);
|
expect(infoSpy).toHaveBeenCalledWith('Cache is not found');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set output if cache hit is occured', async () => {
|
it('should set output if cache hit is occurred', async () => {
|
||||||
//Arrange
|
// Arrange
|
||||||
hashFilesSpy.mockImplementation((somePath: string) => {
|
hashFilesSpy.mockImplementation(() => Promise.resolve('file_hash'));
|
||||||
return new Promise<string>(resolve => {
|
restoreCacheSpy.mockImplementation(() => Promise.resolve('cache_key'));
|
||||||
resolve('file_hash');
|
// Act + Assert
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
restoreCacheSpy.mockImplementation(() => {
|
|
||||||
return new Promise<string>(resolve => {
|
|
||||||
resolve('cache_key');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//Act + Assert
|
|
||||||
await cacheRestore.restoreCache(
|
await cacheRestore.restoreCache(
|
||||||
versionSpec,
|
versionSpec,
|
||||||
packageManager,
|
packageManager,
|
||||||
cacheDependencyPath
|
cacheDependencyPath
|
||||||
);
|
);
|
||||||
expect(setOutputSpy).toBeCalledWith('cache-hit', true);
|
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw if dependency file is not found in workspace', async () => {
|
||||||
|
jest.spyOn(fs, 'readdirSync').mockReturnValue(['main.go'] as any);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
cacheRestore.restoreCache(
|
||||||
|
versionSpec,
|
||||||
|
packageManager
|
||||||
|
// No cacheDependencyPath
|
||||||
|
)
|
||||||
|
).rejects.toThrow(
|
||||||
|
'Dependencies file is not found in /test/workspace. Supported file pattern: go.mod'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
155
__tests__/cache-save.test.ts
Normal file
155
__tests__/cache-save.test.ts
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
import * as cache from '@actions/cache';
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
|
import {run} from '../src/cache-save';
|
||||||
|
import * as cacheUtils from '../src/cache-utils';
|
||||||
|
import {State} from '../src/constants';
|
||||||
|
|
||||||
|
describe('cache-save', () => {
|
||||||
|
const primaryKey = 'primary-key';
|
||||||
|
|
||||||
|
let primaryKeyValue: string;
|
||||||
|
let matchedKeyValue: string;
|
||||||
|
|
||||||
|
let getBooleanInputSpy: jest.SpyInstance;
|
||||||
|
let getStateSpy: jest.SpyInstance;
|
||||||
|
let infoSpy: jest.SpyInstance;
|
||||||
|
let warningSpy: jest.SpyInstance;
|
||||||
|
let debugSpy: jest.SpyInstance;
|
||||||
|
let setFailedSpy: jest.SpyInstance;
|
||||||
|
let saveCacheSpy: jest.SpyInstance;
|
||||||
|
let getCacheDirectoryPathSpy: jest.SpyInstance;
|
||||||
|
let existsSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
primaryKeyValue = primaryKey;
|
||||||
|
matchedKeyValue = 'matched-key';
|
||||||
|
|
||||||
|
getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
|
||||||
|
getBooleanInputSpy.mockReturnValue(true);
|
||||||
|
|
||||||
|
getStateSpy = jest.spyOn(core, 'getState');
|
||||||
|
getStateSpy.mockImplementation((key: string) => {
|
||||||
|
if (key === State.CachePrimaryKey) {
|
||||||
|
return primaryKeyValue;
|
||||||
|
}
|
||||||
|
if (key === State.CacheMatchedKey) {
|
||||||
|
return matchedKeyValue;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
|
||||||
|
infoSpy = jest.spyOn(core, 'info');
|
||||||
|
infoSpy.mockImplementation(() => undefined);
|
||||||
|
|
||||||
|
warningSpy = jest.spyOn(core, 'warning');
|
||||||
|
warningSpy.mockImplementation(() => undefined);
|
||||||
|
|
||||||
|
debugSpy = jest.spyOn(core, 'debug');
|
||||||
|
debugSpy.mockImplementation(() => undefined);
|
||||||
|
|
||||||
|
setFailedSpy = jest.spyOn(core, 'setFailed');
|
||||||
|
setFailedSpy.mockImplementation(() => undefined);
|
||||||
|
|
||||||
|
saveCacheSpy = jest.spyOn(cache, 'saveCache');
|
||||||
|
saveCacheSpy.mockImplementation(() => Promise.resolve(0));
|
||||||
|
|
||||||
|
getCacheDirectoryPathSpy = jest.spyOn(cacheUtils, 'getCacheDirectoryPath');
|
||||||
|
getCacheDirectoryPathSpy.mockImplementation(() =>
|
||||||
|
Promise.resolve(['cache_directory_path', 'cache_directory_path'])
|
||||||
|
);
|
||||||
|
|
||||||
|
existsSpy = jest.spyOn(fs, 'existsSync');
|
||||||
|
existsSpy.mockImplementation(() => true);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not save cache when the cache input is false', async () => {
|
||||||
|
getBooleanInputSpy.mockReturnValue(false);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(saveCacheSpy).not.toHaveBeenCalled();
|
||||||
|
expect(warningSpy).not.toHaveBeenCalled();
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not save cache when there are no cache folders on the disk', async () => {
|
||||||
|
existsSpy.mockImplementation(() => false);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
|
'There are no cache folders on the disk'
|
||||||
|
);
|
||||||
|
expect(saveCacheSpy).not.toHaveBeenCalled();
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not save cache when the primary key was not generated', async () => {
|
||||||
|
primaryKeyValue = '';
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
|
'Primary key was not generated. Please check the log messages above for more errors or information'
|
||||||
|
);
|
||||||
|
expect(saveCacheSpy).not.toHaveBeenCalled();
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not save cache when a cache hit occurred on the primary key', async () => {
|
||||||
|
matchedKeyValue = primaryKey;
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
|
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
|
||||||
|
);
|
||||||
|
expect(saveCacheSpy).not.toHaveBeenCalled();
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('saves cache when the primary key differs from the matched key', async () => {
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(saveCacheSpy).toHaveBeenCalled();
|
||||||
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
|
`Cache saved with the key: ${primaryKey}`
|
||||||
|
);
|
||||||
|
expect(warningSpy).not.toHaveBeenCalled();
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('save with -1 cacheId , should not fail workflow', async () => {
|
||||||
|
saveCacheSpy.mockImplementation(() => Promise.resolve(-1));
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(saveCacheSpy).toHaveBeenCalled();
|
||||||
|
expect(debugSpy).toHaveBeenCalledWith(
|
||||||
|
`Cache was not saved for the key: ${primaryKey}`
|
||||||
|
);
|
||||||
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
|
`Cache saved with the key: ${primaryKey}`
|
||||||
|
);
|
||||||
|
expect(warningSpy).not.toHaveBeenCalled();
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('saves with error from toolkit, should not fail workflow', async () => {
|
||||||
|
saveCacheSpy.mockImplementation(() =>
|
||||||
|
Promise.reject(new Error('Unable to reach the service'))
|
||||||
|
);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(saveCacheSpy).toHaveBeenCalled();
|
||||||
|
expect(warningSpy).toHaveBeenCalledWith('Unable to reach the service');
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -6,7 +6,7 @@ import {PackageManagerInfo} from '../src/package-managers';
|
|||||||
|
|
||||||
describe('getCommandOutput', () => {
|
describe('getCommandOutput', () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
let getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
const getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
||||||
|
|
||||||
it('should return trimmed stdout in case of successful exit code', async () => {
|
it('should return trimmed stdout in case of successful exit code', async () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
@ -36,7 +36,7 @@ describe('getCommandOutput', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//Act + Assert
|
//Act + Assert
|
||||||
expect(async () => {
|
await expect(async () => {
|
||||||
await cacheUtils.getCommandOutput('command');
|
await cacheUtils.getCommandOutput('command');
|
||||||
}).rejects.toThrow();
|
}).rejects.toThrow();
|
||||||
});
|
});
|
||||||
@ -47,7 +47,7 @@ describe('getPackageManagerInfo', () => {
|
|||||||
//Arrange
|
//Arrange
|
||||||
const packageManagerName = 'default';
|
const packageManagerName = 'default';
|
||||||
const expectedResult = {
|
const expectedResult = {
|
||||||
dependencyFilePattern: 'go.sum',
|
dependencyFilePattern: 'go.mod',
|
||||||
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
|
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ describe('getPackageManagerInfo', () => {
|
|||||||
const packageManagerName = 'invalidName';
|
const packageManagerName = 'invalidName';
|
||||||
|
|
||||||
//Act + Assert
|
//Act + Assert
|
||||||
expect(async () => {
|
await expect(async () => {
|
||||||
await cacheUtils.getPackageManagerInfo(packageManagerName);
|
await cacheUtils.getPackageManagerInfo(packageManagerName);
|
||||||
}).rejects.toThrow();
|
}).rejects.toThrow();
|
||||||
});
|
});
|
||||||
@ -70,10 +70,10 @@ describe('getPackageManagerInfo', () => {
|
|||||||
|
|
||||||
describe('getCacheDirectoryPath', () => {
|
describe('getCacheDirectoryPath', () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
let getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
const getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
||||||
|
|
||||||
const validPackageManager: PackageManagerInfo = {
|
const validPackageManager: PackageManagerInfo = {
|
||||||
dependencyFilePattern: 'go.sum',
|
dependencyFilePattern: 'go.mod',
|
||||||
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
|
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -93,6 +93,41 @@ describe('getCacheDirectoryPath', () => {
|
|||||||
.then(data => expect(data).toEqual(expectedResult));
|
.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 () => {
|
it('should throw if the specified package name is invalid', async () => {
|
||||||
getExecOutputSpy.mockImplementation((commandLine: string) => {
|
getExecOutputSpy.mockImplementation((commandLine: string) => {
|
||||||
return new Promise<exec.ExecOutput>(resolve => {
|
return new Promise<exec.ExecOutput>(resolve => {
|
||||||
@ -101,7 +136,7 @@ describe('getCacheDirectoryPath', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//Act + Assert
|
//Act + Assert
|
||||||
expect(async () => {
|
await expect(async () => {
|
||||||
await cacheUtils.getCacheDirectoryPath(validPackageManager);
|
await cacheUtils.getCacheDirectoryPath(validPackageManager);
|
||||||
}).rejects.toThrow();
|
}).rejects.toThrow();
|
||||||
});
|
});
|
||||||
@ -109,8 +144,8 @@ describe('getCacheDirectoryPath', () => {
|
|||||||
|
|
||||||
describe('isCacheFeatureAvailable', () => {
|
describe('isCacheFeatureAvailable', () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
let isFeatureAvailableSpy = jest.spyOn(cache, 'isFeatureAvailable');
|
const isFeatureAvailableSpy = jest.spyOn(cache, 'isFeatureAvailable');
|
||||||
let warningSpy = jest.spyOn(core, 'warning');
|
const warningSpy = jest.spyOn(core, 'warning');
|
||||||
|
|
||||||
it('should return true when cache feature is available', () => {
|
it('should return true when cache feature is available', () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
@ -118,16 +153,14 @@ describe('isCacheFeatureAvailable', () => {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
let functionResult;
|
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
functionResult = cacheUtils.isCacheFeatureAvailable();
|
const functionResult = cacheUtils.isCacheFeatureAvailable();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
expect(functionResult).toBeTruthy();
|
expect(functionResult).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should warn when cache feature is unavailable and GHES is not used ', () => {
|
it('should warn when cache feature is unavailable and GHES is not used', () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
isFeatureAvailableSpy.mockImplementation(() => {
|
isFeatureAvailableSpy.mockImplementation(() => {
|
||||||
return false;
|
return false;
|
||||||
@ -135,7 +168,7 @@ describe('isCacheFeatureAvailable', () => {
|
|||||||
|
|
||||||
process.env['GITHUB_SERVER_URL'] = 'https://github.com';
|
process.env['GITHUB_SERVER_URL'] = 'https://github.com';
|
||||||
|
|
||||||
let warningMessage =
|
const warningMessage =
|
||||||
'The runner was not able to contact the cache service. Caching will be skipped';
|
'The runner was not able to contact the cache service. Caching will be skipped';
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
@ -153,16 +186,14 @@ describe('isCacheFeatureAvailable', () => {
|
|||||||
|
|
||||||
process.env['GITHUB_SERVER_URL'] = 'https://github.com';
|
process.env['GITHUB_SERVER_URL'] = 'https://github.com';
|
||||||
|
|
||||||
let functionResult;
|
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
functionResult = cacheUtils.isCacheFeatureAvailable();
|
const functionResult = cacheUtils.isCacheFeatureAvailable();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
expect(functionResult).toBeFalsy();
|
expect(functionResult).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw when cache feature is unavailable and GHES is used', () => {
|
it('should warn when cache feature is unavailable and GHES is used', () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
isFeatureAvailableSpy.mockImplementation(() => {
|
isFeatureAvailableSpy.mockImplementation(() => {
|
||||||
return false;
|
return false;
|
||||||
@ -170,10 +201,49 @@ describe('isCacheFeatureAvailable', () => {
|
|||||||
|
|
||||||
process.env['GITHUB_SERVER_URL'] = 'https://nongithub.com';
|
process.env['GITHUB_SERVER_URL'] = 'https://nongithub.com';
|
||||||
|
|
||||||
let errorMessage =
|
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.';
|
'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
|
//Act + Assert
|
||||||
expect(() => cacheUtils.isCacheFeatureAvailable()).toThrow(errorMessage);
|
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
__tests__/data/.go-version
Normal file
1
__tests__/data/.go-version
Normal file
@ -0,0 +1 @@
|
|||||||
|
1.22.4
|
||||||
1
__tests__/data/.tool-versions
Normal file
1
__tests__/data/.tool-versions
Normal file
@ -0,0 +1 @@
|
|||||||
|
golang 1.23.2
|
||||||
@ -1,6 +1,6 @@
|
|||||||
module example.com/mymodule
|
module example.com/mymodule
|
||||||
|
|
||||||
go 1.14
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
example.com/othermodule v1.2.3
|
example.com/othermodule v1.2.3
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
go 1.19
|
go 1.21
|
||||||
|
|
||||||
use .
|
use .
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user