diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 19f39d251..30f55084c 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -58600,8 +58600,8 @@ const cache = __importStar(__nccwpck_require__(7799)); const core = __importStar(__nccwpck_require__(2186)); const exec = __importStar(__nccwpck_require__(1514)); const package_managers_1 = __nccwpck_require__(6663); -const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { - let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); +const getCommandOutput = (toolCommand, execOpts) => __awaiter(void 0, void 0, void 0, function* () { + let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, Object.assign(Object.assign({}, execOpts), { ignoreReturnCode: true })); if (exitCode) { stderr = !stderr.trim() ? `The '${toolCommand}' command failed with exit code: ${exitCode}` @@ -58619,8 +58619,8 @@ const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void return obtainedPackageManager; }); exports.getPackageManagerInfo = getPackageManagerInfo; -const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { - const pathOutputs = yield Promise.allSettled(packageManagerInfo.cacheFolderCommandList.map((command) => __awaiter(void 0, void 0, void 0, function* () { return exports.getCommandOutput(command); }))); +const getCacheDirectoryPath = (packageManagerInfo, execOpts) => __awaiter(void 0, void 0, void 0, function* () { + const pathOutputs = yield Promise.allSettled(packageManagerInfo.cacheFolderCommandList.map((command) => __awaiter(void 0, void 0, void 0, function* () { return exports.getCommandOutput(command, execOpts); }))); const results = pathOutputs.map(item => { if (item.status === 'fulfilled') { return item.value; diff --git a/dist/setup/index.js b/dist/setup/index.js index 25798ccb6..7d7e5c4bc 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -61194,7 +61194,9 @@ const cache_utils_1 = __nccwpck_require__(1678); const restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); const platform = process.env.RUNNER_OS; - const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); + const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo, { + env: Object.assign(Object.assign({}, process.env), { GOTOOLCHAIN: 'local' }) + }); const dependencyFilePath = cacheDependencyPath ? cacheDependencyPath : findDependencyFile(packageManagerInfo); @@ -61270,8 +61272,8 @@ const cache = __importStar(__nccwpck_require__(7799)); const core = __importStar(__nccwpck_require__(2186)); const exec = __importStar(__nccwpck_require__(1514)); const package_managers_1 = __nccwpck_require__(6663); -const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { - let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); +const getCommandOutput = (toolCommand, execOpts) => __awaiter(void 0, void 0, void 0, function* () { + let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, Object.assign(Object.assign({}, execOpts), { ignoreReturnCode: true })); if (exitCode) { stderr = !stderr.trim() ? `The '${toolCommand}' command failed with exit code: ${exitCode}` @@ -61289,8 +61291,8 @@ const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void return obtainedPackageManager; }); exports.getPackageManagerInfo = getPackageManagerInfo; -const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { - const pathOutputs = yield Promise.allSettled(packageManagerInfo.cacheFolderCommandList.map((command) => __awaiter(void 0, void 0, void 0, function* () { return exports.getCommandOutput(command); }))); +const getCacheDirectoryPath = (packageManagerInfo, execOpts) => __awaiter(void 0, void 0, void 0, function* () { + const pathOutputs = yield Promise.allSettled(packageManagerInfo.cacheFolderCommandList.map((command) => __awaiter(void 0, void 0, void 0, function* () { return exports.getCommandOutput(command, execOpts); }))); const results = pathOutputs.map(item => { if (item.status === 'fulfilled') { return item.value; @@ -61817,7 +61819,11 @@ function run() { const added = yield addBinToPath(); core.debug(`add bin ${added}`); const goPath = yield io.which('go'); - const goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString(); + // run `go version` with the bundled Go toolchain to avoid potentially + // downloading one into the cache + const goVersion = (child_process_1.default.execSync(`${goPath} version`, { + env: Object.assign(Object.assign({}, process.env), { GOTOOLCHAIN: 'local' }) + }) || '').toString(); if (cache && cache_utils_1.isCacheFeatureAvailable()) { const packageManager = 'default'; const cacheDependencyPath = core.getInput('cache-dependency-path'); @@ -61854,7 +61860,9 @@ function addBinToPath() { core.debug('go not in the path'); return added; } - const buf = child_process_1.default.execSync('go env GOPATH'); + const buf = child_process_1.default.execSync('go env GOPATH', { + env: Object.assign(Object.assign({}, process.env), { GOTOOLCHAIN: 'local' }) + }); if (buf.length > 1) { const gp = buf.toString().trim(); core.debug(`go env GOPATH :${gp}:`); diff --git a/src/cache-restore.ts b/src/cache-restore.ts index 183df9ea5..82560341b 100644 --- a/src/cache-restore.ts +++ b/src/cache-restore.ts @@ -16,7 +16,9 @@ export const restoreCache = async ( const packageManagerInfo = await getPackageManagerInfo(packageManager); const platform = process.env.RUNNER_OS; - const cachePaths = await getCacheDirectoryPath(packageManagerInfo); + const cachePaths = await getCacheDirectoryPath(packageManagerInfo, { + env: {...process.env, GOTOOLCHAIN: 'local'} + }); const dependencyFilePath = cacheDependencyPath ? cacheDependencyPath diff --git a/src/cache-utils.ts b/src/cache-utils.ts index 545c97af1..c5a718cd4 100644 --- a/src/cache-utils.ts +++ b/src/cache-utils.ts @@ -3,11 +3,14 @@ import * as core from '@actions/core'; import * as exec from '@actions/exec'; import {supportedPackageManagers, PackageManagerInfo} from './package-managers'; -export const getCommandOutput = async (toolCommand: string) => { +export const getCommandOutput = async ( + toolCommand: string, + execOpts?: exec.ExecOptions +) => { let {stdout, stderr, exitCode} = await exec.getExecOutput( toolCommand, undefined, - {ignoreReturnCode: true} + {...execOpts, ignoreReturnCode: true} ); if (exitCode) { @@ -32,11 +35,12 @@ export const getPackageManagerInfo = async (packageManager: string) => { }; export const getCacheDirectoryPath = async ( - packageManagerInfo: PackageManagerInfo + packageManagerInfo: PackageManagerInfo, + execOpts?: exec.ExecOptions ) => { const pathOutputs = await Promise.allSettled( packageManagerInfo.cacheFolderCommandList.map(async command => - getCommandOutput(command) + getCommandOutput(command, execOpts) ) ); diff --git a/src/main.ts b/src/main.ts index d3fb857df..e62b28b0a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -62,7 +62,13 @@ export async function run() { core.debug(`add bin ${added}`); const goPath = await io.which('go'); - const goVersion = (cp.execSync(`${goPath} version`) || '').toString(); + // run `go version` with the bundled Go toolchain to avoid potentially + // downloading one into the cache + const goVersion = ( + cp.execSync(`${goPath} version`, { + env: {...process.env, GOTOOLCHAIN: 'local'} + }) || '' + ).toString(); if (cache && isCacheFeatureAvailable()) { const packageManager = 'default'; @@ -105,7 +111,9 @@ export async function addBinToPath(): Promise { return added; } - const buf = cp.execSync('go env GOPATH'); + const buf = cp.execSync('go env GOPATH', { + env: {...process.env, GOTOOLCHAIN: 'local'} + }); if (buf.length > 1) { const gp = buf.toString().trim(); core.debug(`go env GOPATH :${gp}:`);