@@ -61488,6 +61488,46 @@ function resolveVersionFromManifest(versionSpec, stable, auth, arch, manifest) {
6148861488 }
6148961489 });
6149061490}
61491+ // for github hosted windows runner handle latency of OS drive
61492+ // by avoiding write operations to C:
61493+ function cacheWindowsDir(extPath, tool, version, arch) {
61494+ return __awaiter(this, void 0, void 0, function* () {
61495+ if (os_1.default.platform() !== 'win32')
61496+ return false;
61497+ // make sure the action runs in the hosted environment
61498+ if (process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted' &&
61499+ process.env['AGENT_ISSELFHOSTED'] === '1')
61500+ return false;
61501+ const defaultToolCacheRoot = process.env['RUNNER_TOOL_CACHE'];
61502+ if (!defaultToolCacheRoot)
61503+ return false;
61504+ if (!fs_1.default.existsSync('d:\\') || !fs_1.default.existsSync('c:\\'))
61505+ return false;
61506+ const actualToolCacheRoot = defaultToolCacheRoot
61507+ .replace('C:', 'D:')
61508+ .replace('c:', 'd:');
61509+ // make toolcache root to be on drive d:
61510+ process.env['RUNNER_TOOL_CACHE'] = actualToolCacheRoot;
61511+ const actualToolCacheDir = yield tc.cacheDir(extPath, tool, version, arch);
61512+ // create a link from c: to d:
61513+ const defaultToolCacheDir = actualToolCacheDir.replace(actualToolCacheRoot, defaultToolCacheRoot);
61514+ fs_1.default.mkdirSync(path.dirname(defaultToolCacheDir), { recursive: true });
61515+ fs_1.default.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction');
61516+ core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`);
61517+ // make outer code to continue using toolcache as if it were installed on c:
61518+ // restore toolcache root to default drive c:
61519+ process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot;
61520+ return defaultToolCacheDir;
61521+ });
61522+ }
61523+ function addExecutablesToToolCache(extPath, info, arch) {
61524+ return __awaiter(this, void 0, void 0, function* () {
61525+ const tool = 'go';
61526+ const version = makeSemver(info.resolvedVersion);
61527+ return ((yield cacheWindowsDir(extPath, tool, version, arch)) ||
61528+ (yield tc.cacheDir(extPath, tool, version, arch)));
61529+ });
61530+ }
6149161531function installGoVersion(info, auth, arch) {
6149261532 return __awaiter(this, void 0, void 0, function* () {
6149361533 core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
@@ -61503,9 +61543,9 @@ function installGoVersion(info, auth, arch) {
6150361543 extPath = path.join(extPath, 'go');
6150461544 }
6150561545 core.info('Adding to the cache ...');
61506- const cachedDir = yield tc.cacheDir (extPath, 'go', makeSemver( info.resolvedVersion) , arch);
61507- core.info(`Successfully cached go to ${cachedDir }`);
61508- return cachedDir ;
61546+ const toolCacheDir = yield addExecutablesToToolCache (extPath, info, arch);
61547+ core.info(`Successfully cached go to ${toolCacheDir }`);
61548+ return toolCacheDir ;
6150961549 });
6151061550}
6151161551function extractGoArchive(archivePath) {
0 commit comments