mirror of
https://github.com/actions/setup-go.git
synced 2026-06-24 06:17:42 +00:00
Compare commits
44 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 |
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 -->
|
||||
|
||||
**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
|
||||
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 -->
|
||||
|
||||
**Description:**
|
||||
|
||||
2
.github/workflows/basic-validation.yml
vendored
2
.github/workflows/basic-validation.yml
vendored
@ -15,4 +15,4 @@ jobs:
|
||||
name: Basic validation
|
||||
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
|
||||
with:
|
||||
node-version: '20'
|
||||
node-version: '24.x'
|
||||
|
||||
2
.github/workflows/check-dist.yml
vendored
2
.github/workflows/check-dist.yml
vendored
@ -16,4 +16,4 @@ jobs:
|
||||
name: Check dist/
|
||||
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
|
||||
with:
|
||||
node-version: '20'
|
||||
node-version: '24.x'
|
||||
|
||||
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
|
||||
@ -14,7 +14,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checking out
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
- name: Publish
|
||||
id: publish
|
||||
uses: actions/publish-immutable-action@v0.0.4
|
||||
|
||||
@ -22,7 +22,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Update the ${{ env.TAG_NAME }} tag
|
||||
uses: actions/publish-action@v0.3.0
|
||||
uses: actions/publish-action@v0.4.0
|
||||
with:
|
||||
source-tag: ${{ env.TAG_NAME }}
|
||||
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
||||
|
||||
76
.github/workflows/versions.yml
vendored
76
.github/workflows/versions.yml
vendored
@ -18,9 +18,9 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- name: Setup Go Stable
|
||||
uses: ./
|
||||
with:
|
||||
@ -33,9 +33,9 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- name: Setup Go oldStable
|
||||
uses: ./
|
||||
with:
|
||||
@ -48,16 +48,16 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||
version: [stable, oldstable]
|
||||
architecture: [x64, x32]
|
||||
exclude:
|
||||
- os: macos-latest
|
||||
architecture: x32
|
||||
- os: macos-13
|
||||
- os: macos-latest-large
|
||||
architecture: x32
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }}
|
||||
uses: ./
|
||||
with:
|
||||
@ -72,7 +72,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest, macos-13]
|
||||
os: [macos-latest, windows-latest, ubuntu-latest, macos-latest-large]
|
||||
go: [1.21.13, 1.22.8, 1.23.2]
|
||||
include:
|
||||
- os: windows-latest
|
||||
@ -82,7 +82,7 @@ jobs:
|
||||
go: 1.23.2
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: setup-go ${{ matrix.go }}
|
||||
uses: ./
|
||||
@ -98,10 +98,10 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||
go-version: ['1.20', '1.21', '1.22', '1.23']
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- name: Setup Go and check latest
|
||||
uses: ./
|
||||
with:
|
||||
@ -115,9 +115,9 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- name: Setup Go and check latest
|
||||
uses: ./
|
||||
with:
|
||||
@ -131,9 +131,9 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- name: Setup Go and check latest
|
||||
uses: ./
|
||||
with:
|
||||
@ -142,16 +142,48 @@ jobs:
|
||||
run: __tests__/verify-go.sh 1.21
|
||||
shell: bash
|
||||
|
||||
go-version-file-with-tool-versions:
|
||||
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 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-13]
|
||||
os: [macos-latest, windows-latest, ubuntu-latest, macos-latest-large]
|
||||
go: [1.20.14, 1.21.10, 1.22.8, 1.23.2]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: setup-go ${{ matrix.go }}
|
||||
uses: ./
|
||||
@ -167,11 +199,11 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [windows-latest, ubuntu-latest, macos-13]
|
||||
os: [windows-latest, ubuntu-latest, macos-latest-large]
|
||||
go: [1.11.12]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: setup-go ${{ matrix.go }}
|
||||
uses: ./
|
||||
@ -187,7 +219,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||
go-version: [1.20.14, 1.21, 1.22, 1.23]
|
||||
include:
|
||||
- os: macos-latest
|
||||
@ -196,10 +228,10 @@ jobs:
|
||||
architecture: x64
|
||||
- os: windows-latest
|
||||
architecture: x64
|
||||
- os: macos-13
|
||||
- os: macos-latest-large
|
||||
architecture: x64
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- name: Setup Go and check latest
|
||||
uses: ./
|
||||
with:
|
||||
|
||||
6
.github/workflows/windows-validation.yml
vendored
6
.github/workflows/windows-validation.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
||||
cache: [false, true]
|
||||
go: [1.20.1]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: 'Setup ${{ matrix.cache }}, cache: ${{ matrix.go }}'
|
||||
uses: ./
|
||||
@ -88,7 +88,7 @@ jobs:
|
||||
matrix:
|
||||
cache: [false, true]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: 'Setup default go, cache: ${{ matrix.cache }}'
|
||||
uses: ./
|
||||
@ -121,7 +121,7 @@ jobs:
|
||||
cache: [false]
|
||||
go: [1.20.1]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}'
|
||||
uses: ./
|
||||
|
||||
@ -12,4 +12,5 @@ allowed:
|
||||
- 0bsd
|
||||
|
||||
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.4.0.dep.yml
generated
BIN
.licenses/npm/@actions/glob-0.4.0.dep.yml
generated
Binary file not shown.
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.
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
BIN
.licenses/npm/@azure/core-util.dep.yml
generated
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/@fastify/busboy.dep.yml
generated
BIN
.licenses/npm/@fastify/busboy.dep.yml
generated
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.
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/@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.
BIN
.licenses/npm/anynum.dep.yml
generated
Normal file
BIN
.licenses/npm/anynum.dep.yml
generated
Normal file
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/camel-case.dep.yml
generated
BIN
.licenses/npm/camel-case.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.
BIN
.licenses/npm/dot-object.dep.yml
generated
BIN
.licenses/npm/dot-object.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-4.0.0.dep.yml
generated
BIN
.licenses/npm/form-data-4.0.0.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/fs.realpath.dep.yml
generated
BIN
.licenses/npm/fs.realpath.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/glob.dep.yml
generated
BIN
.licenses/npm/glob.dep.yml
generated
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/inflight.dep.yml
generated
BIN
.licenses/npm/inflight.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/lodash.dep.yml
generated
BIN
.licenses/npm/lodash.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/lower-case.dep.yml
generated
BIN
.licenses/npm/lower-case.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/lru-cache.dep.yml
generated
BIN
.licenses/npm/lru-cache.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.
Binary file not shown.
BIN
.licenses/npm/no-case.dep.yml
generated
BIN
.licenses/npm/no-case.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/once.dep.yml
generated
BIN
.licenses/npm/once.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/pascal-case.dep.yml
generated
BIN
.licenses/npm/pascal-case.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/path-is-absolute.dep.yml
generated
BIN
.licenses/npm/path-is-absolute.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/path-to-regexp.dep.yml
generated
BIN
.licenses/npm/path-to-regexp.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/prettier.dep.yml
generated
BIN
.licenses/npm/prettier.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.
Binary file not shown.
BIN
.licenses/npm/ts-poet.dep.yml
generated
BIN
.licenses/npm/ts-poet.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.
Binary file not shown.
BIN
.licenses/npm/twirp-ts.dep.yml
generated
BIN
.licenses/npm/twirp-ts.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.dep.yml
generated
BIN
.licenses/npm/undici.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/wrappy.dep.yml
generated
BIN
.licenses/npm/wrappy.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.
BIN
.licenses/npm/yallist.dep.yml
generated
BIN
.licenses/npm/yallist.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/yaml.dep.yml
generated
BIN
.licenses/npm/yaml.dep.yml
generated
Binary file not shown.
341
README.md
341
README.md
@ -3,68 +3,96 @@
|
||||
[](https://github.com/actions/setup-go/actions/workflows/basic-validation.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`.
|
||||
- Registering problem matchers for error output.
|
||||
- Optionally downloading and caching a version of Go by version and adding it to the PATH
|
||||
- Optionally caching Go modules and build outputs
|
||||
- Registering problem matchers for error output
|
||||
|
||||
# V5
|
||||
## Breaking changes in V6
|
||||
|
||||
The V5 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)
|
||||
|
||||
- Upgraded Node.js runtime from node16 to node20
|
||||
- **Go toolchain**
|
||||
- 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.
|
||||
|
||||
- **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.
|
||||
|
||||
See full release notes on the [releases page](https://github.com/actions/setup-go/releases).
|
||||
|
||||
# V4
|
||||
## Usage
|
||||
|
||||
The V4 edition of the action offers:
|
||||
See [action.yml](action.yml).
|
||||
|
||||
- Enabled caching by default
|
||||
<!-- start usage -->
|
||||
```yaml
|
||||
- uses: actions/setup-go@v6
|
||||
with:
|
||||
# Version or version range of Go to use
|
||||
go-version: '1.23'
|
||||
|
||||
# Path to go.mod, go.work, .go-version, or .tool-versions file
|
||||
# Note: if both go-version and go-version-file are provided, go-version takes precedence.
|
||||
go-version-file: 'go.mod'
|
||||
|
||||
# Set this option if you want the action to check for the latest available version
|
||||
# Default: false
|
||||
check-latest: false
|
||||
|
||||
# GitHub token for authentication
|
||||
token: ${{ github.token }}
|
||||
|
||||
# Used to specify whether caching is needed.
|
||||
# Default: true
|
||||
cache: true
|
||||
|
||||
# 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 -->
|
||||
|
||||
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)
|
||||
|
||||
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).
|
||||
|
||||
**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):
|
||||
**Basic:**
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: '^1.13.1' # The Go version to download (if necessary) and use.
|
||||
- run: go version
|
||||
go-version: '1.25' # The Go version to download (if necessary) and use.
|
||||
- run: go run hello.go
|
||||
```
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '>=1.17.0'
|
||||
- run: go version
|
||||
```
|
||||
**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:
|
||||
|
||||
- Specific versions: `1.25`, `1.24.11`, `1.24.0-rc.1`, `1.23.0-beta.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 details on Semantic Versioning, see [the semver package documentation](https://github.com/npm/node-semver).
|
||||
|
||||
> **Note**: Due to the peculiarities of YAML parsing, it is recommended to wrap the version in single quotation marks:
|
||||
>
|
||||
@ -72,195 +100,9 @@ steps:
|
||||
> 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.
|
||||
> 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:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.18.0-rc.1' # The Go version to download (if necessary) and use.
|
||||
- run: go version
|
||||
```
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
# Usage
|
||||
|
||||
See [action.yml](action.yml)
|
||||
|
||||
## Basic
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
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@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
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
go: [ '1.14', '1.13' ]
|
||||
name: Go ${{ matrix.go }} sample
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
- run: go run hello.go
|
||||
```
|
||||
|
||||
### Supported version 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`
|
||||
- SemVer's version range syntax: `^1.13.1`, `>=1.18.0-rc.1`
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
## Recommended permissions
|
||||
|
||||
@ -271,13 +113,36 @@ permissions:
|
||||
contents: read # access to check out code and install dependencies
|
||||
```
|
||||
|
||||
# License
|
||||
## Caching dependency files and build outputs
|
||||
|
||||
The scripts and documentation in this project are released under the [MIT License](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`.
|
||||
|
||||
# Contributions
|
||||
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 are welcome! See [Contributor's Guide](docs/contributors.md)
|
||||
If caching cannot be performed for any reason, the action logs a warning and continues workflow execution.
|
||||
|
||||
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
|
||||
|
||||
|
||||
@ -1,94 +1,83 @@
|
||||
import * as cache from '@actions/cache';
|
||||
import * as core from '@actions/core';
|
||||
import * as glob from '@actions/glob';
|
||||
import fs from 'fs';
|
||||
|
||||
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');
|
||||
let hashFilesSpy: jest.SpyInstance;
|
||||
let getCacheDirectoryPathSpy: jest.SpyInstance;
|
||||
let restoreCacheSpy: jest.SpyInstance;
|
||||
let infoSpy: jest.SpyInstance;
|
||||
let setOutputSpy: jest.SpyInstance;
|
||||
|
||||
const versionSpec = '1.13.1';
|
||||
const packageManager = 'default';
|
||||
const cacheDependencyPath = 'path';
|
||||
|
||||
let originalWorkspace: string | undefined;
|
||||
|
||||
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(
|
||||
(PackageManager: PackageManagerInfo) => {
|
||||
return new Promise<string[]>(resolve => {
|
||||
resolve(['cache_directory_path', 'cache_directory_path']);
|
||||
});
|
||||
return Promise.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('');
|
||||
});
|
||||
});
|
||||
afterEach(() => {
|
||||
process.env.GITHUB_WORKSPACE = originalWorkspace;
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
//Act + Assert
|
||||
await expect(async () => {
|
||||
await cacheRestore.restoreCache(
|
||||
it('should throw if dependency file path is not valid', async () => {
|
||||
// Arrange
|
||||
hashFilesSpy.mockImplementation(() => Promise.resolve(''));
|
||||
// Act + Assert
|
||||
await expect(
|
||||
cacheRestore.restoreCache(
|
||||
versionSpec,
|
||||
packageManager,
|
||||
cacheDependencyPath
|
||||
);
|
||||
}).rejects.toThrow(
|
||||
)
|
||||
).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
|
||||
it('should inform if cache hit is not occurred', async () => {
|
||||
// Arrange
|
||||
hashFilesSpy.mockImplementation(() => Promise.resolve('file_hash'));
|
||||
restoreCacheSpy.mockImplementation(() => Promise.resolve(''));
|
||||
// Act + Assert
|
||||
await cacheRestore.restoreCache(
|
||||
versionSpec,
|
||||
packageManager,
|
||||
cacheDependencyPath
|
||||
);
|
||||
expect(infoSpy).toHaveBeenCalledWith(`Cache is not found`);
|
||||
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
|
||||
it('should set output if cache hit is occurred', async () => {
|
||||
// Arrange
|
||||
hashFilesSpy.mockImplementation(() => Promise.resolve('file_hash'));
|
||||
restoreCacheSpy.mockImplementation(() => Promise.resolve('cache_key'));
|
||||
// Act + Assert
|
||||
await cacheRestore.restoreCache(
|
||||
versionSpec,
|
||||
packageManager,
|
||||
@ -96,4 +85,18 @@ describe('restoreCache', () => {
|
||||
);
|
||||
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();
|
||||
});
|
||||
});
|
||||
@ -47,7 +47,7 @@ describe('getPackageManagerInfo', () => {
|
||||
//Arrange
|
||||
const packageManagerName = 'default';
|
||||
const expectedResult = {
|
||||
dependencyFilePattern: 'go.sum',
|
||||
dependencyFilePattern: 'go.mod',
|
||||
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
|
||||
};
|
||||
|
||||
@ -73,7 +73,7 @@ describe('getCacheDirectoryPath', () => {
|
||||
const getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
||||
|
||||
const validPackageManager: PackageManagerInfo = {
|
||||
dependencyFilePattern: 'go.sum',
|
||||
dependencyFilePattern: 'go.mod',
|
||||
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
|
||||
};
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user