Compare commits
	
		
			51 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 5a083d0e9a | ||
|  | 1d82324e53 | ||
|  | f111f3307d | ||
|  | 3d10edb4c2 | ||
|  | 43e13893cf | ||
|  | f81f022188 | ||
|  | 3041bf56c9 | ||
|  | 41dfa10bad | ||
|  | 941977282c | ||
|  | d60b41a563 | ||
|  | e09f57f6a9 | ||
|  | df1a11710e | ||
|  | 49582f6476 | ||
|  | b26d40294f | ||
|  | 0a12ed9d6a | ||
|  | 4ab57d7ea2 | ||
|  | cdcb360436 | ||
|  | 99176a8f9a | ||
|  | be1aa1186e | ||
|  | 6c1fd22b67 | ||
|  | 0c52d547c9 | ||
|  | bfd2fb341f | ||
|  | 3d65fa57fc | ||
|  | 8a505c9cf2 | ||
|  | 883490dfd0 | ||
|  | d45ebba0ce | ||
|  | 317c6617fa | ||
|  | f90673ad64 | ||
|  | 8018234347 | ||
|  | d085b4fe57 | ||
|  | 48ac8fd236 | ||
|  | 89a192af9d | ||
|  | aabcd82874 | ||
|  | 93397bea11 | ||
|  | 27eec5b982 | ||
|  | ecfc77a56f | ||
|  | 1b80a11e05 | ||
|  | b1c343484c | ||
|  | 0bb97b1c5c | ||
|  | 4220624b80 | ||
|  | db8764c1e2 | ||
|  | 08b314a573 | ||
|  | 4e0b6c77c6 | ||
|  | a4d10f0ea4 | ||
|  | 992f068900 | ||
|  | 0e6baa5a93 | ||
|  | a6259e5d50 | ||
|  | 49bc3307c5 | ||
|  | f350b3e5db | ||
|  | 06a11aedec | ||
|  | 56b159bb76 | 
| @ -7,7 +7,7 @@ module.exports = { | ||||
|     'eslint-config-prettier' | ||||
|   ], | ||||
|   parser: '@typescript-eslint/parser', | ||||
|   plugins: ['@typescript-eslint', 'eslint-plugin-jest'], | ||||
|   plugins: ['@typescript-eslint', 'eslint-plugin-node', 'eslint-plugin-jest'], | ||||
|   rules: { | ||||
|     '@typescript-eslint/no-require-imports': 'error', | ||||
|     '@typescript-eslint/no-non-null-assertion': 'off', | ||||
| @ -28,7 +28,8 @@ module.exports = { | ||||
|       } | ||||
|     ], | ||||
|     'no-control-regex': 'off', | ||||
|     'no-constant-condition': ['error', {checkLoops: false}] | ||||
|     'no-constant-condition': ['error', {checkLoops: false}], | ||||
|     'node/no-extraneous-import': 'error' | ||||
|   }, | ||||
|   overrides: [ | ||||
|     { | ||||
|  | ||||
							
								
								
									
										22
									
								
								.github/dependabot.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								.github/dependabot.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| # To get started with Dependabot version updates, you'll need to specify which | ||||
| # package ecosystems to update and where the package manifests are located. | ||||
| # Please see the documentation for all configuration options: | ||||
| # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file | ||||
| 
 | ||||
| version: 2 | ||||
| updates: | ||||
|   # Enable version updates for npm | ||||
|   - package-ecosystem: 'npm' | ||||
|     # Look for `package.json` and `lock` files in the `root` directory | ||||
|     directory: '/' | ||||
|     # Check the npm registry for updates every day (weekdays) | ||||
|     schedule: | ||||
|       interval: 'weekly' | ||||
| 
 | ||||
|   # Enable version updates for GitHub Actions | ||||
|   - package-ecosystem: 'github-actions' | ||||
|     # Workflow files stored in the default location of `.github/workflows` | ||||
|     # You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`. | ||||
|     directory: '/' | ||||
|     schedule: | ||||
|       interval: 'weekly' | ||||
							
								
								
									
										2
									
								
								.github/workflows/basic-validation.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/basic-validation.yml
									
									
									
									
										vendored
									
									
								
							| @ -14,3 +14,5 @@ jobs: | ||||
|   call-basic-validation: | ||||
|     name: Basic validation | ||||
|     uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main | ||||
|     with: | ||||
|       node-version: '20' | ||||
|  | ||||
							
								
								
									
										2
									
								
								.github/workflows/check-dist.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/check-dist.yml
									
									
									
									
										vendored
									
									
								
							| @ -15,3 +15,5 @@ jobs: | ||||
|   call-check-dist: | ||||
|     name: Check dist/ | ||||
|     uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main | ||||
|     with: | ||||
|       node-version: '20' | ||||
|  | ||||
							
								
								
									
										20
									
								
								.github/workflows/publish-immutable-actions.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								.github/workflows/publish-immutable-actions.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | ||||
| name: 'Publish Immutable Action Version' | ||||
| 
 | ||||
| on: | ||||
|   release: | ||||
|     types: [published] | ||||
| 
 | ||||
| jobs: | ||||
|   publish: | ||||
|     runs-on: ubuntu-latest | ||||
|     permissions: | ||||
|       contents: read | ||||
|       id-token: write | ||||
|       packages: write | ||||
| 
 | ||||
|     steps: | ||||
|       - name: Checking out | ||||
|         uses: actions/checkout@v4 | ||||
|       - name: Publish | ||||
|         id: publish | ||||
|         uses: actions/publish-immutable-action@v0.0.4 | ||||
| @ -22,7 +22,7 @@ jobs: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - name: Update the ${{ env.TAG_NAME }} tag | ||||
|         uses: actions/publish-action@v0.2.2 | ||||
|         uses: actions/publish-action@v0.3.0 | ||||
|         with: | ||||
|           source-tag: ${{ env.TAG_NAME }} | ||||
|           slack-webhook: ${{ secrets.SLACK_WEBHOOK }} | ||||
|  | ||||
							
								
								
									
										75
									
								
								.github/workflows/versions.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										75
									
								
								.github/workflows/versions.yml
									
									
									
									
										vendored
									
									
								
							| @ -18,9 +18,9 @@ jobs: | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest] | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest, macos-13] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v3 | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Setup Go Stable | ||||
|         uses: ./ | ||||
|         with: | ||||
| @ -33,9 +33,9 @@ jobs: | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest] | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest, macos-13] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v3 | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Setup Go oldStable | ||||
|         uses: ./ | ||||
|         with: | ||||
| @ -48,14 +48,16 @@ jobs: | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest] | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest, macos-13] | ||||
|         version: [stable, oldstable] | ||||
|         architecture: [x64, x32] | ||||
|         exclude: | ||||
|           - os: macos-latest | ||||
|             architecture: x32 | ||||
|           - os: macos-13 | ||||
|             architecture: x32 | ||||
|     steps: | ||||
|       - uses: actions/checkout@v3 | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }} | ||||
|         uses: ./ | ||||
|         with: | ||||
| @ -70,11 +72,17 @@ jobs: | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: [macos-latest, windows-latest, ubuntu-latest] | ||||
|         go: [1.17, 1.18, 1.19] | ||||
|         os: [macos-latest, windows-latest, ubuntu-latest, macos-13] | ||||
|         go: [1.21.13, 1.22.8, 1.23.2] | ||||
|         include: | ||||
|           - os: windows-latest | ||||
|             go: 1.20.14 | ||||
|         exclude: | ||||
|           - os: windows-latest | ||||
|             go: 1.23.2 | ||||
|     steps: | ||||
|       - name: Checkout | ||||
|         uses: actions/checkout@v3 | ||||
|         uses: actions/checkout@v4 | ||||
| 
 | ||||
