Debug cache extract

pull/310/head
Frostebite 2022-01-16 13:11:30 +00:00
parent 4543d0466b
commit 96310265cf
6 changed files with 40 additions and 7 deletions

24
dist/index.js vendored
View File

@ -489,6 +489,12 @@ class CLI {
yield setup_cloud_runner_repository_1.SetupCloudRunnerRepository.run(); yield setup_cloud_runner_repository_1.SetupCloudRunnerRepository.run();
}); });
} }
static cachePush() {
return __awaiter(this, void 0, void 0, function* () { });
}
static cachePull() {
return __awaiter(this, void 0, void 0, function* () { });
}
} }
__decorate([ __decorate([
cli_decorator_1.CliFunction(`cli`, `runs a cloud runner build`) cli_decorator_1.CliFunction(`cli`, `runs a cloud runner build`)
@ -496,6 +502,12 @@ __decorate([
__decorate([ __decorate([
cli_decorator_1.CliFunction(`remote-cli`, `sets up a repository, usually before a game-ci build`) cli_decorator_1.CliFunction(`remote-cli`, `sets up a repository, usually before a game-ci build`)
], CLI, "runRemoteClientJob", null); ], CLI, "runRemoteClientJob", null);
__decorate([
cli_decorator_1.CliFunction(`cach-push`, `push to cache`)
], CLI, "cachePush", null);
__decorate([
cli_decorator_1.CliFunction(`cach-pull`, `pull from cache`)
], CLI, "cachePull", null);
exports.CLI = CLI; exports.CLI = CLI;
@ -596,10 +608,10 @@ class Caching {
remote_client_logger_1.RemoteClientLogger.log(`Caching for ${path_1.default.basename(destinationFolder)}`); remote_client_logger_1.RemoteClientLogger.log(`Caching for ${path_1.default.basename(destinationFolder)}`);
try { try {
if (!fs_1.default.existsSync(cacheFolder)) { if (!fs_1.default.existsSync(cacheFolder)) {
yield cloud_runner_system_1.CloudRunnerSystem.Run(`mkdir -p ${cacheFolder}`); fs_1.default.mkdirSync(cacheFolder);
} }
if (!fs_1.default.existsSync(destinationFolder)) { if (!fs_1.default.existsSync(destinationFolder)) {
yield cloud_runner_system_1.CloudRunnerSystem.Run(`mkdir -p ${destinationFolder}`); fs_1.default.mkdirSync(destinationFolder);
} }
const latestInBranch = yield (yield cloud_runner_system_1.CloudRunnerSystem.Run(`ls -t "${cacheFolder}" | grep .zip$ | head -1`)) const latestInBranch = yield (yield cloud_runner_system_1.CloudRunnerSystem.Run(`ls -t "${cacheFolder}" | grep .zip$ | head -1`))
.replace(/\n/g, ``) .replace(/\n/g, ``)
@ -608,7 +620,7 @@ class Caching {
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}`);
if (fs_1.default.existsSync(`${cacheSelection}.zip`)) { if (fs_1.default.existsSync(`${cacheSelection}.zip`)) {
const resultsDirectory = `results`; const resultsDirectory = `results${cloud_runner_state_1.CloudRunnerState.buildParams.buildGuid}`;
yield cloud_runner_system_1.CloudRunnerSystem.Run(`mkdir -p ${resultsDirectory}`); yield cloud_runner_system_1.CloudRunnerSystem.Run(`mkdir -p ${resultsDirectory}`);
if (__1.Input.cloudRunnerTests) { if (__1.Input.cloudRunnerTests) {
yield cloud_runner_system_1.CloudRunnerSystem.Run(`tree ${destinationFolder}`); yield cloud_runner_system_1.CloudRunnerSystem.Run(`tree ${destinationFolder}`);
@ -627,6 +639,7 @@ class Caching {
remote_client_logger_1.RemoteClientLogger.log(`cache item extracted to ${fullDestination}`); remote_client_logger_1.RemoteClientLogger.log(`cache item extracted to ${fullDestination}`);
console_1.assert(`${fs_1.default.existsSync(fullDestination)}`); console_1.assert(`${fs_1.default.existsSync(fullDestination)}`);
yield cloud_runner_system_1.CloudRunnerSystem.Run(`mv "${fullDestination}" "${destinationFolder}"`); yield cloud_runner_system_1.CloudRunnerSystem.Run(`mv "${fullDestination}" "${destinationFolder}"`);
fs_1.default.rmdirSync(fullDestination);
} }
else { else {
remote_client_logger_1.RemoteClientLogger.logWarning(`cache item ${cacheKey} doesn't exist ${destinationFolder}`); remote_client_logger_1.RemoteClientLogger.logWarning(`cache item ${cacheKey} doesn't exist ${destinationFolder}`);
@ -847,6 +860,7 @@ class SetupCloudRunnerRepository {
try { try {
yield cloud_runner_system_1.CloudRunnerSystem.Run(`mkdir -p ${cloud_runner_state_1.CloudRunnerState.buildPathFull}`); yield cloud_runner_system_1.CloudRunnerSystem.Run(`mkdir -p ${cloud_runner_state_1.CloudRunnerState.buildPathFull}`);
yield cloud_runner_system_1.CloudRunnerSystem.Run(`mkdir -p ${cloud_runner_state_1.CloudRunnerState.repoPathFull}`); yield cloud_runner_system_1.CloudRunnerSystem.Run(`mkdir -p ${cloud_runner_state_1.CloudRunnerState.repoPathFull}`);
yield cloud_runner_system_1.CloudRunnerSystem.Run(`mkdir -p ${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}`);
process.chdir(cloud_runner_state_1.CloudRunnerState.repoPathFull); process.chdir(cloud_runner_state_1.CloudRunnerState.repoPathFull);
if (__1.Input.cloudRunnerTests) { if (__1.Input.cloudRunnerTests) {
yield cloud_runner_system_1.CloudRunnerSystem.Run(`ls -lh`); yield cloud_runner_system_1.CloudRunnerSystem.Run(`ls -lh`);
@ -2894,6 +2908,10 @@ class BuildStep {
${__1.Input.cloudRunnerTests ? '' : '#'} tree -lh ${__1.Input.cloudRunnerTests ? '' : '#'} tree -lh
${__1.Input.cloudRunnerTests ? '' : '#'} tree -lh "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull.replace(/\\/g, `/`)}" ${__1.Input.cloudRunnerTests ? '' : '#'} tree -lh "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull.replace(/\\/g, `/`)}"
mv "build-${cloud_runner_state_1.CloudRunnerState.buildParams.buildGuid}.zip" "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull.replace(/\\/g, `/`)}" mv "build-${cloud_runner_state_1.CloudRunnerState.buildParams.buildGuid}.zip" "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull.replace(/\\/g, `/`)}"
chmod +x ${path_1.default.join(cloud_runner_state_1.CloudRunnerState.builderPathFull, 'dist', `index.js`).replace(/\\/g, `/`)}
node ${path_1.default
.join(cloud_runner_state_1.CloudRunnerState.builderPathFull, 'dist', `index.js`)
.replace(/\\/g, `/`)} -m cache-push "Library" "lib-${cloud_runner_state_1.CloudRunnerState.buildParams.buildGuid}.zip" "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull.replace(/\\/g, `/`)}/Library"
${__1.Input.cloudRunnerTests ? '' : '#'} tree -lh "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}" ${__1.Input.cloudRunnerTests ? '' : '#'} tree -lh "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}"
${hooks.filter((x) => x.hook.includes(`after`)).map((x) => x.commands) || ' '} ${hooks.filter((x) => x.hook.includes(`after`)).map((x) => x.commands) || ' '}
`, `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, `/${cloud_runner_state_1.CloudRunnerState.projectPathFull}`, environmentVariables, secrets); `, `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, `/${cloud_runner_state_1.CloudRunnerState.projectPathFull}`, environmentVariables, secrets);

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -68,4 +68,10 @@ export class CLI {
CloudRunnerState.setup(buildParameter); CloudRunnerState.setup(buildParameter);
await SetupCloudRunnerRepository.run(); await SetupCloudRunnerRepository.run();
} }
@CliFunction(`cach-push`, `push to cache`)
static async cachePush() {}
@CliFunction(`cach-pull`, `pull from cache`)
static async cachePull() {}
} }

View File

@ -76,11 +76,11 @@ export class Caching {
RemoteClientLogger.log(`Caching for ${path.basename(destinationFolder)}`); RemoteClientLogger.log(`Caching for ${path.basename(destinationFolder)}`);
try { try {
if (!fs.existsSync(cacheFolder)) { if (!fs.existsSync(cacheFolder)) {
await CloudRunnerSystem.Run(`mkdir -p ${cacheFolder}`); fs.mkdirSync(cacheFolder);
} }
if (!fs.existsSync(destinationFolder)) { if (!fs.existsSync(destinationFolder)) {
await CloudRunnerSystem.Run(`mkdir -p ${destinationFolder}`); fs.mkdirSync(destinationFolder);
} }
const latestInBranch = await (await CloudRunnerSystem.Run(`ls -t "${cacheFolder}" | grep .zip$ | head -1`)) const latestInBranch = await (await CloudRunnerSystem.Run(`ls -t "${cacheFolder}" | grep .zip$ | head -1`))
@ -93,7 +93,7 @@ export class Caching {
await CloudRunnerLogger.log(`cache key ${cacheKey} selection ${cacheSelection}`); await CloudRunnerLogger.log(`cache key ${cacheKey} selection ${cacheSelection}`);
if (fs.existsSync(`${cacheSelection}.zip`)) { if (fs.existsSync(`${cacheSelection}.zip`)) {
const resultsDirectory = `results`; const resultsDirectory = `results${CloudRunnerState.buildParams.buildGuid}`;
await CloudRunnerSystem.Run(`mkdir -p ${resultsDirectory}`); await CloudRunnerSystem.Run(`mkdir -p ${resultsDirectory}`);
if (Input.cloudRunnerTests) { if (Input.cloudRunnerTests) {
await CloudRunnerSystem.Run(`tree ${destinationFolder}`); await CloudRunnerSystem.Run(`tree ${destinationFolder}`);
@ -114,6 +114,7 @@ export class Caching {
RemoteClientLogger.log(`cache item extracted to ${fullDestination}`); RemoteClientLogger.log(`cache item extracted to ${fullDestination}`);
assert(`${fs.existsSync(fullDestination)}`); assert(`${fs.existsSync(fullDestination)}`);
await CloudRunnerSystem.Run(`mv "${fullDestination}" "${destinationFolder}"`); await CloudRunnerSystem.Run(`mv "${fullDestination}" "${destinationFolder}"`);
fs.rmdirSync(fullDestination);
} else { } else {
RemoteClientLogger.logWarning(`cache item ${cacheKey} doesn't exist ${destinationFolder}`); RemoteClientLogger.logWarning(`cache item ${cacheKey} doesn't exist ${destinationFolder}`);
if (cacheSelection !== ``) { if (cacheSelection !== ``) {

View File

@ -13,6 +13,8 @@ export class SetupCloudRunnerRepository {
try { try {
await CloudRunnerSystem.Run(`mkdir -p ${CloudRunnerState.buildPathFull}`); await CloudRunnerSystem.Run(`mkdir -p ${CloudRunnerState.buildPathFull}`);
await CloudRunnerSystem.Run(`mkdir -p ${CloudRunnerState.repoPathFull}`); await CloudRunnerSystem.Run(`mkdir -p ${CloudRunnerState.repoPathFull}`);
await CloudRunnerSystem.Run(`mkdir -p ${CloudRunnerState.cacheFolderFull}`);
process.chdir(CloudRunnerState.repoPathFull); process.chdir(CloudRunnerState.repoPathFull);
if (Input.cloudRunnerTests) { if (Input.cloudRunnerTests) {
await CloudRunnerSystem.Run(`ls -lh`); await CloudRunnerSystem.Run(`ls -lh`);

View File

@ -57,6 +57,12 @@ export class BuildStep implements StepInterface {
/\\/g, /\\/g,
`/`, `/`,
)}" )}"
chmod +x ${path.join(CloudRunnerState.builderPathFull, 'dist', `index.js`).replace(/\\/g, `/`)}
node ${path
.join(CloudRunnerState.builderPathFull, 'dist', `index.js`)
.replace(/\\/g, `/`)} -m cache-push "Library" "lib-${
CloudRunnerState.buildParams.buildGuid
}.zip" "${CloudRunnerState.cacheFolderFull.replace(/\\/g, `/`)}/Library"
${Input.cloudRunnerTests ? '' : '#'} tree -lh "${CloudRunnerState.cacheFolderFull}" ${Input.cloudRunnerTests ? '' : '#'} tree -lh "${CloudRunnerState.cacheFolderFull}"
${hooks.filter((x) => x.hook.includes(`after`)).map((x) => x.commands) || ' '} ${hooks.filter((x) => x.hook.includes(`after`)).map((x) => x.commands) || ' '}
`, `,