mirror of
				https://github.com/actions/setup-go.git
				synced 2025-10-31 15:50:33 +00:00 
			
		
		
		
	Compare commits
	
		
			20 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | d0a58c1c4d | ||
|   | 3dcd9d6eb3 | ||
|   | e983b65a44 | ||
|   | 27b43e1b0d | ||
|   | 7678c83214 | ||
|   | c4a742cab1 | ||
|   | f556e5b7e0 | ||
|   | 514ae57904 | ||
|   | 30b9ddff11 | ||
|   | c4e169859f | ||
|   | db58e98a43 | ||
|   | 2905db4069 | ||
|   | 57452eb902 | ||
|   | 5547b9ed8d | ||
|   | be45b2722d | ||
|   | 4c32251b06 | ||
|   | e68a999c97 | ||
|   | b855b20887 | ||
|   | bf059911e8 | ||
|   | 884d2909a6 | 
| @@ -21,7 +21,7 @@ jobs: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - name: Update the ${{ env.TAG_NAME }} tag | ||||
|         uses: actions/publish-action@v0.1.0 | ||||
|         uses: actions/publish-action@v0.2.1 | ||||
|         with: | ||||
|           source-tag: ${{ env.TAG_NAME }} | ||||
|           slack-webhook: ${{ secrets.SLACK_WEBHOOK }} | ||||
|   | ||||
							
								
								
									
										18
									
								
								.github/workflows/versions.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								.github/workflows/versions.yml
									
									
									
									
										vendored
									
									
								
							| @@ -66,6 +66,22 @@ jobs: | ||||
|         run: __tests__/verify-go.sh 1.14 | ||||
|         shell: bash | ||||
|  | ||||
|   go-version-file-with-gowork: | ||||
|     runs-on: ${{ matrix.os }} | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v3 | ||||
|       - name: Setup Go and check latest | ||||
|         uses: ./ | ||||
|         with: | ||||
|           go-version-file: __tests__/data/go.work | ||||
|       - name: verify go | ||||
|         run: __tests__/verify-go.sh 1.19 | ||||
|         shell: bash | ||||
|  | ||||
|   setup-versions-from-manifest: | ||||
|     name: Setup ${{ matrix.go }} ${{ matrix.os }} | ||||
|     runs-on: ${{ matrix.os }} | ||||
| @@ -123,4 +139,4 @@ jobs: | ||||
|           go-version: ${{ matrix.go-version }} | ||||
|           architecture: x64 | ||||
|       - name: Verify Go | ||||
|         run: go version | ||||
|         run: go version | ||||
|   | ||||
							
								
								
									
										2
									
								
								.licenses/npm/@actions/core.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@actions/core.dep.yml
									
									
									
										generated
									
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| --- | ||||
| name: "@actions/core" | ||||
| version: 1.6.0 | ||||
| version: 1.10.0 | ||||
| type: npm | ||||
| summary: Actions core lib | ||||
| homepage: https://github.com/actions/toolkit/tree/main/packages/core | ||||
|   | ||||
							
								
								
									
										19
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								README.md
									
									
									
									
									
								
							| @@ -127,7 +127,7 @@ steps: | ||||
