From 690909d8248f174fe76a5b96dba7f700d8a13d4c Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 22 Jun 2020 23:20:52 +0300 Subject: [PATCH] resolve comments --- .github/workflows/versions.yml | 12 +- README.md | 19 +- __tests__/data/versions-manifest.json | 932 +------------------------- __tests__/setup-go.test.ts | 2 +- __tests__/verify-go.sh | 14 + dist/index.js | 32 +- src/installer.ts | 35 +- 7 files changed, 77 insertions(+), 969 deletions(-) create mode 100644 __tests__/verify-go.sh diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index f5db42e00..ed0d48853 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -24,24 +24,24 @@ jobs: with: go-version: ^1.13.6 - - name: validate version - run: go version | grep "go1." + - name: verify go + run: _tests__/verify-go.sh go1.13.6 - name: setup-go 1.13 uses: ./ with: go-version: 1.13 - - name: validate version - run: go version | grep "go1.13." + - name: verify go + run: _tests__/verify-go.sh go1.13.* - name: setup-go 1.12.9 uses: ./ with: go-version: 1.12.9 - - name: validate version - run: go version | grep "go1.12.9" + - name: verify go + run: _tests__/verify-go.sh go1.12.9 - name: dump env shell: bash diff --git a/README.md b/README.md index e88b8603d..d7601ebd4 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,6 @@ This action sets up a go environment for use in actions by: -- optionally installing and adding to PATH a version of Go that is already installed in the tools cache -- downloading, installing and adding to PATH an available version of Go from GitHub Releases ([actions/go-versions](https://github.com/actions/go-versions/releases)) if a specific version is not available in the tools cache - optionally downloading and caching a version of Go by version and adding to PATH - registering problem matchers for error output @@ -73,21 +71,6 @@ jobs: go-version: ${{ matrix.go }} - run: go run hello.go ``` -Download and set up a version of Go that does not come preinstalled on an image: -```yaml -jobs: - build: - runs-on: ubuntu-latest - strategy: - go-version: [1.11.13, 1.12.17, 1.13.12, 1.14.4] - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v1 - with: - go-version: ${{ matrix.go }} - - run: go run my_go.go - -``` # License @@ -99,4 +82,4 @@ Contributions are welcome! See [Contributor's Guide](docs/contributors.md) ## Code of Conduct -:wave: Be nice. See [our code of conduct](CONDUCT) +:wave: Be nice. See [our code of conduct](CONDUCT) \ No newline at end of file diff --git a/__tests__/data/versions-manifest.json b/__tests__/data/versions-manifest.json index 8e24eb8f4..0c24f57b9 100644 --- a/__tests__/data/versions-manifest.json +++ b/__tests__/data/versions-manifest.json @@ -1,951 +1,51 @@ [ { - "version": "1.14.4", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.14.4-20200616.39", - "files": [ - { - "filename": "go-1.14.4-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.14.4-20200616.39/go-1.14.4-darwin-x64.tar.gz" - }, - { - "filename": "go-1.14.4-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.14.4-20200616.39/go-1.14.4-linux-x64.tar.gz" - }, - { - "filename": "go-1.14.4-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.14.4-20200616.39/go-1.14.4-win32-x64.zip" - } - ] - }, - { - "version": "1.14.3", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.14.3-20200616.38", - "files": [ - { - "filename": "go-1.14.3-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.14.3-20200616.38/go-1.14.3-darwin-x64.tar.gz" - }, - { - "filename": "go-1.14.3-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.14.3-20200616.38/go-1.14.3-linux-x64.tar.gz" - }, - { - "filename": "go-1.14.3-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.14.3-20200616.38/go-1.14.3-win32-x64.zip" - } - ] - }, - { - "version": "1.14.2", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.14.2-20200616.37", - "files": [ - { - "filename": "go-1.14.2-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.14.2-20200616.37/go-1.14.2-darwin-x64.tar.gz" - }, - { - "filename": "go-1.14.2-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.14.2-20200616.37/go-1.14.2-linux-x64.tar.gz" - }, - { - "filename": "go-1.14.2-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.14.2-20200616.37/go-1.14.2-win32-x64.zip" - } - ] - }, - { - "version": "1.14.1", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.14.1-20200616.36", - "files": [ - { - "filename": "go-1.14.1-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.14.1-20200616.36/go-1.14.1-darwin-x64.tar.gz" - }, - { - "filename": "go-1.14.1-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.14.1-20200616.36/go-1.14.1-linux-x64.tar.gz" - }, - { - "filename": "go-1.14.1-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.14.1-20200616.36/go-1.14.1-win32-x64.zip" - } - ] - }, - { - "version": "1.14.0", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.14.0-20200616.35", - "files": [ - { - "filename": "go-1.14.0-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.14.0-20200616.35/go-1.14.0-darwin-x64.tar.gz" - }, - { - "filename": "go-1.14.0-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.14.0-20200616.35/go-1.14.0-linux-x64.tar.gz" - }, - { - "filename": "go-1.14.0-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.14.0-20200616.35/go-1.14.0-win32-x64.zip" - } - ] - }, - { - "version": "1.13.12", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.13.12-20200616.34", - "files": [ - { - "filename": "go-1.13.12-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.12-20200616.34/go-1.13.12-darwin-x64.tar.gz" - }, - { - "filename": "go-1.13.12-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.12-20200616.34/go-1.13.12-linux-x64.tar.gz" - }, - { - "filename": "go-1.13.12-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.12-20200616.34/go-1.13.12-win32-x64.zip" - } - ] - }, - { - "version": "1.13.11", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.13.11-20200616.33", - "files": [ - { - "filename": "go-1.13.11-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.11-20200616.33/go-1.13.11-darwin-x64.tar.gz" - }, - { - "filename": "go-1.13.11-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.11-20200616.33/go-1.13.11-linux-x64.tar.gz" - }, - { - "filename": "go-1.13.11-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.11-20200616.33/go-1.13.11-win32-x64.zip" - } - ] - }, - { - "version": "1.13.10", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.13.10-20200616.32", - "files": [ - { - "filename": "go-1.13.10-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.10-20200616.32/go-1.13.10-darwin-x64.tar.gz" - }, - { - "filename": "go-1.13.10-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.10-20200616.32/go-1.13.10-linux-x64.tar.gz" - }, - { - "filename": "go-1.13.10-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.10-20200616.32/go-1.13.10-win32-x64.zip" - } - ] - }, - { - "version": "1.13.9", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.13.9-20200616.31", - "files": [ - { - "filename": "go-1.13.9-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.9-20200616.31/go-1.13.9-darwin-x64.tar.gz" - }, - { - "filename": "go-1.13.9-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.9-20200616.31/go-1.13.9-linux-x64.tar.gz" - }, - { - "filename": "go-1.13.9-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.9-20200616.31/go-1.13.9-win32-x64.zip" - } - ] - }, - { - "version": "1.13.8", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.13.8-20200616.30", - "files": [ - { - "filename": "go-1.13.8-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.8-20200616.30/go-1.13.8-darwin-x64.tar.gz" - }, - { - "filename": "go-1.13.8-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.8-20200616.30/go-1.13.8-linux-x64.tar.gz" - }, - { - "filename": "go-1.13.8-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.8-20200616.30/go-1.13.8-win32-x64.zip" - } - ] - }, - { - "version": "1.13.7", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.13.7-20200616.29", - "files": [ - { - "filename": "go-1.13.7-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.7-20200616.29/go-1.13.7-darwin-x64.tar.gz" - }, - { - "filename": "go-1.13.7-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.7-20200616.29/go-1.13.7-linux-x64.tar.gz" - }, - { - "filename": "go-1.13.7-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.7-20200616.29/go-1.13.7-win32-x64.zip" - } - ] - }, - { - "version": "1.13.6", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.13.6-20200616.28", - "files": [ - { - "filename": "go-1.13.6-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.6-20200616.28/go-1.13.6-darwin-x64.tar.gz" - }, - { - "filename": "go-1.13.6-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.6-20200616.28/go-1.13.6-linux-x64.tar.gz" - }, - { - "filename": "go-1.13.6-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.6-20200616.28/go-1.13.6-win32-x64.zip" - } - ] - }, - { - "version": "1.13.5", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.13.5-20200616.27", - "files": [ - { - "filename": "go-1.13.5-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.5-20200616.27/go-1.13.5-darwin-x64.tar.gz" - }, - { - "filename": "go-1.13.5-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.5-20200616.27/go-1.13.5-linux-x64.tar.gz" - }, - { - "filename": "go-1.13.5-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.5-20200616.27/go-1.13.5-win32-x64.zip" - } - ] - }, - { - "version": "1.13.4", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.13.4-20200616.26", - "files": [ - { - "filename": "go-1.13.4-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.4-20200616.26/go-1.13.4-darwin-x64.tar.gz" - }, - { - "filename": "go-1.13.4-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.4-20200616.26/go-1.13.4-linux-x64.tar.gz" - }, - { - "filename": "go-1.13.4-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.4-20200616.26/go-1.13.4-win32-x64.zip" - } - ] - }, - { - "version": "1.13.3", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.13.3-20200616.25", - "files": [ - { - "filename": "go-1.13.3-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.3-20200616.25/go-1.13.3-darwin-x64.tar.gz" - }, - { - "filename": "go-1.13.3-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.3-20200616.25/go-1.13.3-linux-x64.tar.gz" - }, - { - "filename": "go-1.13.3-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.3-20200616.25/go-1.13.3-win32-x64.zip" - } - ] - }, - { - "version": "1.13.2", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.13.2-20200616.24", - "files": [ - { - "filename": "go-1.13.2-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.2-20200616.24/go-1.13.2-darwin-x64.tar.gz" - }, - { - "filename": "go-1.13.2-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.2-20200616.24/go-1.13.2-linux-x64.tar.gz" - }, - { - "filename": "go-1.13.2-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.2-20200616.24/go-1.13.2-win32-x64.zip" - } - ] - }, - { - "version": "1.13.1", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.13.1-20200616.23", - "files": [ - { - "filename": "go-1.13.1-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.1-20200616.23/go-1.13.1-darwin-x64.tar.gz" - }, - { - "filename": "go-1.13.1-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.1-20200616.23/go-1.13.1-linux-x64.tar.gz" - }, - { - "filename": "go-1.13.1-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.1-20200616.23/go-1.13.1-win32-x64.zip" - } - ] - }, - { - "version": "1.13.0", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.13.0-20200616.22", - "files": [ - { - "filename": "go-1.13.0-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.0-20200616.22/go-1.13.0-darwin-x64.tar.gz" - }, - { - "filename": "go-1.13.0-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.0-20200616.22/go-1.13.0-linux-x64.tar.gz" - }, - { - "filename": "go-1.13.0-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.13.0-20200616.22/go-1.13.0-win32-x64.zip" - } - ] - }, - { - "version": "1.12.17", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.17-20200616.21", - "files": [ - { - "filename": "go-1.12.17-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.17-20200616.21/go-1.12.17-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.17-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.17-20200616.21/go-1.12.17-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.17-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.17-20200616.21/go-1.12.17-win32-x64.zip" - } - ] - }, - { - "version": "1.12.16", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.16-20200616.20", - "files": [ - { - "filename": "go-1.12.16-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.16-20200616.20/go-1.12.16-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.16-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.16-20200616.20/go-1.12.16-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.16-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.16-20200616.20/go-1.12.16-win32-x64.zip" - } - ] - }, - { - "version": "1.12.15", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.15-20200616.19", - "files": [ - { - "filename": "go-1.12.15-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.15-20200616.19/go-1.12.15-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.15-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.15-20200616.19/go-1.12.15-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.15-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.15-20200616.19/go-1.12.15-win32-x64.zip" - } - ] - }, - { - "version": "1.12.14", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.14-20200616.18", - "files": [ - { - "filename": "go-1.12.14-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.14-20200616.18/go-1.12.14-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.14-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.14-20200616.18/go-1.12.14-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.14-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.14-20200616.18/go-1.12.14-win32-x64.zip" - } - ] - }, - { - "version": "1.12.13", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.13-20200616.17", - "files": [ - { - "filename": "go-1.12.13-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.13-20200616.17/go-1.12.13-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.13-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.13-20200616.17/go-1.12.13-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.13-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.13-20200616.17/go-1.12.13-win32-x64.zip" - } - ] - }, - { - "version": "1.12.12", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.12-20200616.16", - "files": [ - { - "filename": "go-1.12.12-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.12-20200616.16/go-1.12.12-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.12-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.12-20200616.16/go-1.12.12-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.12-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.12-20200616.16/go-1.12.12-win32-x64.zip" - } - ] - }, - { - "version": "1.12.11", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.11-20200616.15", - "files": [ - { - "filename": "go-1.12.11-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.11-20200616.15/go-1.12.11-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.11-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.11-20200616.15/go-1.12.11-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.11-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.11-20200616.15/go-1.12.11-win32-x64.zip" - } - ] - }, - { - "version": "1.12.10", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.10-20200616.14", - "files": [ - { - "filename": "go-1.12.10-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.10-20200616.14/go-1.12.10-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.10-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.10-20200616.14/go-1.12.10-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.10-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.10-20200616.14/go-1.12.10-win32-x64.zip" - } - ] - }, - { - "version": "1.12.9", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.9-20200616.13", - "files": [ - { - "filename": "go-1.12.9-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.9-20200616.13/go-1.12.9-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.9-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.9-20200616.13/go-1.12.9-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.9-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.9-20200616.13/go-1.12.9-win32-x64.zip" - } - ] - }, - { - "version": "1.12.8", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.8-20200616.12", - "files": [ - { - "filename": "go-1.12.8-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.8-20200616.12/go-1.12.8-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.8-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.8-20200616.12/go-1.12.8-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.8-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.8-20200616.12/go-1.12.8-win32-x64.zip" - } - ] - }, - { - "version": "1.12.7", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.7-20200616.11", - "files": [ - { - "filename": "go-1.12.7-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.7-20200616.11/go-1.12.7-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.7-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.7-20200616.11/go-1.12.7-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.7-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.7-20200616.11/go-1.12.7-win32-x64.zip" - } - ] - }, - { - "version": "1.12.6", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.6-20200616.10", - "files": [ - { - "filename": "go-1.12.6-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.6-20200616.10/go-1.12.6-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.6-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.6-20200616.10/go-1.12.6-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.6-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.6-20200616.10/go-1.12.6-win32-x64.zip" - } - ] - }, - { - "version": "1.12.5", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.5-20200616.9", - "files": [ - { - "filename": "go-1.12.5-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.5-20200616.9/go-1.12.5-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.5-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.5-20200616.9/go-1.12.5-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.5-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.5-20200616.9/go-1.12.5-win32-x64.zip" - } - ] - }, - { - "version": "1.12.4", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.4-20200616.8", - "files": [ - { - "filename": "go-1.12.4-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.4-20200616.8/go-1.12.4-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.4-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.4-20200616.8/go-1.12.4-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.4-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.4-20200616.8/go-1.12.4-win32-x64.zip" - } - ] - }, - { - "version": "1.12.3", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.3-20200616.7", - "files": [ - { - "filename": "go-1.12.3-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.3-20200616.7/go-1.12.3-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.3-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.3-20200616.7/go-1.12.3-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.3-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.3-20200616.7/go-1.12.3-win32-x64.zip" - } - ] - }, - { - "version": "1.12.2", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.2-20200616.6", - "files": [ - { - "filename": "go-1.12.2-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.2-20200616.6/go-1.12.2-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.2-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.2-20200616.6/go-1.12.2-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.2-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.2-20200616.6/go-1.12.2-win32-x64.zip" - } - ] - }, - { - "version": "1.12.1", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.1-20200616.5", - "files": [ - { - "filename": "go-1.12.1-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.1-20200616.5/go-1.12.1-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.1-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.1-20200616.5/go-1.12.1-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.1-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.1-20200616.5/go-1.12.1-win32-x64.zip" - } - ] - }, - { - "version": "1.12.0", - "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.0-20200616.4", - "files": [ - { - "filename": "go-1.12.0-darwin-x64.tar.gz", - "arch": "x64", - "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.0-20200616.4/go-1.12.0-darwin-x64.tar.gz" - }, - { - "filename": "go-1.12.0-linux-x64.tar.gz", - "arch": "x64", - "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.0-20200616.4/go-1.12.0-linux-x64.tar.gz" - }, - { - "filename": "go-1.12.0-win32-x64.zip", - "arch": "x64", - "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.12.0-20200616.4/go-1.12.0-win32-x64.zip" - } - ] - }, - { - "version": "1.11.13", + "version": "1.12.17", "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.11.13-20200616.3", + "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.17-20200616.21", "files": [ { - "filename": "go-1.11.13-darwin-x64.tar.gz", + "filename": "go-1.12.17-darwin-x64.tar.gz", "arch": "x64", "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.11.13-20200616.3/go-1.11.13-darwin-x64.tar.gz" + "download_url": "https://github.com/actions/go-versions/releases/download/1.12.17-20200616.21/go-1.12.17-darwin-x64.tar.gz" }, { - "filename": "go-1.11.13-linux-x64.tar.gz", + "filename": "go-1.12.17-linux-x64.tar.gz", "arch": "x64", "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.11.13-20200616.3/go-1.11.13-linux-x64.tar.gz" + "download_url": "https://github.com/actions/go-versions/releases/download/1.12.17-20200616.21/go-1.12.17-linux-x64.tar.gz" }, { - "filename": "go-1.11.13-win32-x64.zip", + "filename": "go-1.12.17-win32-x64.zip", "arch": "x64", "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.11.13-20200616.3/go-1.11.13-win32-x64.zip" + "download_url": "https://github.com/actions/go-versions/releases/download/1.12.17-20200616.21/go-1.12.17-win32-x64.zip" } ] }, { - "version": "1.10.8", + "version": "1.12.16", "stable": true, - "release_url": "https://github.com/actions/go-versions/releases/tag/1.10.8-20200616.2", + "release_url": "https://github.com/actions/go-versions/releases/tag/1.12.16-20200616.20", "files": [ { - "filename": "go-1.10.8-darwin-x64.tar.gz", + "filename": "go-1.12.16-darwin-x64.tar.gz", "arch": "x64", "platform": "darwin", - "download_url": "https://github.com/actions/go-versions/releases/download/1.10.8-20200616.2/go-1.10.8-darwin-x64.tar.gz" + "download_url": "https://github.com/actions/go-versions/releases/download/1.12.16-20200616.20/go-1.12.16-darwin-x64.tar.gz" }, { - "filename": "go-1.10.8-linux-x64.tar.gz", + "filename": "go-1.12.16-linux-x64.tar.gz", "arch": "x64", "platform": "linux", - "download_url": "https://github.com/actions/go-versions/releases/download/1.10.8-20200616.2/go-1.10.8-linux-x64.tar.gz" + "download_url": "https://github.com/actions/go-versions/releases/download/1.12.16-20200616.20/go-1.12.16-linux-x64.tar.gz" }, { - "filename": "go-1.10.8-win32-x64.zip", + "filename": "go-1.12.16-win32-x64.zip", "arch": "x64", "platform": "win32", - "download_url": "https://github.com/actions/go-versions/releases/download/1.10.8-20200616.2/go-1.10.8-win32-x64.zip" + "download_url": "https://github.com/actions/go-versions/releases/download/1.12.16-20200616.20/go-1.12.16-win32-x64.zip" } ] }, diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index 25b0ab0a7..826498183 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -114,7 +114,7 @@ describe('setup-go', () => { 'mocktoken' ); expect(versions).toBeDefined(); - expect(versions.length).toBe(39); + expect(versions.length).toBe(3); }); it('can find 1.12.17 from manifest on osx', async () => { diff --git a/__tests__/verify-go.sh b/__tests__/verify-go.sh new file mode 100644 index 000000000..37e6d1333 --- /dev/null +++ b/__tests__/verify-go.sh @@ -0,0 +1,14 @@ + +#!/bin/sh + +if [ -z "$1" ]; then + echo "Must supply go version argument" + exit 1 +fi + +go_version="$(go version)" +echo "Found go version '$go_version'" +if [ -z "$(echo $go_version | grep $1)" ]; then + echo "Unexpected version" + exit 1 +fi \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 35925d779..e02c0ca90 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6955,7 +6955,7 @@ function getGo(versionSpec, stable, auth) { info = yield getInfoFromManifest(versionSpec, stable, auth); if (info) { console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); - downloadPath = yield tc.downloadTool(info.downloadUrl, undefined, auth); + downloadPath = yield installGoVersion(info, auth); } else { console.log('Not found in manifest. Falling back to download directly from Go'); @@ -6982,27 +6982,31 @@ function getGo(versionSpec, stable, auth) { } console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); try { - downloadPath = yield tc.downloadTool(info.downloadUrl); + downloadPath = yield installGoVersion(info, auth); } catch (err) { throw new Error(`Failed to download version ${versionSpec}: ${err}`); } } - // - // Extract - // - console.log('Extracting ...'); - let extPath = yield extractGoArchive(downloadPath); - info = info || {}; // satisfy compiler, never null when reaches here - // - // Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded - // - console.log('Adding to the cache ...'); - toolPath = yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion)); - return toolPath; + return downloadPath; }); } exports.getGo = getGo; +function installGoVersion(info, auth) { + return __awaiter(this, void 0, void 0, function* () { + const localPath = tc.find('go', info.resolvedVersion); + if (localPath) { + console.log(`Found in cache @ ${localPath}`); + return localPath; + } + console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); + const downloadPath = yield tc.downloadTool(info.downloadUrl, undefined, auth); + console.log('Extracting Go...'); + const extPath = yield extractGoArchive(downloadPath); + console.log('Adding to the cache ...'); + return yield tc.cacheDir(extPath, 'go', info.resolvedVersion); + }); +} function extractGoArchive(archivePath) { return __awaiter(this, void 0, void 0, function* () { const arch = os_1.default.arch(); diff --git a/src/installer.ts b/src/installer.ts index 9705b5156..7298144f9 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -53,7 +53,7 @@ export async function getGo( info = await getInfoFromManifest(versionSpec, stable, auth); if (info) { console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); - downloadPath = await tc.downloadTool(info.downloadUrl, undefined, auth); + downloadPath = await installGoVersion(info, auth); } else { console.log( 'Not found in manifest. Falling back to download directly from Go' @@ -87,26 +87,33 @@ export async function getGo( console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); try { - downloadPath = await tc.downloadTool(info.downloadUrl); + downloadPath = await installGoVersion(info, auth); } catch (err) { throw new Error(`Failed to download version ${versionSpec}: ${err}`); } } - // - // Extract - // - console.log('Extracting ...'); - let extPath = await extractGoArchive(downloadPath); - info = info || ({} as IGoVersionInfo); // satisfy compiler, never null when reaches here + return downloadPath; +} - // - // Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded - // - console.log('Adding to the cache ...'); - toolPath = await tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion)); +async function installGoVersion( + info: IGoVersionInfo, + auth: string | undefined +): Promise { + const localPath = tc.find('go', info.resolvedVersion); + if (localPath) { + console.log(`Found in cache @ ${localPath}`); + return localPath; + } + + console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); + const downloadPath = await tc.downloadTool(info.downloadUrl, undefined, auth); - return toolPath; + console.log('Extracting Go...'); + const extPath = await extractGoArchive(downloadPath); + + console.log('Adding to the cache ...'); + return await tc.cacheDir(extPath, 'go', info.resolvedVersion); } export async function extractGoArchive(archivePath: string): Promise {