Simple override cache push

pull/353/head
Frostebite 2022-03-06 01:58:02 +00:00
parent 035e59e774
commit a8be343564
3 changed files with 21 additions and 3 deletions

11
dist/index.js vendored
View File

@ -628,10 +628,19 @@ class Caching {
if (__1.Input.cloudRunnerTests) {
yield cloud_runner_system_1.CloudRunnerSystem.Run(`ls ${path_1.default.basename(sourceFolder)}`);
}
// eslint-disable-next-line func-style
const formatFunction = function (format) {
const arguments_ = Array.prototype.slice.call([path_1.default.resolve(sourceFolder, '..'), cacheFolder], 1);
return format.replace(/{(\d+)}/g, function (match, number) {
return typeof arguments_[number] != 'undefined' ? arguments_[number] : match;
});
};
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(path_1.default.basename(sourceFolder)), 'source folder exists');
yield cloud_runner_system_1.CloudRunnerSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`);
yield (process.env.CLOUD_RUNNER_OVERRIDE_CACHE_PUSH
? cloud_runner_system_1.CloudRunnerSystem.Run(formatFunction(process.env.CLOUD_RUNNER_OVERRIDE_CACHE_PUSH))
: cloud_runner_system_1.CloudRunnerSystem.Run(`mv ${cacheKey}.zip ${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');
if (__1.Input.cloudRunnerTests) {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -28,10 +28,19 @@ export class Caching {
if (Input.cloudRunnerTests) {
await CloudRunnerSystem.Run(`ls ${path.basename(sourceFolder)}`);
}
// eslint-disable-next-line func-style
const formatFunction = function (format: string) {
const arguments_ = Array.prototype.slice.call([path.resolve(sourceFolder, '..'), cacheFolder], 1);
return format.replace(/{(\d+)}/g, function (match, number) {
return typeof arguments_[number] != 'undefined' ? arguments_[number] : match;
});
};
await CloudRunnerSystem.Run(`zip ${cacheKey}.zip ${path.basename(sourceFolder)}`);
assert(fs.existsSync(`${cacheKey}.zip`), 'cache zip exists');
assert(fs.existsSync(path.basename(sourceFolder)), 'source folder exists');
await CloudRunnerSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`);
await (process.env.CLOUD_RUNNER_OVERRIDE_CACHE_PUSH
? CloudRunnerSystem.Run(formatFunction(process.env.CLOUD_RUNNER_OVERRIDE_CACHE_PUSH))
: CloudRunnerSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`));
RemoteClientLogger.log(`moved ${cacheKey}.zip to ${cacheFolder}`);
assert(fs.existsSync(`${path.join(cacheFolder, cacheKey)}.zip`), 'cache zip exists inside cache folder');