|       - name: setup-go ${{ matrix.go }} | ||||
|         uses: ./ | ||||
| @ -90,10 +98,10 @@ jobs: | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest] | ||||
|         go-version: [1.16, 1.17] | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest, macos-13] | ||||
|         go-version: ['1.20', '1.21', '1.22', '1.23'] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v3 | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Setup Go and check latest | ||||
|         uses: ./ | ||||
|         with: | ||||
| @ -107,15 +115,15 @@ jobs: | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest] | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest, macos-13] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v3 | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Setup Go and check latest | ||||
|         uses: ./ | ||||
|         with: | ||||
|           go-version-file: __tests__/data/go.mod | ||||
|       - name: verify go | ||||
|         run: __tests__/verify-go.sh 1.14 | ||||
|         run: __tests__/verify-go.sh 1.20.14 | ||||
|         shell: bash | ||||
| 
 | ||||
|   go-version-file-with-gowork: | ||||
| @ -123,28 +131,27 @@ jobs: | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest] | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest, macos-13] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v3 | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Setup Go and check latest | ||||
|         uses: ./ | ||||
|         with: | ||||
|           go-version-file: __tests__/data/go.work | ||||
|       - name: verify go | ||||
|         run: __tests__/verify-go.sh 1.19 | ||||
|         run: __tests__/verify-go.sh 1.21 | ||||
|         shell: bash | ||||
| 
 | ||||
|   setup-versions-from-manifest: | ||||
|     name: Setup ${{ matrix.go }} ${{ matrix.os }} | ||||
|     runs-on: ${{ matrix.os }} | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: [macos-latest, windows-latest, ubuntu-latest] | ||||
|         go: [1.12.16, 1.13.11, 1.14.3] | ||||
|         os: [macos-latest, windows-latest, ubuntu-latest, macos-13] | ||||
|         go: [1.20.14, 1.21.10, 1.22.8, 1.23.2] | ||||
|     steps: | ||||
|       - name: Checkout | ||||
|         uses: actions/checkout@v3 | ||||
|         uses: actions/checkout@v4 | ||||
| 
 | ||||
|       - name: setup-go ${{ matrix.go }} | ||||
|         uses: ./ | ||||
| @ -156,16 +163,15 @@ jobs: | ||||
|         shell: bash | ||||
| 
 | ||||
|   setup-versions-from-dist: | ||||
|     name: Setup ${{ matrix.go }} ${{ matrix.os }} | ||||
|     runs-on: ${{ matrix.os }} | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: [macos-latest, windows-latest, ubuntu-latest] | ||||
|         go: [1.9, 1.8.6] | ||||
|         os: [windows-latest, ubuntu-latest, macos-13] | ||||
|         go: [1.11.12] | ||||
|     steps: | ||||
|       - name: Checkout | ||||
|         uses: actions/checkout@v3 | ||||
|         uses: actions/checkout@v4 | ||||
| 
 | ||||
|       - name: setup-go ${{ matrix.go }} | ||||
|         uses: ./ | ||||
| @ -181,14 +187,23 @@ jobs: | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest] | ||||
|         go-version: [1.16, 1.17] | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest, macos-13] | ||||
|         go-version: [1.20.14, 1.21, 1.22, 1.23] | ||||
|         include: | ||||
|           - os: macos-latest | ||||
|             architecture: arm64 | ||||
|           - os: ubuntu-latest | ||||
|             architecture: x64 | ||||
|           - os: windows-latest | ||||
|             architecture: x64 | ||||
|           - os: macos-13 | ||||
|             architecture: x64 | ||||
|     steps: | ||||
|       - uses: actions/checkout@v3 | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Setup Go and check latest | ||||
|         uses: ./ | ||||
|         with: | ||||
|           go-version: ${{ matrix.go-version }} | ||||
|           architecture: x64 | ||||
|           architecture: ${{ matrix.architecture }} | ||||
|       - name: Verify Go | ||||
|         run: go version | ||||
|  | ||||
							
								
								
									
										136
									
								
								.github/workflows/windows-validation.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										136
									
								
								.github/workflows/windows-validation.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,136 @@ | ||||
| name: Validate Windows installation | ||||
| 
 | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - main | ||||
|     paths-ignore: | ||||
|       - '**.md' | ||||
|   pull_request: | ||||
|     paths-ignore: | ||||
|       - '**.md' | ||||
| 
 | ||||
| jobs: | ||||
|   create-link-if-not-default: | ||||
|     runs-on: windows-latest | ||||
|     name: 'Validate if symlink is created' | ||||
|     strategy: | ||||
|       matrix: | ||||
|         cache: [false, true] | ||||
|         go: [1.20.1] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
| 
 | ||||
|       - name: 'Setup ${{ matrix.cache }}, cache: ${{ matrix.go }}' | ||||
|         uses: ./ | ||||
|         with: | ||||
|           go-version: ${{ matrix.go }} | ||||
|           cache: ${{ matrix.cache }} | ||||
| 
 | ||||
|       - name: 'Drive C: should have zero size link' | ||||
|         run: | | ||||
|           du -m -s 'C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64' | ||||
|           # make sure drive c: contains only a link | ||||
|           size=$(du -m -s 'C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'|cut -f1 -d$'\t') | ||||
|           if [ $size -ne 0 ];then | ||||
|             echo 'Size of the link created on drive c: must be 0' | ||||
|             exit 1 | ||||
|           fi | ||||
|         shell: bash | ||||
| 
 | ||||
|       # Drive D: is small, take care the action does not eat up the space | ||||
|       - name: 'Drive D: space usage should be below 1G' | ||||
|         run: | | ||||
|           du -m -s 'D:\hostedtoolcache\windows\go\${{ matrix.go }}\x64' | ||||
|           size=$(du -m -s 'D:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'|cut -f1 -d$'\t') | ||||
|           # make sure archive does not take lot of space | ||||
|           if [ $size -gt 999 ];then | ||||
|             echo 'Size of installed on drive d: go is too big'; | ||||
|             exit 1 | ||||
|           fi | ||||
|         shell: bash | ||||
| 
 | ||||
|       # make sure the Go installation has not been changed to the end user | ||||
|       - name: Test paths and environments | ||||
|         run: | | ||||
|           echo $PATH | ||||
|           which go | ||||
|           go version | ||||
|           go env | ||||
|           if [ $(which go) != '/c/hostedtoolcache/windows/go/${{ matrix.go }}/x64/bin/go' ];then | ||||
|             echo 'which go should return "/c/hostedtoolcache/windows/go/${{ matrix.go }}/x64/bin/go"' | ||||
|             exit 1 | ||||
|           fi | ||||
|           if [ $(go env GOROOT) != 'C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64' ];then | ||||
|             echo 'go env GOROOT should return "C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64"' | ||||
|             exit 1 | ||||
|           fi | ||||
|         shell: bash | ||||
| 
 | ||||
|   find-default-go: | ||||
|     name: 'Find default go version' | ||||
|     runs-on: windows-latest | ||||
|     outputs: | ||||
|       version: ${{ steps.goversion.outputs.version }} | ||||
|     steps: | ||||
|       - run: | | ||||
|           version=`go env GOVERSION|sed s/^go//` | ||||
|           echo "default go version: $version" | ||||
|           echo "version=$version" >> "$GITHUB_OUTPUT" | ||||
|         id: goversion | ||||
|         shell: bash | ||||
| 
 | ||||
|   dont-create-link-if-default: | ||||
|     name: 'Validate if symlink is not created for default go' | ||||
|     runs-on: windows-latest | ||||
|     needs: find-default-go | ||||
|     strategy: | ||||
|       matrix: | ||||
|         cache: [false, true] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
| 
 | ||||
