mirror of
https://github.com/actions/setup-go.git
synced 2025-06-30 13:13:43 +00:00
Add GOCACHE AND GOMODCACHE symlink on Windows
Use D drive for faster cache restore Signed-off-by: Anton Troshin <anton@diagrid.io>
This commit is contained in:
parent
41dfa10bad
commit
28b19b8019
2 changed files with 50 additions and 0 deletions
|
@ -7,6 +7,7 @@ import * as sys from './system';
|
|||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import {StableReleaseAlias} from './utils';
|
||||
import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils';
|
||||
|
||||
type InstallationType = 'dist' | 'manifest';
|
||||
|
||||
|
@ -214,6 +215,33 @@ async function cacheWindowsDir(
|
|||
`Created link ${defaultToolCacheCompleteFile} => ${actualToolCacheCompleteFile}`
|
||||
);
|
||||
|
||||
const packageManager = 'default';
|
||||
const packageManagerInfo = await getPackageManagerInfo(packageManager);
|
||||
const cacheDirectoryPaths = await getCacheDirectoryPath(packageManagerInfo);
|
||||
if (!cacheDirectoryPaths) {
|
||||
throw new Error(`Could not get cache folder paths.`);
|
||||
}
|
||||
|
||||
// replace cache directory path with actual cache directory path
|
||||
const actualCacheDirectoryPaths = cacheDirectoryPaths.map(path => {
|
||||
return {
|
||||
defaultPath: path,
|
||||
actualPath: path.replace('D:', 'C:').replace('d:', 'c:')
|
||||
};
|
||||
});
|
||||
|
||||
// iterate through actual cache directory paths and make links
|
||||
for (const cachePath of actualCacheDirectoryPaths) {
|
||||
if (!fs.existsSync(cachePath.actualPath)) {
|
||||
fs.mkdirSync(path.dirname(cachePath.actualPath), {recursive: true});
|
||||
}
|
||||
|
||||
fs.symlinkSync(cachePath.actualPath, cachePath.defaultPath, 'junction');
|
||||
core.info(
|
||||
`Created link ${cachePath.defaultPath} => ${cachePath.actualPath}`
|
||||
);
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue