Skip to content

Commit

Permalink
Implement "check-latest" flag to check if pre-cached version is lates…
Browse files Browse the repository at this point in the history
…t one (#186)
  • Loading branch information
dmitry-shibanov authored Feb 9, 2022
1 parent 44e2214 commit bfdd357
Show file tree
Hide file tree
Showing 17 changed files with 4,828 additions and 3,616 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v2

- name: Set Node.js 12.x
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: 12.x

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/licensed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install licensed
run: |
cd $RUNNER_TEMP
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.12.2/licensed-2.12.2-linux-x64.tar.gz
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.3.1/licensed-3.3.1-linux-x64.tar.gz
sudo tar -xzf licensed.tar.gz
sudo mv licensed /usr/local/bin/licensed
- run: licensed status
17 changes: 17 additions & 0 deletions .github/workflows/versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ jobs:
run: __tests__/verify-go.sh ${{ matrix.go }}
shell: bash

check-latest:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
go-version: [1.16, 1.17]
steps:
- uses: actions/checkout@v2
- name: Setup Go and check latest
uses: ./
with:
go-version: ${{ matrix.go-version }}
check-latest: true
- name: Verify Go
run: go version

setup-versions-from-manifest:
name: Setup ${{ matrix.go }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
node-version: 12
cache: npm

- name: npm install
run: npm install
- name: npm ci
run: npm ci

- name: Lint
run: npm run format-check
Expand Down
2 changes: 1 addition & 1 deletion .licenses/npm/@actions/core.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions .licenses/npm/@actions/http-client-1.0.11.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ This action sets up a go environment for use in actions by:
The V2 offers:
- Adds GOBIN to the PATH
- Proxy Support
- stable input
- `stable` input
- Check latest version
- Bug Fixes (including issues around version matching and semver)

It will first check the local cache for a version match. If version is not found locally, It will pull it from `main` branch of [go-versions](https://github.com/actions/go-versions/blob/main/versions-manifest.json) repository and on miss or failure, it will fall back to the previous behavior of download directly from [go dist](https://storage.googleapis.com/golang).
The 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).

Matching by [semver spec](https://github.com/npm/node-semver):
```yaml
Expand All @@ -46,17 +47,36 @@ steps:
See [action.yml](action.yml)
Basic:
## Basic:
```yaml
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
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@v2
- uses: actions/setup-go@v2
with:
go-version: '1.9.3' # The Go version to download (if necessary) and use.
go-version: '1.14'
check-latest: true
- run: go run hello.go
```

Matrix Testing:
## Matrix Testing:
```yaml
jobs:
build:
Expand Down
25 changes: 25 additions & 0 deletions __tests__/data/versions-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
[
{
"version": "1.17.6",
"stable": true,
"release_url": "https://github.com/actions/go-versions/releases/tag/1.17.6-1668090892",
"files": [
{
"filename": "go-1.17.6-darwin-x64.tar.gz",
"arch": "x64",
"platform": "darwin",
"download_url": "https://github.com/actions/go-versions/releases/download/1.17.6-1668090892/go-1.17.6-darwin-x64.tar.gz"
},
{
"filename": "go-1.17.6-linux-x64.tar.gz",
"arch": "x64",
"platform": "linux",
"download_url": "https://github.com/actions/go-versions/releases/download/1.17.6-1668090892/go-1.17.6-linux-x64.tar.gz"
},
{
"filename": "go-1.17.6-win32-x64.zip",
"arch": "x64",
"platform": "win32",
"download_url": "https://github.com/actions/go-versions/releases/download/1.17.6-1668090892/go-1.17.6-win32-x64.zip"
}
]
},
{
"version": "1.12.17",
"stable": true,
Expand Down
Loading

0 comments on commit bfdd357

Please sign in to comment.