Simple override cache push and pull override to allow pure cloud storage driven caching
parent
a8be343564
commit
d8278dc24a
|
|
@ -630,7 +630,7 @@ class Caching {
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line func-style
|
// eslint-disable-next-line func-style
|
||||||
const formatFunction = function (format) {
|
const formatFunction = function (format) {
|
||||||
const arguments_ = Array.prototype.slice.call([path_1.default.resolve(sourceFolder, '..'), cacheFolder], 1);
|
const arguments_ = Array.prototype.slice.call([path_1.default.resolve(sourceFolder, '..'), cacheFolder, cacheKey], 1);
|
||||||
return format.replace(/{(\d+)}/g, function (match, number) {
|
return format.replace(/{(\d+)}/g, function (match, number) {
|
||||||
return typeof arguments_[number] != 'undefined' ? arguments_[number] : match;
|
return typeof arguments_[number] != 'undefined' ? arguments_[number] : match;
|
||||||
});
|
});
|
||||||
|
|
@ -638,9 +638,10 @@ class Caching {
|
||||||
yield cloud_runner_system_1.CloudRunnerSystem.Run(`zip ${cacheKey}.zip ${path_1.default.basename(sourceFolder)}`);
|
yield cloud_runner_system_1.CloudRunnerSystem.Run(`zip ${cacheKey}.zip ${path_1.default.basename(sourceFolder)}`);
|
||||||
console_1.assert(fs_1.default.existsSync(`${cacheKey}.zip`), 'cache zip exists');
|
console_1.assert(fs_1.default.existsSync(`${cacheKey}.zip`), 'cache zip exists');
|
||||||
console_1.assert(fs_1.default.existsSync(path_1.default.basename(sourceFolder)), 'source folder exists');
|
console_1.assert(fs_1.default.existsSync(path_1.default.basename(sourceFolder)), 'source folder exists');
|
||||||
yield (process.env.CLOUD_RUNNER_OVERRIDE_CACHE_PUSH
|
if (process.env.CLOUD_RUNNER_PRE_CACHE_PUSH) {
|
||||||
? cloud_runner_system_1.CloudRunnerSystem.Run(formatFunction(process.env.CLOUD_RUNNER_OVERRIDE_CACHE_PUSH))
|
cloud_runner_system_1.CloudRunnerSystem.Run(formatFunction(process.env.CLOUD_RUNNER_PRE_CACHE_PUSH));
|
||||||
: cloud_runner_system_1.CloudRunnerSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`));
|
}
|
||||||
|
cloud_runner_system_1.CloudRunnerSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`);
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`moved ${cacheKey}.zip to ${cacheFolder}`);
|
remote_client_logger_1.RemoteClientLogger.log(`moved ${cacheKey}.zip to ${cacheFolder}`);
|
||||||
console_1.assert(fs_1.default.existsSync(`${path_1.default.join(cacheFolder, cacheKey)}.zip`), 'cache zip exists inside cache folder');
|
console_1.assert(fs_1.default.existsSync(`${path_1.default.join(cacheFolder, cacheKey)}.zip`), 'cache zip exists inside cache folder');
|
||||||
if (__1.Input.cloudRunnerTests) {
|
if (__1.Input.cloudRunnerTests) {
|
||||||
|
|
@ -671,6 +672,16 @@ class Caching {
|
||||||
process.chdir(cacheFolder);
|
process.chdir(cacheFolder);
|
||||||
const cacheSelection = cacheKey !== `` && fs_1.default.existsSync(`${cacheKey}.zip`) ? 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}`);
|
yield cloud_runner_logger_1.default.log(`cache key ${cacheKey} selection ${cacheSelection}`);
|
||||||
|
// eslint-disable-next-line func-style
|
||||||
|
const formatFunction = function (format) {
|
||||||
|
const arguments_ = Array.prototype.slice.call([path_1.default.resolve(destinationFolder, '..'), cacheFolder, cacheKey], 1);
|
||||||
|
return format.replace(/{(\d+)}/g, function (match, number) {
|
||||||
|
return typeof arguments_[number] != 'undefined' ? arguments_[number] : match;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
if (process.env.CLOUD_RUNNER_PRE_CACHE_PULL) {
|
||||||
|
cloud_runner_system_1.CloudRunnerSystem.Run(formatFunction(process.env.CLOUD_RUNNER_PRE_CACHE_PULL));
|
||||||
|
}
|
||||||
if (fs_1.default.existsSync(`${cacheSelection}.zip`)) {
|
if (fs_1.default.existsSync(`${cacheSelection}.zip`)) {
|
||||||
const resultsFolder = `results${cloud_runner_state_1.CloudRunnerState.buildParams.buildGuid}`;
|
const resultsFolder = `results${cloud_runner_state_1.CloudRunnerState.buildParams.buildGuid}`;
|
||||||
yield cloud_runner_system_1.CloudRunnerSystem.Run(`mkdir -p ${resultsFolder}`);
|
yield cloud_runner_system_1.CloudRunnerSystem.Run(`mkdir -p ${resultsFolder}`);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -30,7 +30,7 @@ export class Caching {
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line func-style
|
// eslint-disable-next-line func-style
|
||||||
const formatFunction = function (format: string) {
|
const formatFunction = function (format: string) {
|
||||||
const arguments_ = Array.prototype.slice.call([path.resolve(sourceFolder, '..'), cacheFolder], 1);
|
const arguments_ = Array.prototype.slice.call([path.resolve(sourceFolder, '..'), cacheFolder, cacheKey], 1);
|
||||||
return format.replace(/{(\d+)}/g, function (match, number) {
|
return format.replace(/{(\d+)}/g, function (match, number) {
|
||||||
return typeof arguments_[number] != 'undefined' ? arguments_[number] : match;
|
return typeof arguments_[number] != 'undefined' ? arguments_[number] : match;
|
||||||
});
|
});
|
||||||
|
|
@ -38,9 +38,10 @@ export class Caching {
|
||||||
await CloudRunnerSystem.Run(`zip ${cacheKey}.zip ${path.basename(sourceFolder)}`);
|
await CloudRunnerSystem.Run(`zip ${cacheKey}.zip ${path.basename(sourceFolder)}`);
|
||||||
assert(fs.existsSync(`${cacheKey}.zip`), 'cache zip exists');
|
assert(fs.existsSync(`${cacheKey}.zip`), 'cache zip exists');
|
||||||
assert(fs.existsSync(path.basename(sourceFolder)), 'source folder exists');
|
assert(fs.existsSync(path.basename(sourceFolder)), 'source folder exists');
|
||||||
await (process.env.CLOUD_RUNNER_OVERRIDE_CACHE_PUSH
|
if (process.env.CLOUD_RUNNER_PRE_CACHE_PUSH) {
|
||||||
? CloudRunnerSystem.Run(formatFunction(process.env.CLOUD_RUNNER_OVERRIDE_CACHE_PUSH))
|
CloudRunnerSystem.Run(formatFunction(process.env.CLOUD_RUNNER_PRE_CACHE_PUSH));
|
||||||
: CloudRunnerSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`));
|
}
|
||||||
|
CloudRunnerSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`);
|
||||||
RemoteClientLogger.log(`moved ${cacheKey}.zip to ${cacheFolder}`);
|
RemoteClientLogger.log(`moved ${cacheKey}.zip to ${cacheFolder}`);
|
||||||
assert(fs.existsSync(`${path.join(cacheFolder, cacheKey)}.zip`), 'cache zip exists inside cache folder');
|
assert(fs.existsSync(`${path.join(cacheFolder, cacheKey)}.zip`), 'cache zip exists inside cache folder');
|
||||||
|
|
||||||
|
|
@ -74,6 +75,21 @@ export class Caching {
|
||||||
const cacheSelection = cacheKey !== `` && fs.existsSync(`${cacheKey}.zip`) ? cacheKey : latestInBranch;
|
const cacheSelection = cacheKey !== `` && fs.existsSync(`${cacheKey}.zip`) ? cacheKey : latestInBranch;
|
||||||
await CloudRunnerLogger.log(`cache key ${cacheKey} selection ${cacheSelection}`);
|
await CloudRunnerLogger.log(`cache key ${cacheKey} selection ${cacheSelection}`);
|
||||||
|
|
||||||
|
// eslint-disable-next-line func-style
|
||||||
|
const formatFunction = function (format: string) {
|
||||||
|
const arguments_ = Array.prototype.slice.call(
|
||||||
|
[path.resolve(destinationFolder, '..'), cacheFolder, cacheKey],
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
return format.replace(/{(\d+)}/g, function (match, number) {
|
||||||
|
return typeof arguments_[number] != 'undefined' ? arguments_[number] : match;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (process.env.CLOUD_RUNNER_PRE_CACHE_PULL) {
|
||||||
|
CloudRunnerSystem.Run(formatFunction(process.env.CLOUD_RUNNER_PRE_CACHE_PULL));
|
||||||
|
}
|
||||||
|
|
||||||
if (fs.existsSync(`${cacheSelection}.zip`)) {
|
if (fs.existsSync(`${cacheSelection}.zip`)) {
|
||||||
const resultsFolder = `results${CloudRunnerState.buildParams.buildGuid}`;
|
const resultsFolder = `results${CloudRunnerState.buildParams.buildGuid}`;
|
||||||
await CloudRunnerSystem.Run(`mkdir -p ${resultsFolder}`);
|
await CloudRunnerSystem.Run(`mkdir -p ${resultsFolder}`);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue