Compare commits

..

No commits in common. "main" and "v4" have entirely different histories.
main ... v4

46 changed files with 19548 additions and 67423 deletions

View File

@ -14,5 +14,3 @@ jobs:
call-basic-validation:
name: Basic validation
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
with:
node-version: '20'

View File

@ -15,5 +15,3 @@ jobs:
call-check-dist:
name: Check dist/
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
with:
node-version: '20'

View File

@ -20,7 +20,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Setup Go Stable
uses: ./
with:
@ -35,7 +35,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Setup Go oldStable
uses: ./
with:
@ -55,7 +55,7 @@ jobs:
- os: macos-latest
architecture: x32
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }}
uses: ./
with:
@ -71,10 +71,10 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
go: [1.20.14, 1.21.10, 1.22.3]
go: [1.17, 1.18, 1.19]
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: setup-go ${{ matrix.go }}
uses: ./
@ -91,9 +91,9 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
go-version: [1.20.14, 1.21]
go-version: [1.16, 1.17]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Setup Go and check latest
uses: ./
with:
@ -109,13 +109,13 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Setup Go and check latest
uses: ./
with:
go-version-file: __tests__/data/go.mod
- name: verify go
run: __tests__/verify-go.sh 1.20.14
run: __tests__/verify-go.sh 1.14
shell: bash
go-version-file-with-gowork:
@ -125,13 +125,13 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Setup Go and check latest
uses: ./
with:
go-version-file: __tests__/data/go.work
- name: verify go
run: __tests__/verify-go.sh 1.21
run: __tests__/verify-go.sh 1.19
shell: bash
setup-versions-from-manifest:
@ -141,10 +141,10 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
go: [1.20.14, 1.21.10, 1.22.3]
go: [1.12.16, 1.13.11, 1.14.3]
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: setup-go ${{ matrix.go }}
uses: ./
@ -162,10 +162,10 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
go: [1.20.14, 1.21]
go: [1.9, 1.8.6]
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: setup-go ${{ matrix.go }}
uses: ./
@ -182,9 +182,9 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
go-version: [1.20.14, 1.21]
go-version: [1.16, 1.17]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Setup Go and check latest
uses: ./
with:

View File

