Caching cleanup

pull/310/head
Frostebite 2022-01-02 18:29:54 +00:00
parent a7a8661484
commit d3d0b12901
3 changed files with 13 additions and 11 deletions

10
dist/index.js vendored
View File

@ -545,8 +545,8 @@ class Caching {
if (__1.Input.cloudRunnerTests) {
cloud_runner_logger_1.default.log(`Hashed cache folder ${yield lfs_hashing_1.LFSHashing.hashAllFiles(sourceFolder)}`);
}
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`zip -q -r ${cacheKey}.zip ${path_1.default.basename(sourceFolder)}`);
console_1.assert(fs_1.default.existsSync(`${cacheKey}`));
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`zip ${__1.Input.cloudRunnerTests ? '' : '-q'} -r ${cacheKey} ${path_1.default.basename(sourceFolder)}`);
console_1.assert(fs_1.default.existsSync(`${cacheKey}.zip`));
console_1.assert(fs_1.default.existsSync(`${cacheFolder}`));
console_1.assert(fs_1.default.existsSync(`${sourceFolder}`));
console_1.assert(fs_1.default.existsSync(`${path_1.default.basename(sourceFolder)}`));
@ -576,15 +576,15 @@ class Caching {
.replace(/\n/g, ``)
.replace('.zip', '');
process.chdir(cacheFolder);
const cacheSelection = cacheKey !== `` && fs_1.default.existsSync(cacheKey) ? cacheKey : latestInBranch;
const cacheSelection = cacheKey !== `` && fs_1.default.existsSync(`${cacheKey}.zip`) ? cacheKey : latestInBranch;
yield cloud_runner_logger_1.default.log(`cache key ${cacheKey} selection ${cacheSelection}`);
if (fs_1.default.existsSync(cacheSelection)) {
if (fs_1.default.existsSync(`${cacheSelection}.zip`)) {
if (__1.Input.cloudRunnerTests) {
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`);
}
remote_client_logger_1.RemoteClientLogger.log(`cache item exists`);
console_1.assert(fs_1.default.existsSync(destinationFolder));
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`unzip -q ${cacheSelection}.zip -d ${path_1.default.basename(destinationFolder)}`);
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`unzip -q ${cacheSelection} -d ${path_1.default.basename(destinationFolder)}`);
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`mv ${path_1.default.basename(destinationFolder)}/* ${destinationFolder}`);
console_1.assert(fs_1.default.existsSync(`${path_1.default.join(destinationFolder, `${cacheSelection}.zip`)}`));
}

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -20,8 +20,10 @@ export class Caching {
CloudRunnerLogger.log(`Hashed cache folder ${await LFSHashing.hashAllFiles(sourceFolder)}`);
}
await CloudRunnerAgentSystem.Run(`zip -q -r ${cacheKey}.zip ${path.basename(sourceFolder)}`);
assert(fs.existsSync(`${cacheKey}`));
await CloudRunnerAgentSystem.Run(
`zip ${Input.cloudRunnerTests ? '' : '-q'} -r ${cacheKey} ${path.basename(sourceFolder)}`,
);
assert(fs.existsSync(`${cacheKey}.zip`));
assert(fs.existsSync(`${cacheFolder}`));
assert(fs.existsSync(`${sourceFolder}`));
assert(fs.existsSync(`${path.basename(sourceFolder)}`));
@ -53,16 +55,16 @@ export class Caching {
process.chdir(cacheFolder);
const cacheSelection = cacheKey !== `` && fs.existsSync(cacheKey) ? cacheKey : latestInBranch;
const cacheSelection = cacheKey !== `` && fs.existsSync(`${cacheKey}.zip`) ? cacheKey : latestInBranch;
await CloudRunnerLogger.log(`cache key ${cacheKey} selection ${cacheSelection}`);
if (fs.existsSync(cacheSelection)) {
if (fs.existsSync(`${cacheSelection}.zip`)) {
if (Input.cloudRunnerTests) {
await CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`);
}
RemoteClientLogger.log(`cache item exists`);
assert(fs.existsSync(destinationFolder));
await CloudRunnerAgentSystem.Run(`unzip -q ${cacheSelection}.zip -d ${path.basename(destinationFolder)}`);
await CloudRunnerAgentSystem.Run(`unzip -q ${cacheSelection} -d ${path.basename(destinationFolder)}`);
await CloudRunnerAgentSystem.Run(`mv ${path.basename(destinationFolder)}/* ${destinationFolder}`);
assert(fs.existsSync(`${path.join(destinationFolder, `${cacheSelection}.zip`)}`));
} else {