mirror of
https://github.com/actions/setup-go.git
synced 2025-04-23 17:40:50 +00:00
Fix Install on Windows is very slow
This commit is contained in:
parent
08b314a573
commit
930ff22596
2 changed files with 57 additions and 13 deletions
27
dist/setup/index.js
vendored
27
dist/setup/index.js
vendored
|
@ -61441,6 +61441,14 @@ function resolveVersionFromManifest(versionSpec, stable, auth, arch, manifest) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function addExecutablesToCache(extPath, info, arch) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
}
|
||||||
function installGoVersion(info, auth, arch) {
|
function installGoVersion(info, auth, arch) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
||||||
|
@ -61455,10 +61463,21 @@ function installGoVersion(info, auth, arch) {
|
||||||
if (info.type === 'dist') {
|
if (info.type === 'dist') {
|
||||||
extPath = path.join(extPath, 'go');
|
extPath = path.join(extPath, 'go');
|
||||||
}
|
}
|
||||||
core.info('Adding to the cache ...');
|
if (isWindows) {
|
||||||
const cachedDir = yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion), arch);
|
const oldCacheDir = process.env['RUNNER_TOOL_CACHE'] || '';
|
||||||
core.info(`Successfully cached go to ${cachedDir}`);
|
const tempCacheDir = oldCacheDir.replace('C:', 'D:').replace('c:', 'd:');
|
||||||
return cachedDir;
|
process.env['RUNNER_TOOL_CACHE'] = tempCacheDir;
|
||||||
|
const cachedDir = yield addExecutablesToCache(extPath, info, arch);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
return yield addExecutablesToCache(extPath, info, arch);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function extractGoArchive(archivePath) {
|
function extractGoArchive(archivePath) {
|
||||||
|
|
|
@ -164,6 +164,22 @@ async function resolveVersionFromManifest(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function addExecutablesToCache(
|
||||||
|
extPath: string,
|
||||||
|
info: IGoVersionInfo,
|
||||||
|
arch: string
|
||||||
|
): Promise<string> {
|
||||||
|
core.info('Adding to the cache ...');
|
||||||
|
const cachedDir = await tc.cacheDir(
|
||||||
|
extPath,
|
||||||
|
'go',
|
||||||
|
makeSemver(info.resolvedVersion),
|
||||||
|
arch
|
||||||
|
);
|
||||||
|
core.info(`Successfully cached go to ${cachedDir}`);
|
||||||
|
return cachedDir;
|
||||||
|
}
|
||||||
|
|
||||||
async function installGoVersion(
|
async function installGoVersion(
|
||||||
info: IGoVersionInfo,
|
info: IGoVersionInfo,
|
||||||
auth: string | undefined,
|
auth: string | undefined,
|
||||||
|
@ -185,15 +201,24 @@ async function installGoVersion(
|
||||||
extPath = path.join(extPath, 'go');
|
extPath = path.join(extPath, 'go');
|
||||||
}
|
}
|
||||||
|
|
||||||
core.info('Adding to the cache ...');
|
if (isWindows) {
|
||||||
const cachedDir = await tc.cacheDir(
|
const oldCacheDir = process.env['RUNNER_TOOL_CACHE'] || '';
|
||||||
extPath,
|
const tempCacheDir = oldCacheDir.replace('C:', 'D:').replace('c:', 'd:');
|
||||||
'go',
|
process.env['RUNNER_TOOL_CACHE'] = tempCacheDir;
|
||||||
makeSemver(info.resolvedVersion),
|
|
||||||
arch
|
const cachedDir = await addExecutablesToCache(extPath, info, arch);
|
||||||
);
|
|
||||||
core.info(`Successfully cached go to ${cachedDir}`);
|
const lnkDest = cachedDir;
|
||||||
return 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await addExecutablesToCache(extPath, info, arch);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function extractGoArchive(archivePath: string): Promise<string> {
|
export async function extractGoArchive(archivePath: string): Promise<string> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue