mirror of
https://github.com/actions/setup-go.git
synced 2025-04-23 17:40:50 +00:00
refactor conditions
This commit is contained in:
parent
00f551b2d1
commit
8998c6804e
2 changed files with 50 additions and 49 deletions
45
dist/setup/index.js
vendored
45
dist/setup/index.js
vendored
|
@ -61466,31 +61466,32 @@ function installGoVersion(info, auth, arch) {
|
||||||
}
|
}
|
||||||
// for github hosted windows runner handle latency of OS drive
|
// for github hosted windows runner handle latency of OS drive
|
||||||
// by avoiding write operations to C:
|
// by avoiding write operations to C:
|
||||||
|
if (!isWindows)
|
||||||
|
return addExecutablesToCache(extPath, info, arch);
|
||||||
const isHosted = process.env['RUNNER_ENVIRONMENT'] === 'github-hosted' ||
|
const isHosted = process.env['RUNNER_ENVIRONMENT'] === 'github-hosted' ||
|
||||||
process.env['AGENT_ISSELFHOSTED'] === '0';
|
process.env['AGENT_ISSELFHOSTED'] === '0';
|
||||||
|
if (!isHosted)
|
||||||
|
return addExecutablesToCache(extPath, info, arch);
|
||||||
const defaultToolCacheRoot = process.env['RUNNER_TOOL_CACHE'];
|
const defaultToolCacheRoot = process.env['RUNNER_TOOL_CACHE'];
|
||||||
if (isWindows &&
|
if (!defaultToolCacheRoot)
|
||||||
defaultToolCacheRoot &&
|
return addExecutablesToCache(extPath, info, arch);
|
||||||
isHosted &&
|
if (!fs_1.default.existsSync('d:\\') || !fs_1.default.existsSync('c:\\'))
|
||||||
fs_1.default.existsSync('d:\\') &&
|
return addExecutablesToCache(extPath, info, arch);
|
||||||
fs_1.default.existsSync('c:\\')) {
|
const substitutedToolCacheRoot = defaultToolCacheRoot
|
||||||
const substitutedToolCacheRoot = defaultToolCacheRoot
|
.replace('C:', 'D:')
|
||||||
.replace('C:', 'D:')
|
.replace('c:', 'd:');
|
||||||
.replace('c:', 'd:');
|
// make toolcache root to be on drive d:
|
||||||
// make toolcache root to be on drive d:
|
process.env['RUNNER_TOOL_CACHE'] = substitutedToolCacheRoot;
|
||||||
process.env['RUNNER_TOOL_CACHE'] = substitutedToolCacheRoot;
|
const actualToolCacheDir = yield addExecutablesToCache(extPath, info, arch);
|
||||||
const actualToolCacheDir = yield addExecutablesToCache(extPath, info, arch);
|
// create a link from c: to d:
|
||||||
// create a link from c: to d:
|
const defaultToolCacheDir = actualToolCacheDir.replace(substitutedToolCacheRoot, defaultToolCacheRoot);
|
||||||
const defaultToolCacheDir = actualToolCacheDir.replace(substitutedToolCacheRoot, defaultToolCacheRoot);
|
fs_1.default.mkdirSync(path.dirname(defaultToolCacheDir), { recursive: true });
|
||||||
fs_1.default.mkdirSync(path.dirname(defaultToolCacheDir), { recursive: true });
|
fs_1.default.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction');
|
||||||
fs_1.default.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction');
|
core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`);
|
||||||
core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`);
|
// restore toolcache root to default drive c:
|
||||||
// restore toolcache root to default drive c:
|
process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot;
|
||||||
process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot;
|
// make outer code to continue using toolcache as if it were installed on c:
|
||||||
// make outer code to continue using toolcache as if it were installed on c:
|
return defaultToolCacheDir;
|
||||||
return defaultToolCacheDir;
|
|
||||||
}
|
|
||||||
return yield addExecutablesToCache(extPath, info, arch);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function extractGoArchive(archivePath) {
|
function extractGoArchive(archivePath) {
|
||||||
|
|
|
@ -203,42 +203,42 @@ async function installGoVersion(
|
||||||
|
|
||||||
// for github hosted windows runner handle latency of OS drive
|
// for github hosted windows runner handle latency of OS drive
|
||||||
// by avoiding write operations to C:
|
// by avoiding write operations to C:
|
||||||
|
|
||||||
|
if (!isWindows) return addExecutablesToCache(extPath, info, arch);
|
||||||
|
|
||||||
const isHosted =
|
const isHosted =
|
||||||
process.env['RUNNER_ENVIRONMENT'] === 'github-hosted' ||
|
process.env['RUNNER_ENVIRONMENT'] === 'github-hosted' ||
|
||||||
process.env['AGENT_ISSELFHOSTED'] === '0';
|
process.env['AGENT_ISSELFHOSTED'] === '0';
|
||||||
|
if (!isHosted) return addExecutablesToCache(extPath, info, arch);
|
||||||
|
|
||||||
const defaultToolCacheRoot = process.env['RUNNER_TOOL_CACHE'];
|
const defaultToolCacheRoot = process.env['RUNNER_TOOL_CACHE'];
|
||||||
if (
|
if (!defaultToolCacheRoot) return addExecutablesToCache(extPath, info, arch);
|
||||||
isWindows &&
|
|
||||||
defaultToolCacheRoot &&
|
|
||||||
isHosted &&
|
|
||||||
fs.existsSync('d:\\') &&
|
|
||||||
fs.existsSync('c:\\')
|
|
||||||
) {
|
|
||||||
const substitutedToolCacheRoot = defaultToolCacheRoot
|
|
||||||
.replace('C:', 'D:')
|
|
||||||
.replace('c:', 'd:');
|
|
||||||
// make toolcache root to be on drive d:
|
|
||||||
process.env['RUNNER_TOOL_CACHE'] = substitutedToolCacheRoot;
|
|
||||||
|
|
||||||
const actualToolCacheDir = await addExecutablesToCache(extPath, info, arch);
|
if (!fs.existsSync('d:\\') || !fs.existsSync('c:\\'))
|
||||||
|
return addExecutablesToCache(extPath, info, arch);
|
||||||
|
|
||||||
// create a link from c: to d:
|
const substitutedToolCacheRoot = defaultToolCacheRoot
|
||||||
const defaultToolCacheDir = actualToolCacheDir.replace(
|
.replace('C:', 'D:')
|
||||||
substitutedToolCacheRoot,
|
.replace('c:', 'd:');
|
||||||
defaultToolCacheRoot
|
// make toolcache root to be on drive d:
|
||||||
);
|
process.env['RUNNER_TOOL_CACHE'] = substitutedToolCacheRoot;
|
||||||
fs.mkdirSync(path.dirname(defaultToolCacheDir), {recursive: true});
|
|
||||||
fs.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction');
|
|
||||||
core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`);
|
|
||||||
|
|
||||||
// restore toolcache root to default drive c:
|
const actualToolCacheDir = await addExecutablesToCache(extPath, info, arch);
|
||||||
process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot;
|
|
||||||
|
|
||||||
// make outer code to continue using toolcache as if it were installed on c:
|
// create a link from c: to d:
|
||||||
return defaultToolCacheDir;
|
const defaultToolCacheDir = actualToolCacheDir.replace(
|
||||||
}
|
substitutedToolCacheRoot,
|
||||||
|
defaultToolCacheRoot
|
||||||
|
);
|
||||||
|
fs.mkdirSync(path.dirname(defaultToolCacheDir), {recursive: true});
|
||||||
|
fs.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction');
|
||||||
|
core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`);
|
||||||
|
|
||||||
return await addExecutablesToCache(extPath, info, arch);
|
// restore toolcache root to default drive c:
|
||||||
|
process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot;
|
||||||
|
|
||||||
|
// make outer code to continue using toolcache as if it were installed on c:
|
||||||
|
return defaultToolCacheDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function extractGoArchive(archivePath: string): Promise<string> {
|
export async function extractGoArchive(archivePath: string): Promise<string> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue