hashing driven enhancement for cache

pull/310/head
Frostebite 2022-01-01 03:37:44 +00:00
parent 00937a75df
commit 7d106a632d
3 changed files with 13 additions and 17 deletions

11
dist/index.js vendored
View File

@ -568,18 +568,15 @@ class Caching {
if (!fs_1.default.existsSync(destinationFolder)) {
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`mkdir -p ${destinationFolder}`);
}
const latest = yield (yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`ls -t "${cacheFolder}" | grep .zip$ | head -1`)).replace(/\n/g, ``);
const latestInBranch = yield (yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`ls -t "${cacheFolder}" | grep .zip$ | head -1`)).replace(/\n/g, ``);
process.chdir(cacheFolder);
let cacheSelection;
if (__1.Input.cloudRunnerTests) {
cloud_runner_logger_1.default.log(yield lfs_hashing_1.LFSHashing.hashAllFiles(destinationFolder));
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${cacheFolder}`);
}
if (cacheKey !== ``) {
cacheSelection = fs_1.default.existsSync(cacheKey) ? cacheKey : latest;
}
else {
cacheSelection = latest;
const cacheSelection = cacheKey !== `` && fs_1.default.existsSync(cacheKey) ? cacheKey : latestInBranch;
if (__1.Input.cloudRunnerTests) {
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`cache key ${cacheKey} selection ${cacheSelection}`);
}
if (fs_1.default.existsSync(cacheSelection)) {
if (__1.Input.cloudRunnerTests) {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -47,24 +47,23 @@ export class Caching {
await CloudRunnerAgentSystem.Run(`mkdir -p ${destinationFolder}`);
}
const latest = await (await CloudRunnerAgentSystem.Run(`ls -t "${cacheFolder}" | grep .zip$ | head -1`)).replace(
/\n/g,
``,
);
const latestInBranch = await (
await CloudRunnerAgentSystem.Run(`ls -t "${cacheFolder}" | grep .zip$ | head -1`)
).replace(/\n/g, ``);
process.chdir(cacheFolder);
let cacheSelection;
if (Input.cloudRunnerTests) {
CloudRunnerLogger.log(await LFSHashing.hashAllFiles(destinationFolder));
await CloudRunnerAgentSystem.Run(`tree ${cacheFolder}`);
}
if (cacheKey !== ``) {
cacheSelection = fs.existsSync(cacheKey) ? cacheKey : latest;
} else {
cacheSelection = latest;
const cacheSelection = cacheKey !== `` && fs.existsSync(cacheKey) ? cacheKey : latestInBranch;
if (Input.cloudRunnerTests) {
await CloudRunnerAgentSystem.Run(`cache key ${cacheKey} selection ${cacheSelection}`);
}
if (fs.existsSync(cacheSelection)) {
if (Input.cloudRunnerTests) {
await CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`);