@ -19,7 +19,7 @@ jobs:
cache: [false, true]
go: [1.20.1]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- 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@v3
- name: 'Setup default go, cache: ${{ matrix.cache }}'
uses: ./
@ -112,25 +112,3 @@ jobs:
exit 1
fi
shell: bash
hostedtoolcache:
name: 'Validate if hostedtoolcache works as expected'
runs-on: windows-latest
strategy:
matrix:
cache: [false]
go: [1.20.1]
steps:
- uses: actions/checkout@v4
- name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}'
uses: ./
with:
go-version: ${{ matrix.go }}
cache: ${{ matrix.cache }}
- name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }} (from hostedtoolcache)'
uses: ./
with:
go-version: ${{ matrix.go }}
cache: ${{ matrix.cache }}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/form-data-3.0.1.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/tslib-2.3.1.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -8,14 +8,6 @@ This action sets up a go environment for use in actions by:
- Optionally downloading and caching a version of Go by version and adding to `PATH`.
- Registering problem matchers for error output.
# V5
The V5 edition of the action offers:
- Upgraded Node.js runtime from node16 to node20
See full release notes on the [releases page](https://github.com/actions/setup-go/releases).
# V4
The V4 edition of the action offers:
@ -50,8 +42,8 @@ Matching by [semver spec](https://github.com/npm/node-semver):
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '^1.13.1' # The Go version to download (if necessary) and use.
- run: go version
@ -59,8 +51,8 @@ steps:
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '>=1.17.0'
- run: go version
@ -73,13 +65,12 @@ steps:
> ```
>
> 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
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.18.0-rc.1' # The Go version to download (if necessary) and use.
- run: go version
@ -87,8 +78,8 @@ steps:
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.16.0-beta.1' # The Go version to download (if necessary) and use.
- run: go version
@ -102,8 +93,8 @@ See [action.yml](action.yml)
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.16.1' # The Go version to download (if necessary) and use.
- run: go run hello.go
@ -123,8 +114,8 @@ want the most up-to-date Go version to always be used.
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.14'
check-latest: true
@ -144,8 +135,8 @@ set to `true`
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 'stable'
- run: go run hello.go
@ -153,8 +144,8 @@ steps:
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 'oldstable'
- run: go run hello.go
@ -168,7 +159,7 @@ 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.
in different subdirectories.
If some problem that prevents success caching happens then the action issues the warning in the log and continues the execution of the pipeline.
@ -176,36 +167,30 @@ If some problem that prevents success caching happens then the action issues the
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.17'
check-latest: true
cache-dependency-path: |
subdir/go.sum
tools/go.sum
# cache-dependency-path: "**/*.sum"
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.
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.
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 [versions-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
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: 'path/to/go.mod'
- run: go version
@ -222,9 +207,9 @@ jobs:
go: [ '1.14', '1.13' ]
name: Go ${{ matrix.go }} sample
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v5
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- run: go run hello.go
@ -256,7 +241,7 @@ can [generate a personal access token on github.com](https://github.com/settings
input for the action:
```yaml
uses: actions/setup-go@v5
uses: actions/setup-go@v4
with:
token: ${{ secrets.GH_DOTCOM_TOKEN }}
go-version: '1.18'

View File

@ -1,6 +1,6 @@
module example.com/mymodule
go 1.20
go 1.14
require (
example.com/othermodule v1.2.3

View File

@ -1,3 +1,3 @@
go 1.21
go 1.19
use .

View File

@ -25,7 +25,7 @@ outputs:
cache-hit:
description: 'A boolean value to indicate if a cache was hit'
runs:
using: 'node20'
using: 'node16'
main: 'dist/setup/index.js'
post: 'dist/cache-save/index.js'
post-if: success()

36477
dist/cache-save/index.js vendored

File diff suppressed because one or more lines are too long

41201
dist/setup/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -32,7 +32,7 @@ We don't pursue the goal to provide wide customization of caching in scope of `a
```yml
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '18'
@ -43,7 +43,7 @@ steps:
```yml
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '18'
@ -53,7 +53,7 @@ steps:
```yml
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '18'

8828
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "setup-go",
"version": "5.0.0",
"version": "4.0.0",
"private": true,
"description": "setup go action",
"main": "lib/setup-go.js",
@ -25,31 +25,31 @@
"author": "GitHub",
"license": "MIT",
"dependencies": {
"@actions/cache": "^3.2.4",
"@actions/cache": "^3.2.1",
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.0",
"@actions/glob": "^0.4.0",
"@actions/http-client": "^2.2.1",
"@actions/glob": "^0.2.0",
"@actions/http-client": "^2.0.1",
"@actions/io": "^1.0.2",
"@actions/tool-cache": "^2.0.1",
"semver": "^7.6.0"
"@actions/tool-cache": "^1.5.5",
"semver": "^6.3.1"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/node": "^20.11.28",
"@types/semver": "^7.5.8",
"@types/jest": "^27.0.2",
"@types/node": "^16.11.25",
"@types/semver": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
"@vercel/ncc": "^0.38.1",
"eslint": "^8.57.0",
"@vercel/ncc": "^0.33.4",
"eslint": "^8.35.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-node": "^11.1.0",
"jest": "^29.7.0",
"jest-circus": "^29.7.0",
"jest": "^27.2.5",
"jest-circus": "^27.2.5",
"nock": "^10.0.6",
"prettier": "^2.8.4",
"ts-jest": "^29.1.2",
"typescript": "^5.4.2"
"ts-jest": "^27.0.5",
"typescript": "^4.3.3"
}
}

View File

@ -12,19 +12,9 @@ process.on('uncaughtException', e => {
core.info(`${warningPrefix}${e.message}`);
});
// Added early exit to resolve issue with slow post action step:
// - https://github.com/actions/setup-node/issues/878
// https://github.com/actions/cache/pull/1217
export async function run(earlyExit?: boolean) {
export async function run() {
try {
const cacheInput = core.getBooleanInput('cache');
if (cacheInput) {
await cachePackages();
if (earlyExit) {
process.exit(0);
}
}
} catch (error) {
let message = 'Unknown error!';
if (error instanceof Error) {
@ -38,6 +28,11 @@ export async function run(earlyExit?: boolean) {
}
const cachePackages = async () => {
const cacheInput = core.getBooleanInput('cache');
if (!cacheInput) {
return;
}
const packageManager = 'default';
const state = core.getState(State.CacheMatchedKey);
@ -90,4 +85,4 @@ function logWarning(message: string): void {
core.info(`${warningPrefix}${message}`);
}
run(true);
run();

View File

@ -114,9 +114,9 @@ export async function getGo(
`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`
);
} else {
core.info((err as Error).message);
core.info(err.message);
}
core.debug((err as Error).stack ?? '');
core.debug(err.stack);
core.info('Falling back to download directly from Go');
}
@ -160,7 +160,7 @@ async function resolveVersionFromManifest(
return info?.resolvedVersion;
} catch (err) {
core.info('Unable to resolve a version from the manifest...');
core.debug((err as Error).message);
core.debug(err.message);
}
}
@ -203,17 +203,6 @@ async function cacheWindowsDir(
fs.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction');
core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`);
const actualToolCacheCompleteFile = `${actualToolCacheDir}.complete`;
const defaultToolCacheCompleteFile = `${defaultToolCacheDir}.complete`;
fs.symlinkSync(
actualToolCacheCompleteFile,
defaultToolCacheCompleteFile,
'file'
);
core.info(
`Created link ${defaultToolCacheCompleteFile} => ${actualToolCacheCompleteFile}`
);
// make outer code to continue using toolcache as if it were installed on c:
// restore toolcache root to default drive c:
process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot;

View File

@ -74,7 +74,7 @@ export async function run() {
cacheDependencyPath
);
} catch (error) {
core.warning(`Restore cache failed: ${(error as Error).message}`);
core.warning(`Restore cache failed: ${error.message}`);
}
}
@ -92,7 +92,7 @@ export async function run() {
core.info(goEnv);
core.endGroup();
} catch (error) {
core.setFailed((error as Error).message);
core.setFailed(error.message);
}
}