mirror of
https://github.com/actions/setup-go.git
synced 2025-04-23 17:40:50 +00:00
Merge branch 'main' into go-version-from-file
This commit is contained in:
commit
757cc0bb4a
35 changed files with 10068 additions and 8373 deletions
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
* text=auto
|
||||||
|
.licenses/** -diff linguist-generated=true
|
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a bug report
|
||||||
|
title: ''
|
||||||
|
labels: bug, 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 --->
|
||||||
|
<!--- Before opening up a new bug report, please make sure to check for similar existing issues -->
|
||||||
|
|
||||||
|
**Description:**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**Action version:**
|
||||||
|
Specify the action version
|
||||||
|
|
||||||
|
**Platform:**
|
||||||
|
- [ ] Ubuntu
|
||||||
|
- [ ] macOS
|
||||||
|
- [ ] Windows
|
||||||
|
|
||||||
|
**Runner type:**
|
||||||
|
- [ ] Hosted
|
||||||
|
- [ ] Self-hosted
|
||||||
|
|
||||||
|
**Tools version:**
|
||||||
|
<!--- Please specify go version -->
|
||||||
|
|
||||||
|
**Repro steps:**
|
||||||
|
A description with steps to reproduce the issue. If your have a public example or repo to share, please provide the link.
|
||||||
|
|
||||||
|
**Expected behavior:**
|
||||||
|
A description of what you expected to happen.
|
||||||
|
|
||||||
|
**Actual behavior:**
|
||||||
|
A description of what is actually happening.
|
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
blank_issues_enabled: false
|
18
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
18
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
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 --->
|
||||||
|
<!--- Before opening up a new feature request, please make sure to check for similar existing issues and pull requests -->
|
||||||
|
|
||||||
|
**Description:**
|
||||||
|
Describe your proposal.
|
||||||
|
|
||||||
|
**Justification:**
|
||||||
|
Justification or a use case for your proposal.
|
||||||
|
|
||||||
|
**Are you willing to submit a PR?**
|
||||||
|
<!--- We accept contributions! -->
|
9
.github/pull_request_template.md
vendored
Normal file
9
.github/pull_request_template.md
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
**Description:**
|
||||||
|
Describe your changes.
|
||||||
|
|
||||||
|
**Related issue:**
|
||||||
|
Add link to the related issue.
|
||||||
|
|
||||||
|
**Check list:**
|
||||||
|
- [ ] Mark if documentation changes are required.
|
||||||
|
- [ ] Mark if tests were added or updated to cover the changes.
|
51
.github/workflows/check-dist.yml
vendored
Normal file
51
.github/workflows/check-dist.yml
vendored
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
# `dist/index.js` is a special file in Actions.
|
||||||
|
# When you reference an action with `uses:` in a workflow,
|
||||||
|
# `index.js` is the code that will run.
|
||||||
|
# For our project, we generate this file through a build process from other source files.
|
||||||
|
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
|
||||||
|
name: Check dist/
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-dist:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set Node.js 16.x
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16.x
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Rebuild the dist/ directory
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
|
- name: Compare the expected and actual dist/ directories
|
||||||
|
run: |
|
||||||
|
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
|
||||||
|
echo "Detected uncommitted changes after build. See status below:"
|
||||||
|
git diff
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
id: diff
|
||||||
|
|
||||||
|
# If index.js was different than expected, upload the expected version as an artifact
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||||
|
with:
|
||||||
|
name: dist
|
||||||
|
path: dist/
|
28
.github/workflows/licensed.yml
vendored
Normal file
28
.github/workflows/licensed.yml
vendored
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
name: Licensed
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Check licenses
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Set Node.js 16.x
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16.x
|
||||||
|
- run: npm ci
|
||||||
|
- name: Install licensed
|
||||||
|
run: |
|
||||||
|
cd $RUNNER_TEMP
|
||||||
|
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.4.4/licensed-3.4.4-linux-x64.tar.gz
|
||||||
|
sudo tar -xzf licensed.tar.gz
|
||||||
|
sudo mv licensed /usr/local/bin/licensed
|
||||||
|
- run: licensed status
|
27
.github/workflows/release-new-action-version.yml
vendored
Normal file
27
.github/workflows/release-new-action-version.yml
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
name: Release new action version
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [released]
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
TAG_NAME:
|
||||||
|
description: 'Tag name that the major tag will point to'
|
||||||
|
required: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update_tag:
|
||||||
|
name: Update the major tag to include the ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} changes
|
||||||
|
environment:
|
||||||
|
name: releaseNewActionVersion
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Update the ${{ env.TAG_NAME }} tag
|
||||||
|
uses: actions/publish-action@v0.1.0
|
||||||
|
with:
|
||||||
|
source-tag: ${{ env.TAG_NAME }}
|
||||||
|
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
49
.github/workflows/versions.yml
vendored
49
.github/workflows/versions.yml
vendored
|
@ -2,7 +2,7 @@ name: Validate 'setup-go'
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- main
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
@ -22,7 +22,7 @@ jobs:
|
||||||
go: [1.12, 1.13, 1.14]
|
go: [1.12, 1.13, 1.14]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: setup-go ${{ matrix.go }}
|
- name: setup-go ${{ matrix.go }}
|
||||||
uses: ./
|
uses: ./
|
||||||
|
@ -33,6 +33,23 @@ jobs:
|
||||||
run: __tests__/verify-go.sh ${{ matrix.go }}
|
run: __tests__/verify-go.sh ${{ matrix.go }}
|
||||||
shell: bash
|
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@v3
|
||||||
|
- 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:
|
setup-versions-from-manifest:
|
||||||
name: Setup ${{ matrix.go }} ${{ matrix.os }}
|
name: Setup ${{ matrix.go }} ${{ matrix.os }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
@ -43,13 +60,13 @@ jobs:
|
||||||
go: [1.12.16, 1.13.11, 1.14.3]
|
go: [1.12.16, 1.13.11, 1.14.3]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: setup-go ${{ matrix.go }}
|
- name: setup-go ${{ matrix.go }}
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
- name: verify go
|
- name: verify go
|
||||||
run: __tests__/verify-go.sh ${{ matrix.go }}
|
run: __tests__/verify-go.sh ${{ matrix.go }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
@ -61,14 +78,16 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
go: [1.7, 1.8.6]
|
go: [1.9, 1.8.6]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: setup-go ${{ matrix.go }}
|
|
||||||
uses: ./
|
- name: setup-go ${{ matrix.go }}
|
||||||
with:
|
uses: ./
|
||||||
go-version: ${{ matrix.go }}
|
with:
|
||||||
- name: verify go
|
go-version: ${{ matrix.go }}
|
||||||
run: __tests__/verify-go.sh ${{ matrix.go }}
|
|
||||||
shell: bash
|
- name: verify go
|
||||||
|
run: __tests__/verify-go.sh ${{ matrix.go }}
|
||||||
|
shell: bash
|
||||||
|
|
33
.github/workflows/workflow.yml
vendored
33
.github/workflows/workflow.yml
vendored
|
@ -2,7 +2,7 @@ name: build-test
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- main
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
@ -16,23 +16,24 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest]
|
operating-system: [ubuntu-latest, windows-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup node 12
|
- name: Setup node 16
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 12
|
node-version: 16
|
||||||
|
cache: npm
|
||||||
|
|
||||||
- name: npm install
|
- name: npm ci
|
||||||
run: npm install
|
run: npm ci
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: npm run format-check
|
run: npm run format-check
|
||||||
|
|
||||||
- name: npm test
|
- name: npm test
|
||||||
run: npm test
|
run: npm test
|
||||||
|
|
||||||
- name: audit packages
|
- name: audit packages
|
||||||
run: npm audit --audit-level=high
|
run: npm audit --audit-level=high
|
||||||
if: matrix.operating-system == 'ubuntu-latest'
|
if: matrix.operating-system == 'ubuntu-latest'
|
||||||
|
|
14
.licensed.yml
Normal file
14
.licensed.yml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
sources:
|
||||||
|
npm: true
|
||||||
|
|
||||||
|
allowed:
|
||||||
|
- apache-2.0
|
||||||
|
- bsd-2-clause
|
||||||
|
- bsd-3-clause
|
||||||
|
- isc
|
||||||
|
- mit
|
||||||
|
- cc0-1.0
|
||||||
|
- unlicense
|
||||||
|
|
||||||
|
reviewed:
|
||||||
|
npm:
|
20
.licenses/npm/@actions/core.dep.yml
generated
Normal file
20
.licenses/npm/@actions/core.dep.yml
generated
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
name: "@actions/core"
|
||||||
|
version: 1.6.0
|
||||||
|
type: npm
|
||||||
|
summary: Actions core lib
|
||||||
|
homepage: https://github.com/actions/toolkit/tree/main/packages/core
|
||||||
|
license: mit
|
||||||
|
licenses:
|
||||||
|
- sources: LICENSE.md
|
||||||
|
text: |-
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright 2019 GitHub
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
notices: []
|
30
.licenses/npm/@actions/exec.dep.yml
generated
Normal file
30
.licenses/npm/@actions/exec.dep.yml
generated
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
---
|
||||||
|
name: "@actions/exec"
|
||||||
|
version: 1.0.4
|
||||||
|
type: npm
|
||||||
|
summary: Actions exec lib
|
||||||
|
homepage: https://github.com/actions/toolkit/tree/master/packages/exec
|
||||||
|
license: mit
|
||||||
|
licenses:
|
||||||
|
- sources: Auto-generated MIT license text
|
||||||
|
text: |
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
notices: []
|
32
.licenses/npm/@actions/http-client-1.0.11.dep.yml
generated
Normal file
32
.licenses/npm/@actions/http-client-1.0.11.dep.yml
generated
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
name: "@actions/http-client"
|
||||||
|
version: 1.0.11
|
||||||
|
type: npm
|
||||||
|
summary: Actions Http Client
|
||||||
|
homepage: https://github.com/actions/http-client#readme
|
||||||
|
license: mit
|
||||||
|
licenses:
|
||||||
|
- sources: LICENSE
|
||||||
|
text: |
|
||||||
|
Actions Http Client for Node.js
|
||||||
|
|
||||||
|
Copyright (c) GitHub, Inc.
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||||
|
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||||
|
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
notices: []
|
32
.licenses/npm/@actions/http-client-1.0.8.dep.yml
generated
Normal file
32
.licenses/npm/@actions/http-client-1.0.8.dep.yml
generated
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
name: "@actions/http-client"
|
||||||
|
version: 1.0.8
|
||||||
|
type: npm
|
||||||
|
summary: Actions Http Client
|
||||||
|
homepage: https://github.com/actions/http-client#readme
|
||||||
|
license: mit
|
||||||
|
licenses:
|
||||||
|
- sources: LICENSE
|
||||||
|
text: |
|
||||||
|
Actions Http Client for Node.js
|
||||||
|
|
||||||
|
Copyright (c) GitHub, Inc.
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||||
|
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||||
|
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
notices: []
|
30
.licenses/npm/@actions/io.dep.yml
generated
Normal file
30
.licenses/npm/@actions/io.dep.yml
generated
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
---
|
||||||
|
name: "@actions/io"
|
||||||
|
version: 1.0.2
|
||||||
|
type: npm
|
||||||
|
summary: Actions io lib
|
||||||
|
homepage: https://github.com/actions/toolkit/tree/master/packages/io
|
||||||
|
license: mit
|
||||||
|
licenses:
|
||||||
|
- sources: Auto-generated MIT license text
|
||||||
|
text: |
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
notices: []
|
30
.licenses/npm/@actions/tool-cache.dep.yml
generated
Normal file
30
.licenses/npm/@actions/tool-cache.dep.yml
generated
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
---
|
||||||
|
name: "@actions/tool-cache"
|
||||||
|
version: 1.5.5
|
||||||
|
type: npm
|
||||||
|
summary: Actions tool-cache lib
|
||||||
|
homepage: https://github.com/actions/toolkit/tree/master/packages/tool-cache
|
||||||
|
license: mit
|
||||||
|
licenses:
|
||||||
|
- sources: Auto-generated MIT license text
|
||||||
|
text: |
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
notices: []
|
26
.licenses/npm/semver.dep.yml
generated
Normal file
26
.licenses/npm/semver.dep.yml
generated
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
name: semver
|
||||||
|
version: 6.3.0
|
||||||
|
type: npm
|
||||||
|
summary: The semantic version parser used by npm.
|
||||||
|
homepage: https://github.com/npm/node-semver#readme
|
||||||
|
license: isc
|
||||||
|
licenses:
|
||||||
|
- sources: LICENSE
|
||||||
|
text: |
|
||||||
|
The ISC License
|
||||||
|
|
||||||
|
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||||
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
notices: []
|
35
.licenses/npm/tunnel.dep.yml
generated
Normal file
35
.licenses/npm/tunnel.dep.yml
generated
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
---
|
||||||
|
name: tunnel
|
||||||
|
version: 0.0.6
|
||||||
|
type: npm
|
||||||
|
summary: Node HTTP/HTTPS Agents for tunneling proxies
|
||||||
|
homepage: https://github.com/koichik/node-tunnel/
|
||||||
|
license: mit
|
||||||
|
licenses:
|
||||||
|
- sources: LICENSE
|
||||||
|
text: |
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2012 Koichi Kobayashi
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
- sources: README.md
|
||||||
|
text: Licensed under the [MIT](https://github.com/koichik/node-tunnel/blob/master/LICENSE)
|
||||||
|
license.
|
||||||
|
notices: []
|
39
.licenses/npm/uuid.dep.yml
generated
Normal file
39
.licenses/npm/uuid.dep.yml
generated
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
---
|
||||||
|
name: uuid
|
||||||
|
version: 3.4.0
|
||||||
|
type: npm
|
||||||
|
summary: RFC4122 (v1, v4, and v5) UUIDs
|
||||||
|
homepage: https://github.com/uuidjs/uuid#readme
|
||||||
|
license: mit
|
||||||
|
licenses:
|
||||||
|
- sources: LICENSE.md
|
||||||
|
text: |
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2010-2016 Robert Kieffer and other contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
notices:
|
||||||
|
- sources: AUTHORS
|
||||||
|
text: |-
|
||||||
|
Robert Kieffer <robert@broofa.com>
|
||||||
|
Christoph Tavan <dev@tavan.de>
|
||||||
|
AJ ONeal <coolaj86@gmail.com>
|
||||||
|
Vincent Voyer <vincent@zeroload.net>
|
||||||
|
Roman Shtylman <shtylman@gmail.com>
|
1
CODEOWNERS
Normal file
1
CODEOWNERS
Normal file
|
@ -0,0 +1 @@
|
||||||
|
* @actions/actions-service
|
|
@ -55,7 +55,7 @@ a project may be further defined and clarified by project maintainers.
|
||||||
## Enforcement
|
## Enforcement
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
reported by contacting the project team at opensource@github.com. All
|
reported by contacting the project team at opensource+actions/setup-go@github.com. All
|
||||||
complaints will be reviewed and investigated and will result in a response that
|
complaints will be reviewed and investigated and will result in a response that
|
||||||
is deemed necessary and appropriate to the circumstances. The project team is
|
is deemed necessary and appropriate to the circumstances. The project team is
|
||||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||||
|
@ -73,4 +73,4 @@ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.ht
|
||||||
[homepage]: https://www.contributor-covenant.org
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|
||||||
For answers to common questions about this code of conduct, see
|
For answers to common questions about this code of conduct, see
|
||||||
https://www.contributor-covenant.org/faq
|
https://www.contributor-covenant.org/faq
|
127
README.md
127
README.md
|
@ -1,85 +1,136 @@
|
||||||
# setup-go
|
# setup-go
|
||||||
|
|
||||||
<p align="left">
|
[](https://github.com/actions/setup-go/actions/workflows/workflow.yml)
|
||||||
<a href="https://github.com/actions/setup-go/actions"><img alt="GitHub Actions status" src="https://github.com/actions/setup-go/workflows/build-test/badge.svg"></a>
|
[](https://github.com/actions/setup-go/actions/workflows/versions.yml)
|
||||||
|
|
||||||
<a href="https://github.com/actions/setup-go/actions"><img alt="versions status" src="https://github.com/actions/setup-go/workflows/go-versions/badge.svg"></a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
This action sets up a go environment for use in actions by:
|
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
|
- Optionally downloading and caching a version of Go by version and adding to `PATH`.
|
||||||
- registering problem matchers for error output
|
- Registering problem matchers for error output.
|
||||||
|
|
||||||
# V2
|
# V3
|
||||||
|
|
||||||
The V2 offers:
|
The V3 edition of the action offers:
|
||||||
- Adds GOBIN to the PATH
|
|
||||||
- Proxy Support
|
- Adds `GOBIN` to the `PATH`
|
||||||
- stable input
|
- Proxy support
|
||||||
- Bug Fixes (including issues around version matching and semver)
|
- Check latest version
|
||||||
|
- 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):
|
||||||
|
|
||||||
Matching by semver spec:
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '^1.13.1' # The Go version to download (if necessary) and use.
|
go-version: '^1.13.1' # The Go version to download (if necessary) and use.
|
||||||
- run: go version
|
- run: go version
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '>=1.17.0'
|
||||||
|
- run: go version
|
||||||
```
|
```
|
||||||
|
|
||||||
Matching an unstable pre-release:
|
Matching an unstable pre-release:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
stable: 'false'
|
go-version: '1.18.0-rc.1' # The Go version to download (if necessary) and use.
|
||||||
go-version: '1.14.0-rc1' # The Go version to download (if necessary) and use.
|
- run: go version
|
||||||
- run: go version
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '1.16.0-beta.1' # The Go version to download (if necessary) and use.
|
||||||
|
- run: go version
|
||||||
```
|
```
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
See [action.yml](action.yml)
|
See [action.yml](action.yml)
|
||||||
|
|
||||||
Basic:
|
## Basic
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v1
|
- uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '1.9.3' # The Go version to download (if necessary) and use.
|
go-version: '1.16.1' # The Go version to download (if necessary) and use.
|
||||||
- run: go run hello.go
|
- run: go run hello.go
|
||||||
```
|
```
|
||||||
|
|
||||||
Matrix Testing:
|
|
||||||
|
## Check latest version
|
||||||
|
|
||||||
|
The `check-latest` flag defaults to `false`. Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific Go version is always used.
|
||||||
|
|
||||||
|
If `check-latest` is set to `true`, the action first checks if the cached version is the latest one. If the locally cached version is not the most up-to-date, a Go version will then be downloaded. Set `check-latest` to `true` if you want the most up-to-date Go version to always be used.
|
||||||
|
|
||||||
|
> Setting `check-latest` to `true` has performance implications as downloading Go versions is slower than using cached versions.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '1.14'
|
||||||
|
check-latest: true
|
||||||
|
- run: go run hello.go
|
||||||
|
```
|
||||||
|
|
||||||
|
## Matrix testing
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-16.04
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go: [ '1.13', '1.12' ]
|
go: [ '1.14', '1.13' ]
|
||||||
name: Go ${{ matrix.go }} sample
|
name: Go ${{ matrix.go }} sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Setup go
|
- name: Setup go
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
- run: go run hello.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.
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||||
|
|
||||||
# Contributions
|
# Contributions
|
||||||
|
|
||||||
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
||||||
|
|
||||||
## Code of Conduct
|
## Code of Conduct
|
||||||
|
|
||||||
:wave: Be nice. See [our code of conduct](CONDUCT)
|
:wave: Be nice. See [our code of conduct](CONDUCT)
|
||||||
|
|
|
@ -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",
|
"version": "1.12.17",
|
||||||
"stable": true,
|
"stable": true,
|
||||||
|
|
|
@ -19,6 +19,8 @@ describe('setup-go', () => {
|
||||||
let os = {} as any;
|
let os = {} as any;
|
||||||
|
|
||||||
let inSpy: jest.SpyInstance;
|
let inSpy: jest.SpyInstance;
|
||||||
|
let getBooleanInputSpy: jest.SpyInstance;
|
||||||
|
let exportVarSpy: jest.SpyInstance;
|
||||||
let findSpy: jest.SpyInstance;
|
let findSpy: jest.SpyInstance;
|
||||||
let cnSpy: jest.SpyInstance;
|
let cnSpy: jest.SpyInstance;
|
||||||
let logSpy: jest.SpyInstance;
|
let logSpy: jest.SpyInstance;
|
||||||
|
@ -26,7 +28,7 @@ describe('setup-go', () => {
|
||||||
let platSpy: jest.SpyInstance;
|
let platSpy: jest.SpyInstance;
|
||||||
let archSpy: jest.SpyInstance;
|
let archSpy: jest.SpyInstance;
|
||||||
let dlSpy: jest.SpyInstance;
|
let dlSpy: jest.SpyInstance;
|
||||||
let exSpy: jest.SpyInstance;
|
let extractTarSpy: jest.SpyInstance;
|
||||||
let cacheSpy: jest.SpyInstance;
|
let cacheSpy: jest.SpyInstance;
|
||||||
let dbgSpy: jest.SpyInstance;
|
let dbgSpy: jest.SpyInstance;
|
||||||
let whichSpy: jest.SpyInstance;
|
let whichSpy: jest.SpyInstance;
|
||||||
|
@ -36,11 +38,20 @@ describe('setup-go', () => {
|
||||||
let execSpy: jest.SpyInstance;
|
let execSpy: jest.SpyInstance;
|
||||||
let getManifestSpy: jest.SpyInstance;
|
let getManifestSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
process.env['GITHUB_ENV'] = ''; // Stub out Environment file functionality so we can verify it writes to standard out (toolkit is backwards compatible)
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
process.env['GITHUB_PATH'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
||||||
|
|
||||||
// @actions/core
|
// @actions/core
|
||||||
inputs = {};
|
inputs = {};
|
||||||
inSpy = jest.spyOn(core, 'getInput');
|
inSpy = jest.spyOn(core, 'getInput');
|
||||||
inSpy.mockImplementation(name => inputs[name]);
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
|
||||||
|
getBooleanInputSpy.mockImplementation(name => inputs[name]);
|
||||||
|
exportVarSpy = jest.spyOn(core, 'exportVariable');
|
||||||
|
|
||||||
// node
|
// node
|
||||||
os = {};
|
os = {};
|
||||||
|
@ -53,7 +64,7 @@ describe('setup-go', () => {
|
||||||
// @actions/tool-cache
|
// @actions/tool-cache
|
||||||
findSpy = jest.spyOn(tc, 'find');
|
findSpy = jest.spyOn(tc, 'find');
|
||||||
dlSpy = jest.spyOn(tc, 'downloadTool');
|
dlSpy = jest.spyOn(tc, 'downloadTool');
|
||||||
exSpy = jest.spyOn(tc, 'extractTar');
|
extractTarSpy = jest.spyOn(tc, 'extractTar');
|
||||||
cacheSpy = jest.spyOn(tc, 'cacheDir');
|
cacheSpy = jest.spyOn(tc, 'cacheDir');
|
||||||
getSpy = jest.spyOn(im, 'getVersionsDist');
|
getSpy = jest.spyOn(im, 'getVersionsDist');
|
||||||
getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
|
getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
|
||||||
|
@ -78,7 +89,7 @@ describe('setup-go', () => {
|
||||||
});
|
});
|
||||||
logSpy.mockImplementation(line => {
|
logSpy.mockImplementation(line => {
|
||||||
// uncomment to debug
|
// uncomment to debug
|
||||||
// process.stderr.write('log:' + line + '\n');
|
process.stderr.write('log:' + line + '\n');
|
||||||
});
|
});
|
||||||
dbgSpy.mockImplementation(msg => {
|
dbgSpy.mockImplementation(msg => {
|
||||||
// uncomment to see debug output
|
// uncomment to see debug output
|
||||||
|
@ -92,7 +103,14 @@ describe('setup-go', () => {
|
||||||
//jest.restoreAllMocks();
|
//jest.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {}, 100000);
|
afterAll(async () => {
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
it('can extract the major.minor.patch version from a given Go version string', async () => {
|
||||||
|
const goVersionOutput = 'go version go1.16.6 darwin/amd64';
|
||||||
|
expect(main.parseGoVersion(goVersionOutput)).toBe('1.16.6');
|
||||||
|
});
|
||||||
|
|
||||||
it('can find 1.9.7 from manifest on osx', async () => {
|
it('can find 1.9.7 from manifest on osx', async () => {
|
||||||
os.platform = 'darwin';
|
os.platform = 'darwin';
|
||||||
|
@ -138,7 +156,7 @@ describe('setup-go', () => {
|
||||||
os.arch = 'x64';
|
os.arch = 'x64';
|
||||||
|
|
||||||
// spec: 1.13.0 => 1.13
|
// spec: 1.13.0 => 1.13
|
||||||
let match: im.IGoVersion | undefined = await im.findMatch('1.13.0', true);
|
let match: im.IGoVersion | undefined = await im.findMatch('1.13.0');
|
||||||
expect(match).toBeDefined();
|
expect(match).toBeDefined();
|
||||||
let version: string = match ? match.version : '';
|
let version: string = match ? match.version : '';
|
||||||
expect(version).toBe('go1.13');
|
expect(version).toBe('go1.13');
|
||||||
|
@ -151,7 +169,7 @@ describe('setup-go', () => {
|
||||||
os.arch = 'x64';
|
os.arch = 'x64';
|
||||||
|
|
||||||
// spec: 1.13 => 1.13.7 (latest)
|
// spec: 1.13 => 1.13.7 (latest)
|
||||||
let match: im.IGoVersion | undefined = await im.findMatch('1.13', true);
|
let match: im.IGoVersion | undefined = await im.findMatch('1.13');
|
||||||
expect(match).toBeDefined();
|
expect(match).toBeDefined();
|
||||||
let version: string = match ? match.version : '';
|
let version: string = match ? match.version : '';
|
||||||
expect(version).toBe('go1.13.7');
|
expect(version).toBe('go1.13.7');
|
||||||
|
@ -164,7 +182,7 @@ describe('setup-go', () => {
|
||||||
os.arch = 'x64';
|
os.arch = 'x64';
|
||||||
|
|
||||||
// spec: ^1.13.6 => 1.13.7
|
// spec: ^1.13.6 => 1.13.7
|
||||||
let match: im.IGoVersion | undefined = await im.findMatch('^1.13.6', true);
|
let match: im.IGoVersion | undefined = await im.findMatch('^1.13.6');
|
||||||
expect(match).toBeDefined();
|
expect(match).toBeDefined();
|
||||||
let version: string = match ? match.version : '';
|
let version: string = match ? match.version : '';
|
||||||
expect(version).toBe('go1.13.7');
|
expect(version).toBe('go1.13.7');
|
||||||
|
@ -177,7 +195,7 @@ describe('setup-go', () => {
|
||||||
os.arch = 'x32';
|
os.arch = 'x32';
|
||||||
|
|
||||||
// spec: 1 => 1.13.7 (latest)
|
// spec: 1 => 1.13.7 (latest)
|
||||||
let match: im.IGoVersion | undefined = await im.findMatch('1', true);
|
let match: im.IGoVersion | undefined = await im.findMatch('1');
|
||||||
expect(match).toBeDefined();
|
expect(match).toBeDefined();
|
||||||
let version: string = match ? match.version : '';
|
let version: string = match ? match.version : '';
|
||||||
expect(version).toBe('go1.13.7');
|
expect(version).toBe('go1.13.7');
|
||||||
|
@ -190,10 +208,7 @@ describe('setup-go', () => {
|
||||||
os.arch = 'x64';
|
os.arch = 'x64';
|
||||||
|
|
||||||
// spec: 1.14, stable=false => go1.14rc1
|
// spec: 1.14, stable=false => go1.14rc1
|
||||||
let match: im.IGoVersion | undefined = await im.findMatch(
|
let match: im.IGoVersion | undefined = await im.findMatch('1.14.0-rc.1');
|
||||||
'1.14.0-rc1',
|
|
||||||
false
|
|
||||||
);
|
|
||||||
expect(match).toBeDefined();
|
expect(match).toBeDefined();
|
||||||
let version: string = match ? match.version : '';
|
let version: string = match ? match.version : '';
|
||||||
expect(version).toBe('go1.14rc1');
|
expect(version).toBe('go1.14rc1');
|
||||||
|
@ -209,7 +224,7 @@ describe('setup-go', () => {
|
||||||
findSpy.mockImplementation(() => toolPath);
|
findSpy.mockImplementation(() => toolPath);
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(`Setup go stable version spec 1.13.0`);
|
expect(logSpy).toHaveBeenCalledWith(`Setup go version spec 1.13.0`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('evaluates to stable with no input', async () => {
|
it('evaluates to stable with no input', async () => {
|
||||||
|
@ -221,7 +236,41 @@ describe('setup-go', () => {
|
||||||
findSpy.mockImplementation(() => toolPath);
|
findSpy.mockImplementation(() => toolPath);
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(`Setup go stable version spec 1.13.0`);
|
expect(logSpy).toHaveBeenCalledWith(`Setup go version spec 1.13.0`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not export any variables for Go versions >=1.9', async () => {
|
||||||
|
inputs['go-version'] = '1.13.0';
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
let toolPath = path.normalize('/cache/go/1.13.0/x64');
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
|
||||||
|
let vars: {[key: string]: string} = {};
|
||||||
|
exportVarSpy.mockImplementation((name: string, val: string) => {
|
||||||
|
vars[name] = val;
|
||||||
|
});
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
expect(vars).toStrictEqual({});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('exports GOROOT for Go versions <1.9', async () => {
|
||||||
|
inputs['go-version'] = '1.8';
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
let toolPath = path.normalize('/cache/go/1.8.0/x64');
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
|
||||||
|
let vars: {[key: string]: string} = {};
|
||||||
|
exportVarSpy.mockImplementation((name: string, val: string) => {
|
||||||
|
vars[name] = val;
|
||||||
|
});
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
expect(vars).toStrictEqual({
|
||||||
|
GOROOT: toolPath
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('finds a version of go already in the cache', async () => {
|
it('finds a version of go already in the cache', async () => {
|
||||||
|
@ -265,14 +314,14 @@ describe('setup-go', () => {
|
||||||
findSpy.mockImplementation(() => '');
|
findSpy.mockImplementation(() => '');
|
||||||
dlSpy.mockImplementation(() => '/some/temp/path');
|
dlSpy.mockImplementation(() => '/some/temp/path');
|
||||||
let toolPath = path.normalize('/cache/go/1.13.0/x64');
|
let toolPath = path.normalize('/cache/go/1.13.0/x64');
|
||||||
exSpy.mockImplementation(() => '/some/other/temp/path');
|
extractTarSpy.mockImplementation(() => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(() => toolPath);
|
cacheSpy.mockImplementation(() => toolPath);
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
let expPath = path.join(toolPath, 'bin');
|
let expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
expect(dlSpy).toHaveBeenCalled();
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
expect(exSpy).toHaveBeenCalled();
|
expect(extractTarSpy).toHaveBeenCalled();
|
||||||
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -294,7 +343,6 @@ describe('setup-go', () => {
|
||||||
os.platform = 'linux';
|
os.platform = 'linux';
|
||||||
os.arch = 'x64';
|
os.arch = 'x64';
|
||||||
|
|
||||||
// a version which is in the manifest
|
|
||||||
let versionSpec = '1.12.16';
|
let versionSpec = '1.12.16';
|
||||||
|
|
||||||
inputs['go-version'] = versionSpec;
|
inputs['go-version'] = versionSpec;
|
||||||
|
@ -308,7 +356,7 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
let toolPath = path.normalize('/cache/go/1.12.16/x64');
|
let toolPath = path.normalize('/cache/go/1.12.16/x64');
|
||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
@ -316,7 +364,7 @@ describe('setup-go', () => {
|
||||||
let expPath = path.join(toolPath, 'bin');
|
let expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
expect(dlSpy).toHaveBeenCalled();
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
expect(exSpy).toHaveBeenCalled();
|
expect(extractTarSpy).toHaveBeenCalled();
|
||||||
expect(logSpy).not.toHaveBeenCalledWith(
|
expect(logSpy).not.toHaveBeenCalledWith(
|
||||||
'Not found in manifest. Falling back to download directly from Go'
|
'Not found in manifest. Falling back to download directly from Go'
|
||||||
);
|
);
|
||||||
|
@ -332,7 +380,6 @@ describe('setup-go', () => {
|
||||||
os.platform = 'linux';
|
os.platform = 'linux';
|
||||||
os.arch = 'x64';
|
os.arch = 'x64';
|
||||||
|
|
||||||
// a version which is in the manifest
|
|
||||||
let versionSpec = '1.12';
|
let versionSpec = '1.12';
|
||||||
|
|
||||||
inputs['go-version'] = versionSpec;
|
inputs['go-version'] = versionSpec;
|
||||||
|
@ -346,7 +393,7 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
let toolPath = path.normalize('/cache/go/1.12.17/x64');
|
let toolPath = path.normalize('/cache/go/1.12.17/x64');
|
||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
@ -354,7 +401,7 @@ describe('setup-go', () => {
|
||||||
let expPath = path.join(toolPath, 'bin');
|
let expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
expect(dlSpy).toHaveBeenCalled();
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
expect(exSpy).toHaveBeenCalled();
|
expect(extractTarSpy).toHaveBeenCalled();
|
||||||
expect(logSpy).not.toHaveBeenCalledWith(
|
expect(logSpy).not.toHaveBeenCalledWith(
|
||||||
'Not found in manifest. Falling back to download directly from Go'
|
'Not found in manifest. Falling back to download directly from Go'
|
||||||
);
|
);
|
||||||
|
@ -370,7 +417,6 @@ describe('setup-go', () => {
|
||||||
os.platform = 'linux';
|
os.platform = 'linux';
|
||||||
os.arch = 'x64';
|
os.arch = 'x64';
|
||||||
|
|
||||||
// a version which is not in the manifest but is in node dist
|
|
||||||
let versionSpec = '1.12.14';
|
let versionSpec = '1.12.14';
|
||||||
|
|
||||||
inputs['go-version'] = versionSpec;
|
inputs['go-version'] = versionSpec;
|
||||||
|
@ -384,18 +430,18 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
let toolPath = path.normalize('/cache/go/1.12.14/x64');
|
let toolPath = path.normalize('/cache/go/1.12.14/x64');
|
||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
let expPath = path.join(toolPath, 'bin');
|
let expPath = path.join(toolPath, 'bin');
|
||||||
expect(logSpy).toHaveBeenCalledWith('Setup go stable version spec 1.12.14');
|
expect(logSpy).toHaveBeenCalledWith('Setup go version spec 1.12.14');
|
||||||
expect(findSpy).toHaveBeenCalled();
|
expect(findSpy).toHaveBeenCalled();
|
||||||
expect(logSpy).toHaveBeenCalledWith('Attempting to download 1.12.14...');
|
expect(logSpy).toHaveBeenCalledWith('Attempting to download 1.12.14...');
|
||||||
expect(dlSpy).toHaveBeenCalled();
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
expect(logSpy).toHaveBeenCalledWith('matching 1.12.14...');
|
expect(logSpy).toHaveBeenCalledWith('matching 1.12.14...');
|
||||||
expect(exSpy).toHaveBeenCalled();
|
expect(extractTarSpy).toHaveBeenCalled();
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
'Not found in manifest. Falling back to download directly from Go'
|
'Not found in manifest. Falling back to download directly from Go'
|
||||||
);
|
);
|
||||||
|
@ -492,6 +538,16 @@ describe('setup-go', () => {
|
||||||
expect(annotation.message).toBe('undefined: fmt.Printl');
|
expect(annotation.message).toBe('undefined: fmt.Printl');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('matches on unix path down the tree', async () => {
|
||||||
|
let line = 'foo/main.go:13:2: undefined: fmt.Printl';
|
||||||
|
let annotation = testMatch(line);
|
||||||
|
expect(annotation).toBeDefined();
|
||||||
|
expect(annotation.line).toBe(13);
|
||||||
|
expect(annotation.column).toBe(2);
|
||||||
|
expect(annotation.file).toBe('foo/main.go');
|
||||||
|
expect(annotation.message).toBe('undefined: fmt.Printl');
|
||||||
|
});
|
||||||
|
|
||||||
it('matches on rooted unix path', async () => {
|
it('matches on rooted unix path', async () => {
|
||||||
let line = '/assert.go:4:1: missing return at end of function';
|
let line = '/assert.go:4:1: missing return at end of function';
|
||||||
let annotation = testMatch(line);
|
let annotation = testMatch(line);
|
||||||
|
@ -544,11 +600,11 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
// 1.13.1 => 1.13.1
|
// 1.13.1 => 1.13.1
|
||||||
// 1.13 => 1.13.0
|
// 1.13 => 1.13.0
|
||||||
// 1.10beta1 => 1.10.0-beta1, 1.10rc1 => 1.10.0-rc1
|
// 1.10beta1 => 1.10.0-beta.1, 1.10rc1 => 1.10.0-rc.1
|
||||||
// 1.8.5beta1 => 1.8.5-beta1, 1.8.5rc1 => 1.8.5-rc1
|
// 1.8.5beta1 => 1.8.5-beta.1, 1.8.5rc1 => 1.8.5-rc.1
|
||||||
it('converts prerelease versions', async () => {
|
it('converts prerelease versions', async () => {
|
||||||
expect(im.makeSemver('1.10beta1')).toBe('1.10.0-beta1');
|
expect(im.makeSemver('1.10beta1')).toBe('1.10.0-beta.1');
|
||||||
expect(im.makeSemver('1.10rc1')).toBe('1.10.0-rc1');
|
expect(im.makeSemver('1.10rc1')).toBe('1.10.0-rc.1');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('converts dot zero versions', async () => {
|
it('converts dot zero versions', async () => {
|
||||||
|
@ -559,6 +615,168 @@ describe('setup-go', () => {
|
||||||
expect(im.makeSemver('1.13.1')).toBe('1.13.1');
|
expect(im.makeSemver('1.13.1')).toBe('1.13.1');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('check-latest flag', () => {
|
||||||
|
it("use local version and don't check manifest if check-latest is not specified", async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
inputs['go-version'] = '1.16';
|
||||||
|
inputs['check-latest'] = false;
|
||||||
|
|
||||||
|
const toolPath = path.normalize('/cache/go/1.16.1/x64');
|
||||||
|
findSpy.mockReturnValue(toolPath);
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
expect(logSpy).not.toHaveBeenCalledWith(
|
||||||
|
'Attempting to resolve the latest version from the manifest...'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('check latest version and resolve it from local cache', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
inputs['go-version'] = '1.16';
|
||||||
|
inputs['check-latest'] = true;
|
||||||
|
|
||||||
|
const toolPath = path.normalize('/cache/go/1.16.1/x64');
|
||||||
|
findSpy.mockReturnValue(toolPath);
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Setup go version spec 1.16');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('check latest version and install it from manifest', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
const versionSpec = '1.17';
|
||||||
|
const patchVersion = '1.17.6';
|
||||||
|
inputs['go-version'] = versionSpec;
|
||||||
|
inputs['stable'] = 'true';
|
||||||
|
inputs['check-latest'] = true;
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
const toolPath = path.normalize('/cache/go/1.17.5/x64');
|
||||||
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
const expectedUrl =
|
||||||
|
'https://github.com/actions/go-versions/releases/download/1.17.6-1668090892/go-1.17.6-darwin-x64.tar.gz';
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Setup go version spec ${versionSpec}`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Attempting to resolve the latest version from the manifest...'
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Resolved as '${patchVersion}'`);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Attempting to download ${patchVersion}...`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Extracting Go...');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Added go to the path');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Successfully setup go version ${versionSpec}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fallback to dist if version is not found in manifest', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
let versionSpec = '1.13';
|
||||||
|
|
||||||
|
inputs['go-version'] = versionSpec;
|
||||||
|
inputs['check-latest'] = true;
|
||||||
|
inputs['always-auth'] = false;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
let toolPath = path.normalize('/cache/go/1.13.7/x64');
|
||||||
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
let expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(extractTarSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Attempting to resolve the latest version from the manifest...'
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Failed to resolve version ${versionSpec} from manifest`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Attempting to download ${versionSpec}...`
|
||||||
|
);
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fallback to dist if manifest is not available', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
let versionSpec = '1.13';
|
||||||
|
|
||||||
|
process.env['GITHUB_PATH'] = '';
|
||||||
|
|
||||||
|
inputs['go-version'] = versionSpec;
|
||||||
|
inputs['check-latest'] = true;
|
||||||
|
inputs['always-auth'] = false;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
getManifestSpy.mockImplementation(() => {
|
||||||
|
throw new Error('Unable to download manifest');
|
||||||
|
});
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
let toolPath = path.normalize('/cache/go/1.13.7/x64');
|
||||||
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
let expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Failed to resolve version ${versionSpec} from manifest`
|
||||||
|
);
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(extractTarSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Attempting to resolve the latest version from the manifest...'
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Unable to resolve a version from the manifest...'
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Failed to resolve version ${versionSpec} from manifest`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Attempting to download ${versionSpec}...`
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('go-version-file', () => {
|
describe('go-version-file', () => {
|
||||||
it('reads version from go.mod', async () => {
|
it('reads version from go.mod', async () => {
|
||||||
inputs['go-version-file'] = 'go.mod';
|
inputs['go-version-file'] = 'go.mod';
|
||||||
|
|
13
action.yml
13
action.yml
|
@ -1,17 +1,20 @@
|
||||||
name: 'Setup Go environment'
|
name: 'Setup Go environment'
|
||||||
description: 'Setup a Go environment and add it to the PATH'
|
description: 'Setup a Go environment and add it to the PATH'
|
||||||
author: 'GitHub'
|
author: 'GitHub'
|
||||||
inputs:
|
inputs:
|
||||||
go-version:
|
go-version:
|
||||||
description: 'The Go version to download (if necessary) and use. Supports semver spec and ranges.'
|
description: 'The Go version to download (if necessary) and use. Supports semver spec and ranges.'
|
||||||
go-version-from-file:
|
go-version-from-file:
|
||||||
description: Path to the file with the Go version. go-version overwrites this.
|
description: Path to the file with the Go version. go-version overwrites this.
|
||||||
stable:
|
check-latest:
|
||||||
description: 'Whether to download only stable versions'
|
description: 'Set this option to true if you want the action to always check for the latest available version that satisfies the version spec'
|
||||||
default: 'true'
|
default: false
|
||||||
token:
|
token:
|
||||||
description: Used to pull node distributions from go-versions. Since there's a default, this is typically not supplied by the user.
|
description: Used to pull node distributions from go-versions. Since there's a default, this is typically not supplied by the user.
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
|
outputs:
|
||||||
|
go-version:
|
||||||
|
description: 'The installed Go version. Useful when given a version range as input.'
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node16'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|
1129
dist/index.js
vendored
1129
dist/index.js
vendored
File diff suppressed because it is too large
Load diff
69
docs/adrs/0000-caching-dependencies.md
Normal file
69
docs/adrs/0000-caching-dependencies.md
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
# 0. Caching dependencies
|
||||||
|
Date: 2022-04-13
|
||||||
|
|
||||||
|
Status: Accepted
|
||||||
|
|
||||||
|
# Context
|
||||||
|
`actions/setup-go` is the one of the most popular action related to Golang in GitHub Actions. Many customers use it in conjunction with [actions/cache](https://github.com/actions/cache) to speed up dependency installation process.
|
||||||
|
See more examples on proper usage in [actions/cache documentation](https://github.com/actions/cache/blob/main/examples.md#go---modules).
|
||||||
|
|
||||||
|
# Goals & Anti-Goals
|
||||||
|
Integration of caching functionality into `actions/setup-go` action will bring the following benefits for action users:
|
||||||
|
- Decrease the entry threshold for using the cache for Go dependencies and simplify initial configuration
|
||||||
|
- Simplify YAML pipelines because there will be no need for additional steps to enable caching
|
||||||
|
- More users will use cache for Go so more customers will have fast builds!
|
||||||
|
|
||||||
|
We don't pursue the goal to provide wide customization of caching in scope of `actions/setup-go` action. The purpose of this integration is covering ~90% of basic use-cases. If user needs flexible customization, we should advice them to use `actions/cache` directly.
|
||||||
|
|
||||||
|
# Decision
|
||||||
|
- Add `cache` input parameter to `actions/setup-go`. For now, input will accept the following values:
|
||||||
|
- `true` - enable caching for go dependencies
|
||||||
|
- `false`- disable caching for go dependencies. This value will be set as default value
|
||||||
|
- Cache feature will be disabled by default to make sure that we don't break existing customers. We will consider enabling cache by default in next major releases
|
||||||
|
- Action will try to search a go.sum files in the repository and throw error in the scenario that it was not found
|
||||||
|
- The hash of found file will be used as cache key (the same approach like [actions/cache](https://github.com/actions/cache/blob/main/examples.md#go---modules) recommends)
|
||||||
|
- The following key cache will be used `${{ runner.os }}-go${{ go-version }}-${{ hashFiles('<go.sum-path>') }}`
|
||||||
|
- Action will cache global cache from the `go env GOMODCACHE` and `go env GOCACHE` commands.
|
||||||
|
- Add a `cache-dependency-path` input parameter to `actions/setup-go`. The new input will accept an array or regex of dependency files. The field will accept a path (relative to the repository root) to dependency files. If the provided path contains wildcards, the action will search all matching files and calculate a common hash like the ${{ hashFiles('**/go.sum') }} YAML construction does.
|
||||||
|
|
||||||
|
# Example of real use-cases
|
||||||
|
|
||||||
|
- With cache
|
||||||
|
|
||||||
|
```yml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '18'
|
||||||
|
cache: true
|
||||||
|
```
|
||||||
|
|
||||||
|
- With cache-dependency-path
|
||||||
|
|
||||||
|
```yml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '18'
|
||||||
|
cache: true
|
||||||
|
cache-dependency-path: **/go.sum
|
||||||
|
```
|
||||||
|
|
||||||
|
```yml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '18'
|
||||||
|
cache: true
|
||||||
|
cache-dependency-path: |
|
||||||
|
**/go.sum
|
||||||
|
**/go.mod
|
||||||
|
```
|
||||||
|
|
||||||
|
# Release process
|
||||||
|
|
||||||
|
As soon as functionality is implemented, we will release minor update of action. No need to bump major version since there are no breaking changes for existing users.
|
||||||
|
After that, we will update [starter-workflows](https://github.com/actions/starter-workflows/blob/main/ci/go.yml)
|
|
@ -4,7 +4,7 @@
|
||||||
"owner": "go",
|
"owner": "go",
|
||||||
"pattern": [
|
"pattern": [
|
||||||
{
|
{
|
||||||
"regexp": "^\\s*(\\.{0,2}[\\/\\\\].+\\.go):(?:(\\d+):(\\d+):)? (.*)",
|
"regexp": "^\\s*(.+\\.go):(?:(\\d+):(\\d+):)? (.*)",
|
||||||
"file": 1,
|
"file": 1,
|
||||||
"line": 2,
|
"line": 2,
|
||||||
"column": 3,
|
"column": 3,
|
||||||
|
@ -13,4 +13,4 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
16097
package-lock.json
generated
16097
package-lock.json
generated
File diff suppressed because it is too large
Load diff
12
package.json
12
package.json
|
@ -23,22 +23,22 @@
|
||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.3",
|
"@actions/core": "^1.6.0",
|
||||||
"@actions/http-client": "^1.0.6",
|
"@actions/http-client": "^1.0.6",
|
||||||
"@actions/io": "^1.0.2",
|
"@actions/io": "^1.0.2",
|
||||||
"@actions/tool-cache": "^1.5.5",
|
"@actions/tool-cache": "^1.5.5",
|
||||||
"semver": "^6.1.1"
|
"semver": "^6.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^24.0.13",
|
"@types/jest": "^27.0.2",
|
||||||
"@types/node": "^12.0.4",
|
"@types/node": "^16.11.25",
|
||||||
"@types/semver": "^6.0.0",
|
"@types/semver": "^6.0.0",
|
||||||
"@zeit/ncc": "^0.21.0",
|
"@zeit/ncc": "^0.21.0",
|
||||||
"jest": "^25.2.1",
|
"jest": "^27.2.5",
|
||||||
"jest-circus": "^24.7.1",
|
"jest-circus": "^27.2.5",
|
||||||
"nock": "^10.0.6",
|
"nock": "^10.0.6",
|
||||||
"prettier": "^1.17.1",
|
"prettier": "^1.17.1",
|
||||||
"ts-jest": "^24.0.2",
|
"ts-jest": "^27.0.5",
|
||||||
"typescript": "^3.8.3"
|
"typescript": "^3.8.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,27 @@ export interface IGoVersionInfo {
|
||||||
|
|
||||||
export async function getGo(
|
export async function getGo(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
stable: boolean,
|
checkLatest: boolean,
|
||||||
auth: string | undefined
|
auth: string | undefined
|
||||||
) {
|
) {
|
||||||
let osPlat: string = os.platform();
|
let osPlat: string = os.platform();
|
||||||
let osArch: string = os.arch();
|
let osArch: string = os.arch();
|
||||||
|
|
||||||
|
if (checkLatest) {
|
||||||
|
core.info('Attempting to resolve the latest version from the manifest...');
|
||||||
|
const resolvedVersion = await resolveVersionFromManifest(
|
||||||
|
versionSpec,
|
||||||
|
true,
|
||||||
|
auth
|
||||||
|
);
|
||||||
|
if (resolvedVersion) {
|
||||||
|
versionSpec = resolvedVersion;
|
||||||
|
core.info(`Resolved as '${versionSpec}'`);
|
||||||
|
} else {
|
||||||
|
core.info(`Failed to resolve version ${versionSpec} from manifest`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check cache
|
// check cache
|
||||||
let toolPath: string;
|
let toolPath: string;
|
||||||
toolPath = tc.find('go', versionSpec);
|
toolPath = tc.find('go', versionSpec);
|
||||||
|
@ -52,7 +67,7 @@ export async function getGo(
|
||||||
// Try download from internal distribution (popular versions only)
|
// Try download from internal distribution (popular versions only)
|
||||||
//
|
//
|
||||||
try {
|
try {
|
||||||
info = await getInfoFromManifest(versionSpec, stable, auth);
|
info = await getInfoFromManifest(versionSpec, true, auth);
|
||||||
if (info) {
|
if (info) {
|
||||||
downloadPath = await installGoVersion(info, auth);
|
downloadPath = await installGoVersion(info, auth);
|
||||||
} else {
|
} else {
|
||||||
|
@ -79,7 +94,7 @@ export async function getGo(
|
||||||
// Download from storage.googleapis.com
|
// Download from storage.googleapis.com
|
||||||
//
|
//
|
||||||
if (!downloadPath) {
|
if (!downloadPath) {
|
||||||
info = await getInfoFromDist(versionSpec, stable);
|
info = await getInfoFromDist(versionSpec);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`
|
`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`
|
||||||
|
@ -97,6 +112,20 @@ export async function getGo(
|
||||||
return downloadPath;
|
return downloadPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function resolveVersionFromManifest(
|
||||||
|
versionSpec: string,
|
||||||
|
stable: boolean,
|
||||||
|
auth: string | undefined
|
||||||
|
): Promise<string | undefined> {
|
||||||
|
try {
|
||||||
|
const info = await getInfoFromManifest(versionSpec, stable, auth);
|
||||||
|
return info?.resolvedVersion;
|
||||||
|
} catch (err) {
|
||||||
|
core.info('Unable to resolve a version from the manifest...');
|
||||||
|
core.debug(err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function installGoVersion(
|
async function installGoVersion(
|
||||||
info: IGoVersionInfo,
|
info: IGoVersionInfo,
|
||||||
auth: string | undefined
|
auth: string | undefined
|
||||||
|
@ -122,10 +151,10 @@ async function installGoVersion(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function extractGoArchive(archivePath: string): Promise<string> {
|
export async function extractGoArchive(archivePath: string): Promise<string> {
|
||||||
const arch = os.arch();
|
const platform = os.platform();
|
||||||
let extPath: string;
|
let extPath: string;
|
||||||
|
|
||||||
if (arch === 'win32') {
|
if (platform === 'win32') {
|
||||||
extPath = await tc.extractZip(archivePath);
|
extPath = await tc.extractZip(archivePath);
|
||||||
} else {
|
} else {
|
||||||
extPath = await tc.extractTar(archivePath);
|
extPath = await tc.extractTar(archivePath);
|
||||||
|
@ -140,7 +169,12 @@ export async function getInfoFromManifest(
|
||||||
auth: string | undefined
|
auth: string | undefined
|
||||||
): Promise<IGoVersionInfo | null> {
|
): Promise<IGoVersionInfo | null> {
|
||||||
let info: IGoVersionInfo | null = null;
|
let info: IGoVersionInfo | null = null;
|
||||||
const releases = await tc.getManifestFromRepo('actions', 'go-versions', auth);
|
const releases = await tc.getManifestFromRepo(
|
||||||
|
'actions',
|
||||||
|
'go-versions',
|
||||||
|
auth,
|
||||||
|
'main'
|
||||||
|
);
|
||||||
core.info(`matching ${versionSpec}...`);
|
core.info(`matching ${versionSpec}...`);
|
||||||
const rel = await tc.findFromManifest(versionSpec, stable, releases);
|
const rel = await tc.findFromManifest(versionSpec, stable, releases);
|
||||||
|
|
||||||
|
@ -156,11 +190,10 @@ export async function getInfoFromManifest(
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getInfoFromDist(
|
async function getInfoFromDist(
|
||||||
versionSpec: string,
|
versionSpec: string
|
||||||
stable: boolean
|
|
||||||
): Promise<IGoVersionInfo | null> {
|
): Promise<IGoVersionInfo | null> {
|
||||||
let version: IGoVersion | undefined;
|
let version: IGoVersion | undefined;
|
||||||
version = await findMatch(versionSpec, stable);
|
version = await findMatch(versionSpec);
|
||||||
if (!version) {
|
if (!version) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -176,8 +209,7 @@ async function getInfoFromDist(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function findMatch(
|
export async function findMatch(
|
||||||
versionSpec: string,
|
versionSpec: string
|
||||||
stable: boolean
|
|
||||||
): Promise<IGoVersion | undefined> {
|
): Promise<IGoVersion | undefined> {
|
||||||
let archFilter = sys.getArch();
|
let archFilter = sys.getArch();
|
||||||
let platFilter = sys.getPlatform();
|
let platFilter = sys.getPlatform();
|
||||||
|
@ -198,18 +230,8 @@ export async function findMatch(
|
||||||
let candidate: IGoVersion = candidates[i];
|
let candidate: IGoVersion = candidates[i];
|
||||||
let version = makeSemver(candidate.version);
|
let version = makeSemver(candidate.version);
|
||||||
|
|
||||||
// 1.13.0 is advertised as 1.13 preventing being able to match exactly 1.13.0
|
|
||||||
// since a semver of 1.13 would match latest 1.13
|
|
||||||
let parts: string[] = version.split('.');
|
|
||||||
if (parts.length == 2) {
|
|
||||||
version = version + '.0';
|
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(`check ${version} satisfies ${versionSpec}`);
|
core.debug(`check ${version} satisfies ${versionSpec}`);
|
||||||
if (
|
if (semver.satisfies(version, versionSpec)) {
|
||||||
semver.satisfies(version, versionSpec) &&
|
|
||||||
(!stable || candidate.stable === stable)
|
|
||||||
) {
|
|
||||||
goFile = candidate.files.find(file => {
|
goFile = candidate.files.find(file => {
|
||||||
core.debug(
|
core.debug(
|
||||||
`${file.arch}===${archFilter} && ${file.os}===${platFilter}`
|
`${file.arch}===${archFilter} && ${file.os}===${platFilter}`
|
||||||
|
@ -249,22 +271,32 @@ export async function getVersionsDist(
|
||||||
// Convert the go version syntax into semver for semver matching
|
// Convert the go version syntax into semver for semver matching
|
||||||
// 1.13.1 => 1.13.1
|
// 1.13.1 => 1.13.1
|
||||||
// 1.13 => 1.13.0
|
// 1.13 => 1.13.0
|
||||||
// 1.10beta1 => 1.10.0-beta1, 1.10rc1 => 1.10.0-rc1
|
// 1.10beta1 => 1.10.0-beta.1, 1.10rc1 => 1.10.0-rc.1
|
||||||
// 1.8.5beta1 => 1.8.5-beta1, 1.8.5rc1 => 1.8.5-rc1
|
// 1.8.5beta1 => 1.8.5-beta.1, 1.8.5rc1 => 1.8.5-rc.1
|
||||||
export function makeSemver(version: string): string {
|
export function makeSemver(version: string): string {
|
||||||
version = version.replace('go', '');
|
version = version.replace('go', '');
|
||||||
version = version.replace('beta', '-beta').replace('rc', '-rc');
|
version = version.replace('beta', '-beta.').replace('rc', '-rc.');
|
||||||
let parts = version.split('-');
|
let parts = version.split('-');
|
||||||
|
|
||||||
let verPart: string = parts[0];
|
let semVersion = semver.coerce(parts[0])?.version;
|
||||||
let prereleasePart = parts.length > 1 ? `-${parts[1]}` : '';
|
if (!semVersion) {
|
||||||
|
throw new Error(
|
||||||
let verParts: string[] = verPart.split('.');
|
`The version: ${version} can't be changed to SemVer notation`
|
||||||
if (verParts.length == 2) {
|
);
|
||||||
verPart += '.0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${verPart}${prereleasePart}`;
|
if (!parts[1]) {
|
||||||
|
return semVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fullVersion = semver.valid(`${semVersion}-${parts[1]}`);
|
||||||
|
|
||||||
|
if (!fullVersion) {
|
||||||
|
throw new Error(
|
||||||
|
`The version: ${version} can't be changed to SemVer notation`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return fullVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseGoVersionFile(contents: string, isMod: boolean): string {
|
export function parseGoVersionFile(contents: string, isMod: boolean): string {
|
||||||
|
|
34
src/main.ts
34
src/main.ts
|
@ -1,6 +1,7 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import * as installer from './installer';
|
import * as installer from './installer';
|
||||||
|
import * as semver from 'semver';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import cp from 'child_process';
|
import cp from 'child_process';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
@ -14,22 +15,25 @@ export async function run() {
|
||||||
//
|
//
|
||||||
const versionSpec = resolveVersionInput();
|
const versionSpec = resolveVersionInput();
|
||||||
|
|
||||||
// stable will be true unless false is the exact input
|
core.info(`Setup go version spec ${versionSpec}`);
|
||||||
// since getting unstable versions should be explicit
|
|
||||||
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
|
||||||
|
|
||||||
core.info(`Setup go ${stable ? 'stable' : ''} version spec ${versionSpec}`);
|
|
||||||
|
|
||||||
if (versionSpec) {
|
if (versionSpec) {
|
||||||
let token = core.getInput('token');
|
let token = core.getInput('token');
|
||||||
let auth = !token || isGhes() ? undefined : `token ${token}`;
|
let auth = !token || isGhes() ? undefined : `token ${token}`;
|
||||||
|
|
||||||
const installDir = await installer.getGo(versionSpec, stable, auth);
|
const checkLatest = core.getBooleanInput('check-latest');
|
||||||
|
const installDir = await installer.getGo(versionSpec, checkLatest, auth);
|
||||||
|
|
||||||
core.exportVariable('GOROOT', installDir);
|
|
||||||
core.addPath(path.join(installDir, 'bin'));
|
core.addPath(path.join(installDir, 'bin'));
|
||||||
core.info('Added go to the path');
|
core.info('Added go to the path');
|
||||||
|
|
||||||
|
const version = installer.makeSemver(versionSpec);
|
||||||
|
// Go versions less than 1.9 require GOROOT to be set
|
||||||
|
if (semver.lt(version, '1.9.0')) {
|
||||||
|
core.info('Setting GOROOT for Go version < 1.9');
|
||||||
|
core.exportVariable('GOROOT', installDir);
|
||||||
|
}
|
||||||
|
|
||||||
let added = await addBinToPath();
|
let added = await addBinToPath();
|
||||||
core.debug(`add bin ${added}`);
|
core.debug(`add bin ${added}`);
|
||||||
core.info(`Successfully setup go version ${versionSpec}`);
|
core.info(`Successfully setup go version ${versionSpec}`);
|
||||||
|
@ -44,6 +48,8 @@ export async function run() {
|
||||||
let goVersion = (cp.execSync(`${goPath} version`) || '').toString();
|
let goVersion = (cp.execSync(`${goPath} version`) || '').toString();
|
||||||
core.info(goVersion);
|
core.info(goVersion);
|
||||||
|
|
||||||
|
core.setOutput('go-version', parseGoVersion(goVersion));
|
||||||
|
|
||||||
core.startGroup('go env');
|
core.startGroup('go env');
|
||||||
let goEnv = (cp.execSync(`${goPath} env`) || '').toString();
|
let goEnv = (cp.execSync(`${goPath} env`) || '').toString();
|
||||||
core.info(goEnv);
|
core.info(goEnv);
|
||||||
|
@ -63,19 +69,19 @@ export async function addBinToPath(): Promise<boolean> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let buf = cp.execSync('go env GOPATH');
|
let buf = cp.execSync('go env GOPATH');
|
||||||
if (buf) {
|
if (buf.length > 1) {
|
||||||
let gp = buf.toString().trim();
|
let gp = buf.toString().trim();
|
||||||
core.debug(`go env GOPATH :${gp}:`);
|
core.debug(`go env GOPATH :${gp}:`);
|
||||||
if (!fs.existsSync(gp)) {
|
if (!fs.existsSync(gp)) {
|
||||||
// some of the hosted images have go install but not profile dir
|
// some of the hosted images have go install but not profile dir
|
||||||
core.debug(`creating ${gp}`);
|
core.debug(`creating ${gp}`);
|
||||||
io.mkdirP(gp);
|
await io.mkdirP(gp);
|
||||||
}
|
}
|
||||||
|
|
||||||
let bp = path.join(gp, 'bin');
|
let bp = path.join(gp, 'bin');
|
||||||
if (!fs.existsSync(bp)) {
|
if (!fs.existsSync(bp)) {
|
||||||
core.debug(`creating ${bp}`);
|
core.debug(`creating ${bp}`);
|
||||||
io.mkdirP(bp);
|
await io.mkdirP(bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
core.addPath(bp);
|
core.addPath(bp);
|
||||||
|
@ -91,6 +97,14 @@ function isGhes(): boolean {
|
||||||
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function parseGoVersion(versionString: string): string {
|
||||||
|
// get the installed version as an Action output
|
||||||
|
// based on go/src/cmd/go/internal/version/version.go:
|
||||||
|
// fmt.Printf("go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
||||||
|
// expecting go<version> for runtime.Version()
|
||||||
|
return versionString.split(' ')[2].slice('go'.length);
|
||||||
|
}
|
||||||
|
|
||||||
function resolveVersionInput(): string {
|
function resolveVersionInput(): string {
|
||||||
let version = core.getInput('go-version');
|
let version = core.getInput('go-version');
|
||||||
const versionFilePath = core.getInput('go-version-file');
|
const versionFilePath = core.getInput('go-version-file');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
let os = require('os');
|
const os = require('os');
|
||||||
|
|
||||||
export function getPlatform(): string {
|
export function getPlatform(): string {
|
||||||
// darwin and linux match already
|
// darwin and linux match already
|
||||||
|
|
|
@ -4,9 +4,6 @@
|
||||||
// "incremental": true, /* Enable incremental compilation */
|
// "incremental": true, /* Enable incremental compilation */
|
||||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||||
"lib": [
|
|
||||||
"es6"
|
|
||||||
],
|
|
||||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||||
// "checkJs": true, /* Report errors in .js files. */
|
// "checkJs": true, /* Report errors in .js files. */
|
||||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||||
|
@ -48,7 +45,8 @@
|
||||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||||
// "types": [], /* Type declaration files to be included in compilation. */
|
// "types": [], /* Type declaration files to be included in compilation. */
|
||||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||||
|
"sourceMap": true,
|
||||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue