mirror of
https://github.com/actions/setup-go.git
synced 2025-05-04 14:14:34 +00:00
Fix Install on Windows is very slow (#393)
* Fix Install on Windows is very slow * Add unit test * Improve readability * Add e2e test * fix lint * Fix unit tests * Fix unit tests * limit to github hosted runners * test hosted version of go * AzDev environment * rename lnkSrc * refactor conditions * improve tests * refactoring * Fix e2e test * improve isHosted readability
This commit is contained in:
46
dist/setup/index.js
vendored
46
dist/setup/index.js
vendored
@ -61488,6 +61488,46 @@ function resolveVersionFromManifest(versionSpec, stable, auth, arch, manifest) {
|
||||
}
|
||||
});
|
||||
}
|
||||
// for github hosted windows runner handle latency of OS drive
|
||||
// by avoiding write operations to C:
|
||||
function cacheWindowsDir(extPath, tool, version, arch) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (os_1.default.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_1.default.existsSync('d:\\') || !fs_1.default.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 = yield tc.cacheDir(extPath, tool, version, arch);
|
||||
// create a link from c: to d:
|
||||
const defaultToolCacheDir = actualToolCacheDir.replace(actualToolCacheRoot, defaultToolCacheRoot);
|
||||
fs_1.default.mkdirSync(path.dirname(defaultToolCacheDir), { recursive: true });
|
||||
fs_1.default.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction');
|
||||
core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`);
|
||||
// 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;
|
||||
});
|
||||
}
|
||||
function addExecutablesToToolCache(extPath, info, arch) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const tool = 'go';
|
||||
const version = makeSemver(info.resolvedVersion);
|
||||
return ((yield cacheWindowsDir(extPath, tool, version, arch)) ||
|
||||
(yield tc.cacheDir(extPath, tool, version, arch)));
|
||||
});
|
||||
}
|
||||
function installGoVersion(info, auth, arch) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
||||
@ -61503,9 +61543,9 @@ function installGoVersion(info, auth, arch) {
|
||||
extPath = path.join(extPath, 'go');
|
||||
}
|
||||
core.info('Adding to the cache ...');
|
||||
const cachedDir = yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion), arch);
|
||||
core.info(`Successfully cached go to ${cachedDir}`);
|
||||
return cachedDir;
|
||||
const toolCacheDir = yield addExecutablesToToolCache(extPath, info, arch);
|
||||
core.info(`Successfully cached go to ${toolCacheDir}`);
|
||||
return toolCacheDir;
|
||||
});
|
||||
}
|
||||
function extractGoArchive(archivePath) {
|
||||
|
Reference in New Issue
Block a user