Skip to content

Commit

Permalink
Fix Install on Windows is very slow
Browse files Browse the repository at this point in the history
  • Loading branch information
dsame committed Jul 11, 2023
1 parent 08b314a commit c820c9c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 12 additions & 1 deletion dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61455,10 +61455,21 @@ function installGoVersion(info, auth, arch) {
if (info.type === 'dist') {
extPath = path.join(extPath, 'go');
}
const oldCacheDir = process.env['RUNNER_TOOL_CACHE'] || '';
const tempCacheDir = oldCacheDir.replace('C:', 'D:').replace('c:', 'd:');
core.debug(`toolcache dirs: ${oldCacheDir} -> ${tempCacheDir}`);
process.env['RUNNER_TOOL_CACHE'] = tempCacheDir;
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 lnkDest = cachedDir;
const lnkSrc = lnkDest.replace(tempCacheDir, oldCacheDir);
const lnkSrcDir = path.dirname(lnkSrc);
fs_1.default.mkdirSync(lnkSrcDir, { recursive: true });
fs_1.default.symlinkSync(lnkDest, lnkSrc, 'junction');
core.info(`Created link ${lnkSrc} => ${lnkDest}`);
process.env['RUNNER_TOOL_CACHE'] = oldCacheDir;
return cachedDir.replace(tempCacheDir, oldCacheDir);
});
}
function extractGoArchive(archivePath) {
Expand Down
13 changes: 12 additions & 1 deletion src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ async function installGoVersion(
extPath = path.join(extPath, 'go');
}

const oldCacheDir = process.env['RUNNER_TOOL_CACHE'] || ''
const tempCacheDir = oldCacheDir.replace('C:', 'D:').replace('c:', 'd:')
process.env['RUNNER_TOOL_CACHE'] = tempCacheDir;

core.info('Adding to the cache ...');
const cachedDir = await tc.cacheDir(
extPath,
Expand All @@ -193,7 +197,14 @@ async function installGoVersion(
arch
);
core.info(`Successfully cached go to ${cachedDir}`);
return cachedDir;
const lnkDest = cachedDir
const lnkSrc = lnkDest.replace(tempCacheDir, oldCacheDir)
const lnkSrcDir = path.dirname(lnkSrc)
fs.mkdirSync(lnkSrcDir, {recursive: true})
fs.symlinkSync(lnkDest, lnkSrc, 'junction')
core.info(`Created link ${lnkSrc} => ${lnkDest}`);
process.env['RUNNER_TOOL_CACHE'] = oldCacheDir;
return cachedDir.replace(tempCacheDir, oldCacheDir);
}

export async function extractGoArchive(archivePath: string): Promise<string> {
Expand Down

0 comments on commit c820c9c

Please sign in to comment.