|       - name: 'Setup default go, cache: ${{ matrix.cache }}' | ||||
|         uses: ./ | ||||
|         with: | ||||
|           go-version: ${{ needs.find-default-go.outputs.version }} | ||||
|           cache: ${{ matrix.cache }} | ||||
| 
 | ||||
|       - name: 'Drive C: should have Go installation, cache: ${{ matrix.cache}}' | ||||
|         run: | | ||||
|           size=$(du -m -s 'C:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64'|cut -f1 -d$'\t') | ||||
|           if [ $size -eq 0 ];then | ||||
|             echo 'Size of the hosted go installed on drive c: must be above zero' | ||||
|             exit 1 | ||||
|           fi | ||||
|         shell: bash | ||||
| 
 | ||||
|       - name: 'Drive D: should not have Go installation, cache: ${{ matrix.cache }}' | ||||
|         run: | | ||||
|           if [ -e 'D:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64' ];then | ||||
|             echo 'D:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64 should not exist for hosted version of go'; | ||||
|             exit 1 | ||||
|           fi | ||||
|         shell: bash | ||||
| 
 | ||||
|   hostedtoolcache: | ||||
|     name: 'Validate if hostedtoolcache works as expected' | ||||
|     runs-on: windows-latest | ||||
|     strategy: | ||||
|       matrix: | ||||
|         cache: [false] | ||||
|         go: [1.20.1] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
| 
 | ||||
|       - name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}' | ||||
|         uses: ./ | ||||
|         with: | ||||
|           go-version: ${{ matrix.go }} | ||||
|           cache: ${{ matrix.cache }} | ||||
| 
 | ||||
|       - name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }} (from hostedtoolcache)' | ||||
|         uses: ./ | ||||
|         with: | ||||
|           go-version: ${{ matrix.go }} | ||||
|           cache: ${{ matrix.cache }} | ||||
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@actions/core.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@actions/core.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@actions/http-client-1.0.11.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@actions/http-client-1.0.11.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@actions/io.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@actions/io.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@actions/tool-cache.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@actions/tool-cache.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@azure/core-auth.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@azure/core-auth.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@azure/core-http.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@azure/core-http.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@azure/core-lro.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@azure/core-lro.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@azure/core-paging.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@azure/core-paging.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@azure/core-util.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@azure/core-util.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@azure/logger.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@azure/logger.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@azure/ms-rest-js.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@azure/ms-rest-js.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@azure/storage-blob.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@azure/storage-blob.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@fastify/busboy.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@fastify/busboy.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@opentelemetry/api.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@opentelemetry/api.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@protobuf-ts/plugin-framework.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@protobuf-ts/plugin-framework.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@protobuf-ts/plugin.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@protobuf-ts/plugin.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@protobuf-ts/protoc.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@protobuf-ts/protoc.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@protobuf-ts/runtime-rpc.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@protobuf-ts/runtime-rpc.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@protobuf-ts/runtime.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@protobuf-ts/runtime.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@types/node-fetch.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@types/node-fetch.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/@types/node.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/@types/node.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/camel-case.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/camel-case.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/commander.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/commander.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/form-data-3.0.1.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/form-data-3.0.1.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/fs.realpath.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/fs.realpath.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/glob.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/glob.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/inflight.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/inflight.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/inherits.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/inherits.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/lodash.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/lodash.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/lower-case.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/lower-case.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/no-case.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/no-case.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/node-fetch.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/node-fetch.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/once.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/once.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/pascal-case.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/pascal-case.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/path-to-regexp.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/path-to-regexp.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/prettier.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/prettier.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/psl.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/psl.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/sax.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/sax.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/semver-7.6.3.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/semver-7.6.3.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/tough-cookie.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/tough-cookie.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/ts-poet.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/ts-poet.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/tslib-2.3.1.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/tslib-2.3.1.dep.yml
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/twirp-ts.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/twirp-ts.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/typescript.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/typescript.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/undici-types.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/undici-types.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/wrappy.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/wrappy.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.licenses/npm/yaml.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.licenses/npm/yaml.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										116
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										116
									
								
								README.md
									
									
									
									
									
								
							| @ -8,6 +8,14 @@ This action sets up a go environment for use in actions by: | ||||
| - Optionally downloading and caching a version of Go by version and adding to `PATH`. | ||||
| - Registering problem matchers for error output. | ||||
| 
 | ||||
| # V5 | ||||
| 
 | ||||
| The V5 edition of the action offers: | ||||
| 
 | ||||
| - Upgraded Node.js runtime from node16 to node20 | ||||
| 
 | ||||
