mirror of https://github.com/actions/setup-go.git
				
				
				
			squash! Configure environment to avoid toolchain installs
Only modify env if `GOTOOLCHAIN` is not set
This commit is contained in:
		
							parent
							
								
									7252af563b
								
							
						
					
					
						commit
						277ab1eb0e
					
				|  | @ -94312,6 +94312,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | ||||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; |     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||||
| }; | }; | ||||||
| Object.defineProperty(exports, "__esModule", ({ value: true })); | Object.defineProperty(exports, "__esModule", ({ value: true })); | ||||||
|  | exports.GOTOOLCHAIN_LOCAL_VAL = exports.GOTOOLCHAIN_ENV_VAR = void 0; | ||||||
| exports.getGo = getGo; | exports.getGo = getGo; | ||||||
| exports.extractGoArchive = extractGoArchive; | exports.extractGoArchive = extractGoArchive; | ||||||
| exports.getManifest = getManifest; | exports.getManifest = getManifest; | ||||||
|  | @ -94330,6 +94331,8 @@ const sys = __importStar(__nccwpck_require__(5632)); | ||||||
| const fs_1 = __importDefault(__nccwpck_require__(7147)); | const fs_1 = __importDefault(__nccwpck_require__(7147)); | ||||||
| const os_1 = __importDefault(__nccwpck_require__(2037)); | const os_1 = __importDefault(__nccwpck_require__(2037)); | ||||||
| const utils_1 = __nccwpck_require__(1314); | const utils_1 = __nccwpck_require__(1314); | ||||||
|  | exports.GOTOOLCHAIN_ENV_VAR = 'GOTOOLCHAIN'; | ||||||
|  | exports.GOTOOLCHAIN_LOCAL_VAL = 'local'; | ||||||
| const MANIFEST_REPO_OWNER = 'actions'; | const MANIFEST_REPO_OWNER = 'actions'; | ||||||
| const MANIFEST_REPO_NAME = 'go-versions'; | const MANIFEST_REPO_NAME = 'go-versions'; | ||||||
| const MANIFEST_REPO_BRANCH = 'main'; | const MANIFEST_REPO_BRANCH = 'main'; | ||||||
|  | @ -94783,12 +94786,12 @@ const os_1 = __importDefault(__nccwpck_require__(2037)); | ||||||
| function run() { | function run() { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         try { |         try { | ||||||
|             setToolchain(); |  | ||||||
|             //
 |             //
 | ||||||
|             // versionSpec is optional.  If supplied, install / use from the tool cache
 |             // versionSpec is optional.  If supplied, install / use from the tool cache
 | ||||||
|             // If not supplied then problem matchers will still be setup.  Useful for self-hosted.
 |             // If not supplied then problem matchers will still be setup.  Useful for self-hosted.
 | ||||||
|             //
 |             //
 | ||||||
|             const versionSpec = resolveVersionInput(); |             const versionSpec = resolveVersionInput(); | ||||||
|  |             setGoToolchain(); | ||||||
|             const cache = core.getBooleanInput('cache'); |             const cache = core.getBooleanInput('cache'); | ||||||
|             core.info(`Setup go version spec ${versionSpec}`); |             core.info(`Setup go version spec ${versionSpec}`); | ||||||
|             let arch = core.getInput('architecture'); |             let arch = core.getInput('architecture'); | ||||||
|  | @ -94897,20 +94900,18 @@ function resolveVersionInput() { | ||||||
|     } |     } | ||||||
|     return version; |     return version; | ||||||
| } | } | ||||||
| function setToolchain() { | function setGoToolchain() { | ||||||
|     // docs: https://go.dev/doc/toolchain
 |     // docs: https://go.dev/doc/toolchain
 | ||||||
|     // "local indicates the bundled Go toolchain (the one that shipped with the go command being run)"
 |     // "local indicates the bundled Go toolchain (the one that shipped with the go command being run)"
 | ||||||
|     // this is so any 'go' command is run with the selected Go version
 |     // this is so any 'go' command is run with the selected Go version
 | ||||||
|     // and doesn't trigger a toolchain download and run commands with that
 |     // and doesn't trigger a toolchain download and run commands with that
 | ||||||
|     // see e.g. issue #424
 |     // see e.g. issue #424
 | ||||||
|     // and a similar discussion: https://github.com/docker-library/golang/issues/472
 |     // and a similar discussion: https://github.com/docker-library/golang/issues/472.
 | ||||||
|     const toolchain = 'local'; |     // Set the value in process env so any `go` commands run as child-process
 | ||||||
|     const toolchainVar = 'GOTOOLCHAIN'; |  | ||||||
|     // set the value in process env so any `go` commands run as child-process
 |  | ||||||
|     // don't cause toolchain downloads
 |     // don't cause toolchain downloads
 | ||||||
|     process.env[toolchainVar] = toolchain; |     process.env[installer.GOTOOLCHAIN_ENV_VAR] = installer.GOTOOLCHAIN_LOCAL_VAL; | ||||||
|     // and in the runner env so e.g. a user running `go mod tidy` won't cause it
 |     // and in the runner env so e.g. a user running `go mod tidy` won't cause it
 | ||||||
|     core.exportVariable(toolchainVar, toolchain); |     core.exportVariable(installer.GOTOOLCHAIN_ENV_VAR, installer.GOTOOLCHAIN_LOCAL_VAL); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -8,6 +8,8 @@ import fs from 'fs'; | ||||||
| import os from 'os'; | import os from 'os'; | ||||||
| import {StableReleaseAlias, isSelfHosted} from './utils'; | import {StableReleaseAlias, isSelfHosted} from './utils'; | ||||||
| 
 | 
 | ||||||
|  | export const GOTOOLCHAIN_ENV_VAR = 'GOTOOLCHAIN'; | ||||||
|  | export const GOTOOLCHAIN_LOCAL_VAL = 'local'; | ||||||
| const MANIFEST_REPO_OWNER = 'actions'; | const MANIFEST_REPO_OWNER = 'actions'; | ||||||
| const MANIFEST_REPO_NAME = 'go-versions'; | const MANIFEST_REPO_NAME = 'go-versions'; | ||||||
| const MANIFEST_REPO_BRANCH = 'main'; | const MANIFEST_REPO_BRANCH = 'main'; | ||||||
|  |  | ||||||
							
								
								
									
										18
									
								
								src/main.ts
								
								
								
								
							
							
						
						
									
										18
									
								
								src/main.ts
								
								
								
								
							|  | @ -11,12 +11,12 @@ import os from 'os'; | ||||||
| 
 | 
 | ||||||
| export async function run() { | export async function run() { | ||||||
|   try { |   try { | ||||||
|     setToolchain(); |  | ||||||
|     //
 |     //
 | ||||||
|     // versionSpec is optional.  If supplied, install / use from the tool cache
 |     // versionSpec is optional.  If supplied, install / use from the tool cache
 | ||||||
|     // If not supplied then problem matchers will still be setup.  Useful for self-hosted.
 |     // If not supplied then problem matchers will still be setup.  Useful for self-hosted.
 | ||||||
|     //
 |     //
 | ||||||
|     const versionSpec = resolveVersionInput(); |     const versionSpec = resolveVersionInput(); | ||||||
|  |     setGoToolchain(); | ||||||
| 
 | 
 | ||||||
|     const cache = core.getBooleanInput('cache'); |     const cache = core.getBooleanInput('cache'); | ||||||
|     core.info(`Setup go version spec ${versionSpec}`); |     core.info(`Setup go version spec ${versionSpec}`); | ||||||
|  | @ -162,19 +162,19 @@ function resolveVersionInput(): string { | ||||||
|   return version; |   return version; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function setToolchain() { | function setGoToolchain() { | ||||||
|   // docs: https://go.dev/doc/toolchain
 |   // docs: https://go.dev/doc/toolchain
 | ||||||
|   // "local indicates the bundled Go toolchain (the one that shipped with the go command being run)"
 |   // "local indicates the bundled Go toolchain (the one that shipped with the go command being run)"
 | ||||||
|   // this is so any 'go' command is run with the selected Go version
 |   // this is so any 'go' command is run with the selected Go version
 | ||||||
|   // and doesn't trigger a toolchain download and run commands with that
 |   // and doesn't trigger a toolchain download and run commands with that
 | ||||||
|   // see e.g. issue #424
 |   // see e.g. issue #424
 | ||||||
|   // and a similar discussion: https://github.com/docker-library/golang/issues/472
 |   // and a similar discussion: https://github.com/docker-library/golang/issues/472.
 | ||||||
|   const toolchain = 'local'; |   // Set the value in process env so any `go` commands run as child-process
 | ||||||
|   const toolchainVar = 'GOTOOLCHAIN'; |  | ||||||
| 
 |  | ||||||
|   // set the value in process env so any `go` commands run as child-process
 |  | ||||||
|   // don't cause toolchain downloads
 |   // don't cause toolchain downloads
 | ||||||
|   process.env[toolchainVar] = toolchain; |   process.env[installer.GOTOOLCHAIN_ENV_VAR] = installer.GOTOOLCHAIN_LOCAL_VAL; | ||||||
|   // and in the runner env so e.g. a user running `go mod tidy` won't cause it
 |   // and in the runner env so e.g. a user running `go mod tidy` won't cause it
 | ||||||
|   core.exportVariable(toolchainVar, toolchain); |   core.exportVariable( | ||||||
|  |     installer.GOTOOLCHAIN_ENV_VAR, | ||||||
|  |     installer.GOTOOLCHAIN_LOCAL_VAL | ||||||
|  |   ); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Matthew Hughes
						Matthew Hughes