|   ``` | ||||
| ## Getting go version from the go.mod file | ||||
|  | ||||
| The `go-version-file` input accepts a path to a `go.mod` file containing 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 [version-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. 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 [version-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json) file or at the go servers. | ||||
|  | ||||
| If both the `go-version` and the `go-version-file` inputs are provided then the `go-version` input is used. | ||||
| > The action will search for the `go.mod` file relative to the repository root | ||||
| @@ -169,6 +169,21 @@ The `go-version` input supports the following syntax: | ||||
|  | ||||
| For more information about semantic versioning, please refer to [semver](https://github.com/npm/node-semver) 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. | ||||
|  | ||||
| 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: | ||||
|  | ||||
| ```yaml | ||||
| uses: actions/setup-go@v3 | ||||
| with: | ||||
|   token: ${{ secrets.GH_DOTCOM_TOKEN }} | ||||
|   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. 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. | ||||
|  | ||||
| # License | ||||
|  | ||||
| The scripts and documentation in this project are released under the [MIT License](LICENSE) | ||||
| @@ -179,4 +194,4 @@ Contributions are welcome! See [Contributor's Guide](docs/contributors.md) | ||||
|  | ||||
| ## Code of Conduct | ||||
|  | ||||
| :wave: Be nice. See [our code of conduct](CONDUCT) | ||||
| :wave: Be nice. See [our code of conduct](CODE_OF_CONDUCT.md) | ||||
|   | ||||
| @@ -17,6 +17,7 @@ describe('restoreCache', () => { | ||||
|   let infoSpy = jest.spyOn(core, 'info'); | ||||
|   let setOutputSpy = jest.spyOn(core, 'setOutput'); | ||||
|  | ||||
|   const versionSpec = '1.13.1'; | ||||
|   const packageManager = 'default'; | ||||
|   const cacheDependencyPath = 'path'; | ||||
|  | ||||
| @@ -40,7 +41,11 @@ describe('restoreCache', () => { | ||||
|  | ||||
|     //Act + Assert | ||||
|     expect(async () => { | ||||
|       await cacheRestore.restoreCache(packageManager, cacheDependencyPath); | ||||
|       await cacheRestore.restoreCache( | ||||
|         versionSpec, | ||||
|         packageManager, | ||||
|         cacheDependencyPath | ||||
|       ); | ||||
|     }).rejects.toThrowError( | ||||
|       'Some specified paths were not resolved, unable to cache dependencies.' | ||||
|     ); | ||||
| @@ -61,7 +66,11 @@ describe('restoreCache', () => { | ||||
|     }); | ||||
|  | ||||
|     //Act + Assert | ||||
|     await cacheRestore.restoreCache(packageManager, cacheDependencyPath); | ||||
|     await cacheRestore.restoreCache( | ||||
|       versionSpec, | ||||
|       packageManager, | ||||
|       cacheDependencyPath | ||||
|     ); | ||||
|     expect(infoSpy).toBeCalledWith(`Cache is not found`); | ||||
|   }); | ||||
|  | ||||
| @@ -80,7 +89,11 @@ describe('restoreCache', () => { | ||||
|     }); | ||||
|  | ||||
|     //Act + Assert | ||||
|     await cacheRestore.restoreCache(packageManager, cacheDependencyPath); | ||||
|     await cacheRestore.restoreCache( | ||||
|       versionSpec, | ||||
|       packageManager, | ||||
|       cacheDependencyPath | ||||
|     ); | ||||
|     expect(setOutputSpy).toBeCalledWith('cache-hit', true); | ||||
|   }); | ||||
| }); | ||||
|   | ||||
							
								
								
									
										3
									
								
								__tests__/data/go.work
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								__tests__/data/go.work
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| go 1.19 | ||||
|  | ||||
| use . | ||||
| @@ -295,7 +295,6 @@ describe('setup-go', () => { | ||||
|     findSpy.mockImplementation(() => toolPath); | ||||
|     await main.run(); | ||||
|  | ||||
|     let expPath = path.join(toolPath, 'bin'); | ||||
|     expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`); | ||||
|   }); | ||||
|  | ||||
| @@ -462,9 +461,6 @@ describe('setup-go', () => { | ||||
|     inputs['go-version'] = versionSpec; | ||||
|     inputs['token'] = 'faketoken'; | ||||
|  | ||||
|     let expectedUrl = | ||||
|       'https://github.com/actions/go-versions/releases/download/1.12.14-20200616.18/go-1.12.14-linux-x64.tar.gz'; | ||||
|  | ||||
|     // ... but not in the local cache | ||||
|     findSpy.mockImplementation(() => ''); | ||||
|  | ||||
| @@ -526,7 +522,7 @@ describe('setup-go', () => { | ||||
|     }); | ||||
|  | ||||
|     mkdirpSpy.mockImplementation(async () => {}); | ||||
|     existsSpy.mockImplementation(path => { | ||||
|     existsSpy.mockImplementation(() => { | ||||
|       return false; | ||||
|     }); | ||||
|  | ||||
| @@ -707,8 +703,6 @@ describe('setup-go', () => { | ||||
|       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(); | ||||
|  | ||||
| @@ -830,11 +824,17 @@ require ( | ||||
|  | ||||
| replace example.com/thatmodule => ../thatmodule | ||||
| exclude example.com/thismodule v1.3.0 | ||||
| `; | ||||
|  | ||||
|     const goWorkContents = `go 1.19 | ||||
|  | ||||
| use . | ||||
|  | ||||
| `; | ||||
|  | ||||
|     it('reads version from go.mod', async () => { | ||||
|       inputs['go-version-file'] = 'go.mod'; | ||||
|       existsSpy.mockImplementation(path => true); | ||||
|       existsSpy.mockImplementation(() => true); | ||||
|       readFileSpy.mockImplementation(() => Buffer.from(goModContents)); | ||||
|  | ||||
|       await main.run(); | ||||
| @@ -844,9 +844,21 @@ exclude example.com/thismodule v1.3.0 | ||||
|       expect(logSpy).toHaveBeenCalledWith('matching 1.14...'); | ||||
|     }); | ||||
|  | ||||
|     it('reads version from go.work', async () => { | ||||
|       inputs['go-version-file'] = 'go.work'; | ||||
|       existsSpy.mockImplementation(() => true); | ||||
|       readFileSpy.mockImplementation(() => Buffer.from(goWorkContents)); | ||||
|  | ||||
|       await main.run(); | ||||
|  | ||||
|       expect(logSpy).toHaveBeenCalledWith('Setup go version spec 1.19'); | ||||
|       expect(logSpy).toHaveBeenCalledWith('Attempting to download 1.19...'); | ||||
|       expect(logSpy).toHaveBeenCalledWith('matching 1.19...'); | ||||
|     }); | ||||
|  | ||||
|     it('reads version from .go-version', async () => { | ||||
|       inputs['go-version-file'] = '.go-version'; | ||||
|       existsSpy.mockImplementation(path => true); | ||||
|       existsSpy.mockImplementation(() => true); | ||||
|       readFileSpy.mockImplementation(() => Buffer.from(`1.13.0${osm.EOL}`)); | ||||
|  | ||||
|       await main.run(); | ||||
| @@ -859,7 +871,7 @@ exclude example.com/thismodule v1.3.0 | ||||
|     it('is overwritten by go-version', async () => { | ||||
|       inputs['go-version'] = '1.13.1'; | ||||
|       inputs['go-version-file'] = 'go.mod'; | ||||
|       existsSpy.mockImplementation(path => true); | ||||
|       existsSpy.mockImplementation(() => true); | ||||
|       readFileSpy.mockImplementation(() => Buffer.from(goModContents)); | ||||
|  | ||||
|       await main.run(); | ||||
| @@ -871,7 +883,7 @@ exclude example.com/thismodule v1.3.0 | ||||
|  | ||||
|     it('reports a read failure', async () => { | ||||
|       inputs['go-version-file'] = 'go.mod'; | ||||
|       existsSpy.mockImplementation(path => false); | ||||
|       existsSpy.mockImplementation(() => false); | ||||
|  | ||||
|       await main.run(); | ||||
|  | ||||
|   | ||||
							
								
								
									
										10
									
								
								action.yml
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								action.yml
									
									
									
									
									
								
							| @@ -5,13 +5,13 @@ inputs: | ||||
|   go-version: | ||||
|     description: 'The Go version to download (if necessary) and use. Supports semver spec and ranges.' | ||||
|   go-version-file: | ||||
|     description: 'Path to the go.mod 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. | ||||
|     default: ${{ github.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. | ||||
|     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. | ||||
|     default: false | ||||
| @@ -21,8 +21,8 @@ inputs: | ||||
|     description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.' | ||||
| outputs: | ||||
|   go-version: | ||||
|     description: 'The installed Go version. Useful when given a version range as input.'   | ||||
|   cache-hit:  | ||||
|     description: 'The installed Go version. Useful when given a version range as input.' | ||||
|   cache-hit: | ||||
|     description: 'A boolean value to indicate if a cache was hit' | ||||
| runs: | ||||
|   using: 'node16' | ||||
|   | ||||
							
								
								
									
										1730
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1730
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1725
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1725
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										47
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										47
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -1,16 +1,16 @@ | ||||
| { | ||||
|   "name": "setup-go", | ||||
|   "version": "1.0.0", | ||||
|   "version": "3.3.0", | ||||
|   "lockfileVersion": 2, | ||||
|   "requires": true, | ||||
|   "packages": { | ||||
|     "": { | ||||
|       "name": "setup-go", | ||||
|       "version": "1.0.0", | ||||
|       "version": "3.3.0", | ||||
|       "license": "MIT", | ||||
|       "dependencies": { | ||||
|         "@actions/cache": "^3.0.0", | ||||
|         "@actions/core": "^1.6.0", | ||||
|         "@actions/core": "^1.10.0", | ||||
|         "@actions/exec": "^1.1.0", | ||||
|         "@actions/glob": "^0.2.0", | ||||
|         "@actions/http-client": "^2.0.1", | ||||
| @@ -57,19 +57,20 @@ | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@actions/core": { | ||||
|       "version": "1.6.0", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz", | ||||
|       "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==", | ||||
|       "version": "1.10.0", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", | ||||
|       "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", | ||||
|       "dependencies": { | ||||
|         "@actions/http-client": "^1.0.11" | ||||
|         "@actions/http-client": "^2.0.1", | ||||
|         "uuid": "^8.3.2" | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@actions/core/node_modules/@actions/http-client": { | ||||
|       "version": "1.0.11", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", | ||||
|       "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", | ||||
|       "dependencies": { | ||||
|         "tunnel": "0.0.6" | ||||
|     "node_modules/@actions/core/node_modules/uuid": { | ||||
|       "version": "8.3.2", | ||||
|       "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", | ||||
|       "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", | ||||
|       "bin": { | ||||
|         "uuid": "dist/bin/uuid" | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@actions/exec": { | ||||
| @@ -4991,20 +4992,18 @@ | ||||
|       } | ||||
|     }, | ||||
|     "@actions/core": { | ||||
|       "version": "1.6.0", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz", | ||||
|       "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==", | ||||
|       "version": "1.10.0", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", | ||||
|       "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", | ||||
|       "requires": { | ||||
|         "@actions/http-client": "^1.0.11" | ||||
|         "@actions/http-client": "^2.0.1", | ||||
|         "uuid": "^8.3.2" | ||||
|       }, | ||||
|       "dependencies": { | ||||
|         "@actions/http-client": { | ||||
|           "version": "1.0.11", | ||||
|           "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", | ||||
|           "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", | ||||
|           "requires": { | ||||
|             "tunnel": "0.0.6" | ||||
|           } | ||||
|         "uuid": { | ||||
|           "version": "8.3.2", | ||||
|           "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", | ||||
|           "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "setup-go", | ||||
|   "version": "1.0.0", | ||||
|   "version": "3.3.0", | ||||
|   "private": true, | ||||
|   "description": "setup go action", | ||||
|   "main": "lib/setup-go.js", | ||||
| @@ -24,7 +24,7 @@ | ||||
|   "license": "MIT", | ||||
|   "dependencies": { | ||||
|     "@actions/cache": "^3.0.0", | ||||
|     "@actions/core": "^1.6.0", | ||||
|     "@actions/core": "^1.10.0", | ||||
|     "@actions/exec": "^1.1.0", | ||||
|     "@actions/glob": "^0.2.0", | ||||
|     "@actions/http-client": "^2.0.1", | ||||
|   | ||||
| @@ -9,12 +9,12 @@ import {PackageManagerInfo} from './package-managers'; | ||||
| import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils'; | ||||
|  | ||||
| export const restoreCache = async ( | ||||
|   versionSpec: string, | ||||
|   packageManager: string, | ||||
|   cacheDependencyPath?: string | ||||
| ) => { | ||||
|   const packageManagerInfo = await getPackageManagerInfo(packageManager); | ||||
|   const platform = process.env.RUNNER_OS; | ||||
|   const versionSpec = core.getInput('go-version'); | ||||
|  | ||||
|   const cachePaths = await getCacheDirectoryPath(packageManagerInfo); | ||||
|  | ||||
|   | ||||
| @@ -16,7 +16,14 @@ export async function run() { | ||||
|   try { | ||||
|     await cachePackages(); | ||||
|   } catch (error) { | ||||
|     core.setFailed(error.message); | ||||
|     let message = 'Unknown error!'; | ||||
|     if (error instanceof Error) { | ||||
|       message = error.message; | ||||
|     } | ||||
|     if (typeof error === 'string') { | ||||
|       message = error; | ||||
|     } | ||||
|     core.setFailed(message); | ||||
|   } | ||||
| } | ||||
|  | ||||
| @@ -40,7 +47,8 @@ const cachePackages = async () => { | ||||
|   ); | ||||
|  | ||||
|   if (nonExistingPaths.length === cachePaths.length) { | ||||
|     throw new Error(`There are no cache folders on the disk`); | ||||
|     core.warning('There are no cache folders on the disk'); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   if (nonExistingPaths.length) { | ||||
| @@ -65,7 +73,7 @@ const cachePackages = async () => { | ||||
|   core.info(`Cache saved with the key: ${primaryKey}`); | ||||
| }; | ||||
|  | ||||
| export function logWarning(message: string): void { | ||||
| function logWarning(message: string): void { | ||||
|   const warningPrefix = '[warning]'; | ||||
|   core.info(`${warningPrefix}${message}`); | ||||
| } | ||||
|   | ||||
| @@ -316,7 +316,10 @@ export function makeSemver(version: string): string { | ||||
| export function parseGoVersionFile(versionFilePath: string): string { | ||||
|   const contents = fs.readFileSync(versionFilePath).toString(); | ||||
|  | ||||
|   if (path.basename(versionFilePath) === 'go.mod') { | ||||
|   if ( | ||||
|     path.basename(versionFilePath) === 'go.mod' || | ||||
|     path.basename(versionFilePath) === 'go.work' | ||||
|   ) { | ||||
|     const match = contents.match(/^go (\d+(\.\d+)*)/m); | ||||
|     return match ? match[1] : ''; | ||||
|   } | ||||
|   | ||||
| @@ -28,7 +28,7 @@ export async function run() { | ||||
|  | ||||
|     if (versionSpec) { | ||||
|       let token = core.getInput('token'); | ||||
|       let auth = !token || isGhes() ? undefined : `token ${token}`; | ||||
|       let auth = !token ? undefined : `token ${token}`; | ||||
|  | ||||
|       const checkLatest = core.getBooleanInput('check-latest'); | ||||
|       const installDir = await installer.getGo( | ||||
| @@ -56,7 +56,7 @@ export async function run() { | ||||
|     if (cache && isCacheFeatureAvailable()) { | ||||
|       const packageManager = 'default'; | ||||
|       const cacheDependencyPath = core.getInput('cache-dependency-path'); | ||||
|       await restoreCache(packageManager, cacheDependencyPath); | ||||
|       await restoreCache(versionSpec, packageManager, cacheDependencyPath); | ||||
|     } | ||||
|  | ||||
|     // add problem matchers | ||||
|   | ||||
		Reference in New Issue
	
	Block a user