| See full release notes on the [releases page](https://github.com/actions/setup-go/releases). | ||||
| 
 | ||||
| # V4 | ||||
| 
 | ||||
| The V4 edition of the action offers: | ||||
| @ -42,8 +50,8 @@ Matching by [semver spec](https://github.com/npm/node-semver): | ||||
| 
 | ||||
| ```yaml | ||||
| steps: | ||||
|   - uses: actions/checkout@v3 | ||||
|   - uses: actions/setup-go@v4 | ||||
|   - uses: actions/checkout@v4 | ||||
|   - uses: actions/setup-go@v5 | ||||
|     with: | ||||
|       go-version: '^1.13.1' # The Go version to download (if necessary) and use. | ||||
|   - run: go version | ||||
| @ -51,19 +59,27 @@ steps: | ||||
| 
 | ||||
| ```yaml | ||||
| steps: | ||||
|   - uses: actions/checkout@v3 | ||||
|   - uses: actions/setup-go@v4 | ||||
|   - uses: actions/checkout@v4 | ||||
|   - uses: actions/setup-go@v5 | ||||
|     with: | ||||
|       go-version: '>=1.17.0' | ||||
|   - run: go version | ||||
| ``` | ||||
| 
 | ||||
| > **Note**: Due to the peculiarities of YAML parsing, it is recommended to wrap the version in single quotation marks: | ||||
| > | ||||
| > ```yaml | ||||
| >   go-version: '1.20' | ||||
| > ``` | ||||
| > | ||||
| > The recommendation is based on the YAML parser's behavior, which interprets non-wrapped values as numbers and, in the case of version 1.20, trims it down to 1.2, which may not be very obvious. | ||||
| 
 | ||||
| Matching an unstable pre-release: | ||||
| 
 | ||||
| ```yaml | ||||
| steps: | ||||
|   - uses: actions/checkout@v3 | ||||
|   - uses: actions/setup-go@v4 | ||||
|   - uses: actions/checkout@v4 | ||||
|   - uses: actions/setup-go@v5 | ||||
|     with: | ||||
|       go-version: '1.18.0-rc.1' # The Go version to download (if necessary) and use. | ||||
|   - run: go version | ||||
| @ -71,8 +87,8 @@ steps: | ||||
| 
 | ||||
| ```yaml | ||||
| steps: | ||||
|   - uses: actions/checkout@v3 | ||||
|   - uses: actions/setup-go@v4 | ||||
|   - uses: actions/checkout@v4 | ||||
|   - uses: actions/setup-go@v5 | ||||
|     with: | ||||
|       go-version: '1.16.0-beta.1' # The Go version to download (if necessary) and use. | ||||
|   - run: go version | ||||
| @ -86,8 +102,8 @@ See [action.yml](action.yml) | ||||
| 
 | ||||
| ```yaml | ||||
| steps: | ||||
|   - uses: actions/checkout@v3 | ||||
|   - uses: actions/setup-go@v4 | ||||
|   - uses: actions/checkout@v4 | ||||
|   - uses: actions/setup-go@v5 | ||||
|     with: | ||||
|       go-version: '1.16.1' # The Go version to download (if necessary) and use. | ||||
|   - run: go run hello.go | ||||
| @ -107,8 +123,8 @@ want the most up-to-date Go version to always be used. | ||||
| 
 | ||||
| ```yaml | ||||
| steps: | ||||
|   - uses: actions/checkout@v3 | ||||
|   - uses: actions/setup-go@v4 | ||||
|   - uses: actions/checkout@v4 | ||||
|   - uses: actions/setup-go@v5 | ||||
|     with: | ||||
|       go-version: '1.14' | ||||
|       check-latest: true | ||||
| @ -128,8 +144,8 @@ set to `true` | ||||
| 
 | ||||
| ```yaml | ||||
| steps: | ||||
|   - uses: actions/checkout@v3 | ||||
|   - uses: actions/setup-go@v4 | ||||
|   - uses: actions/checkout@v4 | ||||
|   - uses: actions/setup-go@v5 | ||||
|     with: | ||||
|       go-version: 'stable' | ||||
|   - run: go run hello.go | ||||
| @ -137,8 +153,8 @@ steps: | ||||
| 
 | ||||
| ```yaml | ||||
| steps: | ||||
|   - uses: actions/checkout@v3 | ||||
|   - uses: actions/setup-go@v4 | ||||
|   - uses: actions/checkout@v4 | ||||
|   - uses: actions/setup-go@v5 | ||||
|     with: | ||||
|       go-version: 'oldstable' | ||||
|   - run: go run hello.go | ||||
| @ -152,38 +168,44 @@ The `cache` input is optional, and caching is turned on by default. | ||||
| 
 | ||||
| The action defaults to search for the dependency file - go.sum in the repository root, and uses its hash as a part of | ||||
| the cache key. Use `cache-dependency-path` input for cases when multiple dependency files are used, or they are located | ||||
| in different subdirectories. | ||||
| in different subdirectories. The input supports glob patterns. | ||||
| 
 | ||||
| If some problem that prevents success caching happens then the action issues the warning in the log and continues the execution of the pipeline.  | ||||
| If some problem that prevents success caching happens then the action issues the warning in the log and continues the execution of the pipeline. | ||||
| 
 | ||||
| **Caching in monorepos** | ||||
| 
 | ||||
| ```yaml | ||||
| steps: | ||||
|   - uses: actions/checkout@v3 | ||||
|   - uses: actions/setup-go@v4 | ||||
|   - uses: actions/checkout@v4 | ||||
|   - uses: actions/setup-go@v5 | ||||
|     with: | ||||
|       go-version: '1.17' | ||||
|       check-latest: true | ||||
|       cache-dependency-path: subdir/go.sum | ||||
|       cache-dependency-path: | | ||||
|              subdir/go.sum | ||||
|              tools/go.sum | ||||
|     # cache-dependency-path: "**/*.sum" | ||||
| 
 | ||||
|   - run: go run hello.go | ||||
|   ``` | ||||
| 
 | ||||
| ## Getting go version from the go.mod file | ||||
| 
 | ||||
| The `go-version-file` input accepts a path to a `go.mod` file or a `go.work` file that contains the version of Go to be | ||||
| used by a project. As the `go.mod` file contains only major and minor (e.g. 1.18) tags, the action will search for the | ||||
| latest available patch version sequentially in the runner's directory with the cached tools, in | ||||
| the [versions-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json) file or at the go | ||||
| servers. | ||||
| The `go-version-file` input accepts a path to a `go.mod` file or a `go.work` file that contains the version of Go to be used by a project. | ||||
| 
 | ||||
| The `go` directive in `go.mod` can specify a patch version or omit it altogether (e.g., `go 1.22.0` or `go 1.22`).   | ||||
| If a patch version is specified, that specific patch version will be used.   | ||||
| If no patch version is specified, it will search for the latest available patch version in the cache, | ||||
| [versions-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json), and the | ||||
| [official Go language website](https://golang.org/dl/?mode=json&include=all), in that order. | ||||
| 
 | ||||
| If both the `go-version` and the `go-version-file` inputs are provided then the `go-version` input is used. | ||||
| > The action will search for the `go.mod` file relative to the repository root | ||||
| 
 | ||||
| ```yaml | ||||
| steps: | ||||
|   - uses: actions/checkout@v3 | ||||
|   - uses: actions/setup-go@v4 | ||||
|   - uses: actions/checkout@v4 | ||||
|   - uses: actions/setup-go@v5 | ||||
|     with: | ||||
|       go-version-file: 'path/to/go.mod' | ||||
|   - run: go version | ||||
| @ -200,9 +222,9 @@ jobs: | ||||
|         go: [ '1.14', '1.13' ] | ||||
|     name: Go ${{ matrix.go }} sample | ||||
|     steps: | ||||
|       - uses: actions/checkout@v3 | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Setup go | ||||
|         uses: actions/setup-go@v4 | ||||
|         uses: actions/setup-go@v5 | ||||
|         with: | ||||
|           go-version: ${{ matrix.go }} | ||||
|       - run: go run hello.go | ||||
| @ -220,31 +242,35 @@ documentation. | ||||
| 
 | ||||
| ## Using `setup-go` on GHES | ||||
| 
 | ||||
| `setup-go` comes pre-installed on the appliance with GHES if Actions is enabled. When dynamically downloading Go | ||||
| distributions, `setup-go` downloads distributions from [`actions/go-versions`](https://github.com/actions/go-versions) | ||||
| on github.com (outside of the appliance). These calls to `actions/go-versions` are made via unauthenticated requests, | ||||
| which are limited | ||||
| to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting). If | ||||
| more requests are made within the time frame, then you will start to see rate-limit errors during downloading that looks | ||||
| like: `##[error]API rate limit exceeded for...`. After that error the action will try to download versions directly | ||||
| from https://storage.googleapis.com/golang, but it also can have rate limit so it's better to put token. | ||||
| `setup-go` comes pre-installed on the appliance with GHES if Actions is enabled. | ||||
| When dynamically downloading Go distributions, `setup-go` downloads distributions from [`actions/go-versions`](https://github.com/actions/go-versions) on github.com (outside of the appliance). | ||||
| 
 | ||||
| To get a higher rate limit, you | ||||
| can [generate a personal access token on github.com](https://github.com/settings/tokens/new) and pass it as the `token` | ||||
| input for the action: | ||||
| These calls to `actions/go-versions` are made via unauthenticated requests, which are limited to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting). | ||||
| If more requests are made within the time frame, then the action leverages the `raw API` to retrieve the version-manifest. This approach does not impose a rate limit and hence facilitates unrestricted consumption. This is particularly beneficial for GHES runners, which often share the same IP, to avoid the quick exhaustion of the unauthenticated rate limit. | ||||
| If that fails as well the action will try to download versions directly from https://storage.googleapis.com/golang. | ||||
| 
 | ||||
| If that fails as well you can get a higher rate limit with [generating a personal access token on github.com](https://github.com/settings/tokens/new) and passing it as the `token` input to the action: | ||||
| 
 | ||||
| ```yaml | ||||
| uses: actions/setup-go@v4 | ||||
| uses: actions/setup-go@v5 | ||||
| with: | ||||
|   token: ${{ secrets.GH_DOTCOM_TOKEN }} | ||||
|   go-version: 1.18 | ||||
|   go-version: '1.18' | ||||
| ``` | ||||
| 
 | ||||
| If the runner is not able to access github.com, any Go versions requested during a workflow run must come from the | ||||
| runner's tool cache. | ||||
| If the runner is not able to access github.com, any Go versions requested during a workflow run must come from the runner's tool cache. | ||||
| See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server@3.2/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)" | ||||
| for more information. | ||||
| 
 | ||||
| ## Recommended permissions | ||||
| 
 | ||||
| When using the `setup-go` action in your GitHub Actions workflow, it is recommended to set the following permissions to ensure proper functionality: | ||||
| 
 | ||||
| ```yaml | ||||
| permissions: | ||||
|   contents: read # access to check out code and install dependencies | ||||
| ``` | ||||
| 
 | ||||
| # License | ||||
| 
 | ||||
| The scripts and documentation in this project are released under the [MIT License](LICENSE) | ||||
|  | ||||
| @ -209,3 +209,41 @@ describe('isCacheFeatureAvailable', () => { | ||||
|     expect(warningSpy).toHaveBeenCalledWith(warningMessage); | ||||
|   }); | ||||
| }); | ||||
| 
 | ||||
| describe('isGhes', () => { | ||||
|   const pristineEnv = process.env; | ||||
| 
 | ||||
|   beforeEach(() => { | ||||
|     jest.resetModules(); | ||||
|     process.env = {...pristineEnv}; | ||||
|   }); | ||||
| 
 | ||||
|   afterAll(() => { | ||||
|     process.env = pristineEnv; | ||||
|   }); | ||||
| 
 | ||||
|   it('returns false when the GITHUB_SERVER_URL environment variable is not defined', async () => { | ||||
|     delete process.env['GITHUB_SERVER_URL']; | ||||
|     expect(cacheUtils.isGhes()).toBeFalsy(); | ||||
|   }); | ||||
| 
 | ||||
|   it('returns false when the GITHUB_SERVER_URL environment variable is set to github.com', async () => { | ||||
|     process.env['GITHUB_SERVER_URL'] = 'https://github.com'; | ||||
|     expect(cacheUtils.isGhes()).toBeFalsy(); | ||||
|   }); | ||||
| 
 | ||||
|   it('returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL', async () => { | ||||
|     process.env['GITHUB_SERVER_URL'] = 'https://contoso.ghe.com'; | ||||
|     expect(cacheUtils.isGhes()).toBeFalsy(); | ||||
|   }); | ||||
| 
 | ||||
|   it('returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix', async () => { | ||||
|     process.env['GITHUB_SERVER_URL'] = 'https://mock-github.localhost'; | ||||
|     expect(cacheUtils.isGhes()).toBeFalsy(); | ||||
|   }); | ||||
| 
 | ||||
|   it('returns true when the GITHUB_SERVER_URL environment variable is set to some other URL', async () => { | ||||
|     process.env['GITHUB_SERVER_URL'] = 'https://src.onpremise.fabrikam.com'; | ||||
|     expect(cacheUtils.isGhes()).toBeTruthy(); | ||||
|   }); | ||||
| }); | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| module example.com/mymodule | ||||
| 
 | ||||
| go 1.14 | ||||
| go 1.20 | ||||
| 
 | ||||
| require ( | ||||
| 	example.com/othermodule v1.2.3 | ||||
|  | ||||
| @ -1,3 +1,3 @@ | ||||
| go 1.19 | ||||
| go 1.21 | ||||
| 
 | ||||
| use . | ||||
|  | ||||
| @ -3,10 +3,11 @@ import * as io from '@actions/io'; | ||||
| import * as tc from '@actions/tool-cache'; | ||||
| import fs from 'fs'; | ||||
| import cp from 'child_process'; | ||||
| import osm from 'os'; | ||||
| import osm, {type} from 'os'; | ||||
| import path from 'path'; | ||||
| import * as main from '../src/main'; | ||||
| import * as im from '../src/installer'; | ||||
| import * as httpm from '@actions/http-client'; | ||||
| 
 | ||||
| import goJsonData from './data/golang-dl.json'; | ||||
| import matchers from '../matchers.json'; | ||||
| @ -16,6 +17,8 @@ const matcherRegExp = new RegExp(matcherPattern.regexp); | ||||
| const win32Join = path.win32.join; | ||||
| const posixJoin = path.posix.join; | ||||
| 
 | ||||
| jest.setTimeout(10000); | ||||
| 
 | ||||
| describe('setup-go', () => { | ||||
|   let inputs = {} as any; | ||||
|   let os = {} as any; | ||||
| @ -39,9 +42,12 @@ describe('setup-go', () => { | ||||
|   let existsSpy: jest.SpyInstance; | ||||
|   let readFileSpy: jest.SpyInstance; | ||||
|   let mkdirpSpy: jest.SpyInstance; | ||||
|   let mkdirSpy: jest.SpyInstance; | ||||
|   let symlinkSpy: jest.SpyInstance; | ||||
|   let execSpy: jest.SpyInstance; | ||||
|   let getManifestSpy: jest.SpyInstance; | ||||
|   let getAllVersionsSpy: jest.SpyInstance; | ||||
|   let httpmGetJsonSpy: 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)
 | ||||
| @ -86,12 +92,20 @@ describe('setup-go', () => { | ||||
|     getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo'); | ||||
|     getAllVersionsSpy = jest.spyOn(im, 'getManifest'); | ||||
| 
 | ||||
|     // httm
 | ||||
|     httpmGetJsonSpy = jest.spyOn(httpm.HttpClient.prototype, 'getJson'); | ||||
| 
 | ||||
|     // io
 | ||||
|     whichSpy = jest.spyOn(io, 'which'); | ||||
|     existsSpy = jest.spyOn(fs, 'existsSync'); | ||||
|     readFileSpy = jest.spyOn(fs, 'readFileSync'); | ||||
|     mkdirpSpy = jest.spyOn(io, 'mkdirP'); | ||||
| 
 | ||||
|     // fs
 | ||||
|     mkdirSpy = jest.spyOn(fs, 'mkdir'); | ||||
|     symlinkSpy = jest.spyOn(fs, 'symlinkSync'); | ||||
|     symlinkSpy.mockImplementation(() => {}); | ||||
| 
 | ||||
|     // gets
 | ||||
|     getManifestSpy.mockImplementation(() => <tc.IToolRelease[]>goTestManifest); | ||||
| 
 | ||||
| @ -142,6 +156,21 @@ describe('setup-go', () => { | ||||
|     ); | ||||
|   }); | ||||
| 
 | ||||
|   it('should return manifest from repo', async () => { | ||||
|     const manifest = await im.getManifest(undefined); | ||||
|     expect(manifest).toEqual(goTestManifest); | ||||
|   }); | ||||
| 
 | ||||
|   it('should return manifest from raw URL if repo fetch fails', async () => { | ||||
|     getManifestSpy.mockRejectedValue(new Error('Fetch failed')); | ||||
|     httpmGetJsonSpy.mockResolvedValue({ | ||||
|       result: goTestManifest | ||||
|     }); | ||||
|     const manifest = await im.getManifest(undefined); | ||||
|     expect(httpmGetJsonSpy).toHaveBeenCalled(); | ||||
|     expect(manifest).toEqual(goTestManifest); | ||||
|   }); | ||||
| 
 | ||||
|   it('can find 1.9 from manifest on linux', async () => { | ||||
|     os.platform = 'linux'; | ||||
|     os.arch = 'x64'; | ||||
| @ -781,6 +810,9 @@ describe('setup-go', () => { | ||||
|       getManifestSpy.mockImplementation(() => { | ||||
|         throw new Error('Unable to download manifest'); | ||||
|       }); | ||||
|       httpmGetJsonSpy.mockRejectedValue( | ||||
|         new Error('Unable to download manifest from raw URL') | ||||
|       ); | ||||
|       getAllVersionsSpy.mockImplementationOnce(() => undefined); | ||||
| 
 | ||||
|       dlSpy.mockImplementation(async () => '/some/temp/path'); | ||||
|  | ||||
							
								
								
									
										62
									
								
								__tests__/windows-toolcache.test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								__tests__/windows-toolcache.test.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,62 @@ | ||||
| import fs from 'fs'; | ||||
| import * as io from '@actions/io'; | ||||
| import * as tc from '@actions/tool-cache'; | ||||
| import path from 'path'; | ||||
| 
 | ||||
| describe('Windows performance workaround', () => { | ||||
|   let mkdirSpy: jest.SpyInstance; | ||||
|   let symlinkSpy: jest.SpyInstance; | ||||
|   let statSpy: jest.SpyInstance; | ||||
|   let readdirSpy: jest.SpyInstance; | ||||
|   let writeFileSpy: jest.SpyInstance; | ||||
|   let rmRFSpy: jest.SpyInstance; | ||||
|   let mkdirPSpy: jest.SpyInstance; | ||||
|   let cpSpy: jest.SpyInstance; | ||||
| 
 | ||||
|   let runnerToolCache: string | undefined; | ||||
|   beforeEach(() => { | ||||
|     mkdirSpy = jest.spyOn(fs, 'mkdir'); | ||||
|     symlinkSpy = jest.spyOn(fs, 'symlinkSync'); | ||||
|     statSpy = jest.spyOn(fs, 'statSync'); | ||||
|     readdirSpy = jest.spyOn(fs, 'readdirSync'); | ||||
|     writeFileSpy = jest.spyOn(fs, 'writeFileSync'); | ||||
|     rmRFSpy = jest.spyOn(io, 'rmRF'); | ||||
|     mkdirPSpy = jest.spyOn(io, 'mkdirP'); | ||||
|     cpSpy = jest.spyOn(io, 'cp'); | ||||
| 
 | ||||
|     // default implementations
 | ||||
|     // @ts-ignore - not implement unused methods
 | ||||
|     statSpy.mockImplementation(() => ({ | ||||
|       isDirectory: () => true | ||||
|     })); | ||||
|     readdirSpy.mockImplementation(() => []); | ||||
|     writeFileSpy.mockImplementation(() => {}); | ||||
|     mkdirSpy.mockImplementation(() => {}); | ||||
|     symlinkSpy.mockImplementation(() => {}); | ||||
|     rmRFSpy.mockImplementation(() => Promise.resolve()); | ||||
|     mkdirPSpy.mockImplementation(() => Promise.resolve()); | ||||
|     cpSpy.mockImplementation(() => Promise.resolve()); | ||||
| 
 | ||||
|     runnerToolCache = process.env['RUNNER_TOOL_CACHE']; | ||||
|   }); | ||||
|   afterEach(() => { | ||||
|     jest.clearAllMocks(); | ||||
|     process.env['RUNNER_TOOL_CACHE'] = runnerToolCache; | ||||
|   }); | ||||
|   // cacheWindowsToolkitDir depends on implementation of tc.cacheDir
 | ||||
|   // with the assumption that target dir is passed by RUNNER_TOOL_CACHE environment variable
 | ||||
|   // Make sure the implementation has not been changed
 | ||||
|   it('addExecutablesToCache should depend on env[RUNNER_TOOL_CACHE]', async () => { | ||||
|     process.env['RUNNER_TOOL_CACHE'] = '/faked-hostedtoolcache1'; | ||||
|     const cacheDir1 = await tc.cacheDir('/qzx', 'go', '1.2.3', 'arch'); | ||||
|     expect(cacheDir1).toBe( | ||||
|       path.join('/', 'faked-hostedtoolcache1', 'go', '1.2.3', 'arch') | ||||
|     ); | ||||
| 
 | ||||
|     process.env['RUNNER_TOOL_CACHE'] = '/faked-hostedtoolcache2'; | ||||
|     const cacheDir2 = await tc.cacheDir('/qzx', 'go', '1.2.3', 'arch'); | ||||
|     expect(cacheDir2).toBe( | ||||
|       path.join('/', 'faked-hostedtoolcache2', 'go', '1.2.3', 'arch') | ||||
|     ); | ||||
|   }); | ||||
| }); | ||||
| @ -3,14 +3,14 @@ description: 'Setup a Go environment and add it to the PATH' | ||||
| author: 'GitHub' | ||||
| inputs: | ||||
|   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. Be sure to enclose this option in single quotation marks.' | ||||
|   go-version-file: | ||||
|     description: 'Path to the go.mod or go.work file.' | ||||
|   check-latest: | ||||
|     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: false | ||||
|   token: | ||||
|     description: Used to pull node distributions from go-versions. Since there's a default, this is typically not supplied by the user. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting. | ||||
|     description: Used to pull Go distributions from go-versions. Since there's a default, this is typically not supplied by the user. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting. | ||||
|     default: ${{ github.server_url == 'https://github.com' && github.token || '' }} | ||||
|   cache: | ||||
|     description: Used to specify whether caching is needed. Set to true, if you'd like to enable caching. | ||||
| @ -25,7 +25,7 @@ outputs: | ||||
|   cache-hit: | ||||
|     description: 'A boolean value to indicate if a cache was hit' | ||||
| runs: | ||||
|   using: 'node16' | ||||
|   using: 'node20' | ||||
|   main: 'dist/setup/index.js' | ||||
|   post: 'dist/cache-save/index.js' | ||||
|   post-if: success() | ||||
|  | ||||
							
								
								
									
										46629
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										46629
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										50909
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										50909
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @ -4,7 +4,7 @@ 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.   | ||||
| `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 | ||||
| @ -16,7 +16,7 @@ Integration of caching functionality into `actions/setup-go` action will bring t | ||||
| 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:  | ||||
| - 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 | ||||
| @ -32,7 +32,7 @@ We don't pursue the goal to provide wide customization of caching in scope of `a | ||||
| 
 | ||||
| ```yml | ||||
| steps: | ||||
| - uses: actions/checkout@v3 | ||||
| - uses: actions/checkout@v4 | ||||
| - uses: actions/setup-go@v3 | ||||
|   with: | ||||
|     go-version: '18' | ||||
| @ -43,7 +43,7 @@ steps: | ||||
| 
 | ||||
|  ```yml | ||||
| steps: | ||||
| - uses: actions/checkout@v3 | ||||
| - uses: actions/checkout@v4 | ||||
| - uses: actions/setup-go@v3 | ||||
|   with: | ||||
|     go-version: '18' | ||||
| @ -53,7 +53,7 @@ steps: | ||||
| 
 | ||||
|  ```yml | ||||
| steps: | ||||
| - uses: actions/checkout@v3 | ||||
| - uses: actions/checkout@v4 | ||||
| - uses: actions/setup-go@v3 | ||||
|   with: | ||||
|     go-version: '18' | ||||
| @ -66,4 +66,4 @@ steps: | ||||
| # 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) | ||||
| After that, we will update [starter-workflows](https://github.com/actions/starter-workflows/blob/main/ci/go.yml) | ||||
|  | ||||
| @ -6,13 +6,13 @@ We have prepared a short guide so that the process of making your contribution i | ||||
| 
 | ||||
| ## How can I contribute... | ||||
| 
 | ||||
| * [Contribute Documentation:green_book:](#contribute-documentation) | ||||
| * [Contribute Documentation :green_book:](#contribute-documentation) | ||||
| 
 | ||||
| * [Contribute Code :computer:](#contribute-code) | ||||
| 
 | ||||
| * [Provide Support on Issues:pencil:](#provide-support-on-issues) | ||||
| * [Provide Support on Issues :pencil:](#provide-support-on-issues) | ||||
| 
 | ||||
| * [Review Pull Requests:mag:](#review-pull-requests) | ||||
| * [Review Pull Requests :mag:](#review-pull-requests) | ||||
| 
 | ||||
| ## Contribute documentation | ||||
| 
 | ||||
| @ -113,4 +113,4 @@ Another great way to contribute is pull request reviews. Please, be extra kind: | ||||
| - Make sure you're familiar with the code or documentation is updated, unless it's a minor change (spellchecking, minor formatting, etc.) | ||||
| - Review changes using the GitHub functionality. You can ask a clarifying question, point out an error or suggest an alternative.  | ||||
| > Note: You may ask for minor changes - "nitpicks", but consider whether they are real blockers to merging or not | ||||
| - Submit your review, which may include comments, an approval, or a changes request | ||||
| - Submit your review, which may include comments, an approval, or a changes request | ||||
|  | ||||
							
								
								
									
										8981
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										8981
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										39
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								package.json
									
									
									
									
									
								
							| @ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "setup-go", | ||||
|   "version": "4.0.0", | ||||
|   "version": "5.0.0", | ||||
|   "private": true, | ||||
|   "description": "setup go action", | ||||
|   "main": "lib/setup-go.js", | ||||
| @ -25,30 +25,31 @@ | ||||
|   "author": "GitHub", | ||||
|   "license": "MIT", | ||||
|   "dependencies": { | ||||
|     "@actions/cache": "^3.2.1", | ||||
|     "@actions/core": "^1.10.0", | ||||
|     "@actions/exec": "^1.1.0", | ||||
|     "@actions/glob": "^0.2.0", | ||||
|     "@actions/http-client": "^2.0.1", | ||||
|     "@actions/cache": "^4.0.0", | ||||
|     "@actions/core": "^1.11.1", | ||||
|     "@actions/exec": "^1.1.1", | ||||
|     "@actions/glob": "^0.4.0", | ||||
|     "@actions/http-client": "^2.2.1", | ||||
|     "@actions/io": "^1.0.2", | ||||
|     "@actions/tool-cache": "^1.5.5", | ||||
|     "semver": "^6.1.1" | ||||
|     "@actions/tool-cache": "^2.0.1", | ||||
|     "semver": "^7.6.3" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@types/jest": "^27.0.2", | ||||
|     "@types/node": "^16.11.25", | ||||
|     "@types/semver": "^6.0.0", | ||||
|     "@types/jest": "^29.5.12", | ||||
|     "@types/node": "^20.11.28", | ||||
|     "@types/semver": "^7.5.8", | ||||
|     "@typescript-eslint/eslint-plugin": "^5.54.0", | ||||
|     "@typescript-eslint/parser": "^5.54.0", | ||||
|     "@vercel/ncc": "^0.33.4", | ||||
|     "eslint": "^8.35.0", | ||||
|     "eslint-config-prettier": "^8.6.0", | ||||
|     "eslint-plugin-jest": "^27.2.1", | ||||
|     "jest": "^27.2.5", | ||||
|     "jest-circus": "^27.2.5", | ||||
|     "@vercel/ncc": "^0.38.1", | ||||
|     "eslint": "^8.57.0", | ||||
|     "eslint-config-prettier": "^10.0.1", | ||||
|     "eslint-plugin-jest": "^27.9.0", | ||||
|     "eslint-plugin-node": "^11.1.0", | ||||
|     "jest": "^29.7.0", | ||||
|     "jest-circus": "^29.7.0", | ||||
|     "nock": "^10.0.6", | ||||
|     "prettier": "^2.8.4", | ||||
|     "ts-jest": "^27.0.5", | ||||
|     "typescript": "^4.3.3" | ||||
|     "ts-jest": "^29.1.2", | ||||
|     "typescript": "^5.4.2" | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -15,6 +15,7 @@ export const restoreCache = async ( | ||||
| ) => { | ||||
|   const packageManagerInfo = await getPackageManagerInfo(packageManager); | ||||
|   const platform = process.env.RUNNER_OS; | ||||
|   const arch = process.arch; | ||||
| 
 | ||||
|   const cachePaths = await getCacheDirectoryPath(packageManagerInfo); | ||||
| 
 | ||||
| @ -29,7 +30,9 @@ export const restoreCache = async ( | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   const primaryKey = `setup-go-${platform}-go-${versionSpec}-${fileHash}`; | ||||
|   const linuxVersion = | ||||
|     process.env.RUNNER_OS === 'Linux' ? `${process.env.ImageOS}-` : ''; | ||||
|   const primaryKey = `setup-go-${platform}-${arch}-${linuxVersion}go-${versionSpec}-${fileHash}`; | ||||
|   core.debug(`primary key is ${primaryKey}`); | ||||
| 
 | ||||
|   core.saveState(State.CachePrimaryKey, primaryKey); | ||||
|  | ||||
| @ -12,9 +12,19 @@ process.on('uncaughtException', e => { | ||||
|   core.info(`${warningPrefix}${e.message}`); | ||||
| }); | ||||
| 
 | ||||
| export async function run() { | ||||
| // Added early exit to resolve issue with slow post action step:
 | ||||
| // - https://github.com/actions/setup-node/issues/878
 | ||||
| // https://github.com/actions/cache/pull/1217
 | ||||
| export async function run(earlyExit?: boolean) { | ||||
|   try { | ||||
|     await cachePackages(); | ||||
|     const cacheInput = core.getBooleanInput('cache'); | ||||
|     if (cacheInput) { | ||||
|       await cachePackages(); | ||||
| 
 | ||||
|       if (earlyExit) { | ||||
|         process.exit(0); | ||||
|       } | ||||
|     } | ||||
|   } catch (error) { | ||||
|     let message = 'Unknown error!'; | ||||
|     if (error instanceof Error) { | ||||
| @ -28,11 +38,6 @@ export async function run() { | ||||
| } | ||||
| 
 | ||||
| const cachePackages = async () => { | ||||
|   const cacheInput = core.getBooleanInput('cache'); | ||||
|   if (!cacheInput) { | ||||
|     return; | ||||
|   } | ||||
| 
 | ||||
|   const packageManager = 'default'; | ||||
| 
 | ||||
|   const state = core.getState(State.CacheMatchedKey); | ||||
| @ -85,4 +90,4 @@ function logWarning(message: string): void { | ||||
|   core.info(`${warningPrefix}${message}`); | ||||
| } | ||||
| 
 | ||||
| run(); | ||||
| run(true); | ||||
|  | ||||
| @ -63,7 +63,13 @@ export function isGhes(): boolean { | ||||
|   const ghUrl = new URL( | ||||
|     process.env['GITHUB_SERVER_URL'] || 'https://github.com' | ||||
|   ); | ||||
|   return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; | ||||
| 
 | ||||
|   const hostname = ghUrl.hostname.trimEnd().toUpperCase(); | ||||
|   const isGitHubHost = hostname === 'GITHUB.COM'; | ||||
|   const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); | ||||
|   const isLocalHost = hostname.endsWith('.LOCALHOST'); | ||||
| 
 | ||||
|   return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; | ||||
| } | ||||
| 
 | ||||
| export function isCacheFeatureAvailable(): boolean { | ||||
|  | ||||
							
								
								
									
										131
									
								
								src/installer.ts
									
									
									
									
									
								
							
							
						
						
									
										131
									
								
								src/installer.ts
									
									
									
									
									
								
							| @ -8,6 +8,11 @@ import fs from 'fs'; | ||||
| import os from 'os'; | ||||
| import {StableReleaseAlias} from './utils'; | ||||
| 
 | ||||
| const MANIFEST_REPO_OWNER = 'actions'; | ||||
| const MANIFEST_REPO_NAME = 'go-versions'; | ||||
| const MANIFEST_REPO_BRANCH = 'main'; | ||||
| const MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`; | ||||
| 
 | ||||
| type InstallationType = 'dist' | 'manifest'; | ||||
| 
 | ||||
| export interface IGoVersionFile { | ||||
| @ -114,9 +119,9 @@ export async function getGo( | ||||
|         `Received HTTP status code ${err.httpStatusCode}.  This usually indicates the rate limit has been exceeded` | ||||
|       ); | ||||
|     } else { | ||||
|       core.info(err.message); | ||||
|       core.info((err as Error).message); | ||||
|     } | ||||
|     core.debug(err.stack); | ||||
|     core.debug((err as Error).stack ?? ''); | ||||
|     core.info('Falling back to download directly from Go'); | ||||
|   } | ||||
| 
 | ||||
| @ -160,10 +165,79 @@ async function resolveVersionFromManifest( | ||||
|     return info?.resolvedVersion; | ||||
|   } catch (err) { | ||||
|     core.info('Unable to resolve a version from the manifest...'); | ||||
|     core.debug(err.message); | ||||
|     core.debug((err as Error).message); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| // for github hosted windows runner handle latency of OS drive
 | ||||
| // by avoiding write operations to C:
 | ||||
| async function cacheWindowsDir( | ||||
|   extPath: string, | ||||
|   tool: string, | ||||
|   version: string, | ||||
|   arch: string | ||||
| ): Promise<string | false> { | ||||
|   if (os.platform() !== 'win32') return false; | ||||
| 
 | ||||
|   // make sure the action runs in the hosted environment
 | ||||
|   if ( | ||||
|     process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted' && | ||||
|     process.env['AGENT_ISSELFHOSTED'] === '1' | ||||
|   ) | ||||
|     return false; | ||||
| 
 | ||||
|   const defaultToolCacheRoot = process.env['RUNNER_TOOL_CACHE']; | ||||
|   if (!defaultToolCacheRoot) return false; | ||||
| 
 | ||||
|   if (!fs.existsSync('d:\\') || !fs.existsSync('c:\\')) return false; | ||||
| 
 | ||||
|   const actualToolCacheRoot = defaultToolCacheRoot | ||||
|     .replace('C:', 'D:') | ||||
|     .replace('c:', 'd:'); | ||||
|   // make toolcache root to be on drive d:
 | ||||
|   process.env['RUNNER_TOOL_CACHE'] = actualToolCacheRoot; | ||||
| 
 | ||||
|   const actualToolCacheDir = await tc.cacheDir(extPath, tool, version, arch); | ||||
| 
 | ||||
|   // create a link from c: to d:
 | ||||
|   const defaultToolCacheDir = actualToolCacheDir.replace( | ||||
|     actualToolCacheRoot, | ||||
|     defaultToolCacheRoot | ||||
|   ); | ||||
|   fs.mkdirSync(path.dirname(defaultToolCacheDir), {recursive: true}); | ||||
|   fs.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction'); | ||||
|   core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`); | ||||
| 
 | ||||
|   const actualToolCacheCompleteFile = `${actualToolCacheDir}.complete`; | ||||
|   const defaultToolCacheCompleteFile = `${defaultToolCacheDir}.complete`; | ||||
|   fs.symlinkSync( | ||||
|     actualToolCacheCompleteFile, | ||||
|     defaultToolCacheCompleteFile, | ||||
|     'file' | ||||
|   ); | ||||
|   core.info( | ||||
|     `Created link ${defaultToolCacheCompleteFile} => ${actualToolCacheCompleteFile}` | ||||
|   ); | ||||
| 
 | ||||
|   // make outer code to continue using toolcache as if it were installed on c:
 | ||||
|   // restore toolcache root to default drive c:
 | ||||
|   process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot; | ||||
|   return defaultToolCacheDir; | ||||
| } | ||||
| 
 | ||||
| async function addExecutablesToToolCache( | ||||
|   extPath: string, | ||||
|   info: IGoVersionInfo, | ||||
|   arch: string | ||||
| ): Promise<string> { | ||||
|   const tool = 'go'; | ||||
|   const version = makeSemver(info.resolvedVersion); | ||||
|   return ( | ||||
|     (await cacheWindowsDir(extPath, tool, version, arch)) || | ||||
|     (await tc.cacheDir(extPath, tool, version, arch)) | ||||
|   ); | ||||
| } | ||||
| 
 | ||||
| async function installGoVersion( | ||||
|   info: IGoVersionInfo, | ||||
|   auth: string | undefined, | ||||
| @ -186,14 +260,10 @@ async function installGoVersion( | ||||
|   } | ||||
| 
 | ||||
|   core.info('Adding to the cache ...'); | ||||
|   const cachedDir = await tc.cacheDir( | ||||
|     extPath, | ||||
|     'go', | ||||
|     makeSemver(info.resolvedVersion), | ||||
|     arch | ||||
|   ); | ||||
|   core.info(`Successfully cached go to ${cachedDir}`); | ||||
|   return cachedDir; | ||||
|   const toolCacheDir = await addExecutablesToToolCache(extPath, info, arch); | ||||
|   core.info(`Successfully cached go to ${toolCacheDir}`); | ||||
| 
 | ||||
|   return toolCacheDir; | ||||
| } | ||||
| 
 | ||||
| export async function extractGoArchive(archivePath: string): Promise<string> { | ||||
| @ -209,8 +279,43 @@ export async function extractGoArchive(archivePath: string): Promise<string> { | ||||
|   return extPath; | ||||
| } | ||||
| 
 | ||||
| export async function getManifest(auth: string | undefined) { | ||||
|   return tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); | ||||
| export async function getManifest( | ||||
|   auth: string | undefined | ||||
| ): Promise<tc.IToolRelease[]> { | ||||
|   try { | ||||
|     return await getManifestFromRepo(auth); | ||||
|   } catch (err) { | ||||
|     core.debug('Fetching the manifest via the API failed.'); | ||||
|     if (err instanceof Error) { | ||||
|       core.debug(err.message); | ||||
|     } | ||||
|   } | ||||
|   return await getManifestFromURL(); | ||||
| } | ||||
| 
 | ||||
| function getManifestFromRepo( | ||||
|   auth: string | undefined | ||||
| ): Promise<tc.IToolRelease[]> { | ||||
|   core.debug( | ||||
|     `Getting manifest from ${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}@${MANIFEST_REPO_BRANCH}` | ||||
|   ); | ||||
|   return tc.getManifestFromRepo( | ||||
|     MANIFEST_REPO_OWNER, | ||||
|     MANIFEST_REPO_NAME, | ||||
|     auth, | ||||
|     MANIFEST_REPO_BRANCH | ||||
|   ); | ||||
| } | ||||
| 
 | ||||
| async function getManifestFromURL(): Promise<tc.IToolRelease[]> { | ||||
|   core.debug('Falling back to fetching the manifest using raw URL.'); | ||||
| 
 | ||||
|   const http: httpm.HttpClient = new httpm.HttpClient('tool-cache'); | ||||
|   const response = await http.getJson<tc.IToolRelease[]>(MANIFEST_URL); | ||||
|   if (!response.result) { | ||||
|     throw new Error(`Unable to get manifest from ${MANIFEST_URL}`); | ||||
|   } | ||||
|   return response.result; | ||||
| } | ||||
| 
 | ||||
| export async function getInfoFromManifest( | ||||
|  | ||||
| @ -74,7 +74,7 @@ export async function run() { | ||||
|           cacheDependencyPath | ||||
|         ); | ||||
|       } catch (error) { | ||||
|         core.warning(`Restore cache failed: ${error.message}`); | ||||
|         core.warning(`Restore cache failed: ${(error as Error).message}`); | ||||
|       } | ||||
|     } | ||||
| 
 | ||||
| @ -92,7 +92,7 @@ export async function run() { | ||||
|     core.info(goEnv); | ||||
|     core.endGroup(); | ||||
|   } catch (error) { | ||||
|     core.setFailed(error.message); | ||||
|     core.setFailed((error as Error).message); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user