fix(post-build): guard cache pushes when Library/build missing or empty (local CI)
parent
f00d7c8add
commit
0c57572a1c
|
@ -64,17 +64,47 @@ export class RemoteClient {
|
||||||
public static async remoteClientPostBuild(): Promise<string> {
|
public static async remoteClientPostBuild(): Promise<string> {
|
||||||
RemoteClientLogger.log(`Running POST build tasks`);
|
RemoteClientLogger.log(`Running POST build tasks`);
|
||||||
|
|
||||||
await Caching.PushToCache(
|
// Guard: only push Library cache if the folder exists and has contents
|
||||||
CloudRunnerFolders.ToLinuxFolder(`${CloudRunnerFolders.cacheFolderForCacheKeyFull}/Library`),
|
try {
|
||||||
CloudRunnerFolders.ToLinuxFolder(CloudRunnerFolders.libraryFolderAbsolute),
|
const libraryFolderHost = CloudRunnerFolders.libraryFolderAbsolute;
|
||||||
`lib-${CloudRunner.buildParameters.buildGuid}`,
|
if (fs.existsSync(libraryFolderHost)) {
|
||||||
);
|
const libraryEntries = await fs.promises.readdir(libraryFolderHost).catch(() => [] as string[]);
|
||||||
|
if (libraryEntries.length > 0) {
|
||||||
|
await Caching.PushToCache(
|
||||||
|
CloudRunnerFolders.ToLinuxFolder(`${CloudRunnerFolders.cacheFolderForCacheKeyFull}/Library`),
|
||||||
|
CloudRunnerFolders.ToLinuxFolder(CloudRunnerFolders.libraryFolderAbsolute),
|
||||||
|
`lib-${CloudRunner.buildParameters.buildGuid}`,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
RemoteClientLogger.log(`Skipping Library cache push (folder is empty)`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
RemoteClientLogger.log(`Skipping Library cache push (folder missing)`);
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
RemoteClientLogger.logWarning(`Library cache push skipped with error: ${error.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
await Caching.PushToCache(
|
// Guard: only push Build cache if the folder exists and has contents
|
||||||
CloudRunnerFolders.ToLinuxFolder(`${CloudRunnerFolders.cacheFolderForCacheKeyFull}/build`),
|
try {
|
||||||
CloudRunnerFolders.ToLinuxFolder(CloudRunnerFolders.projectBuildFolderAbsolute),
|
const buildFolderHost = CloudRunnerFolders.projectBuildFolderAbsolute;
|
||||||
`build-${CloudRunner.buildParameters.buildGuid}`,
|
if (fs.existsSync(buildFolderHost)) {
|
||||||
);
|
const buildEntries = await fs.promises.readdir(buildFolderHost).catch(() => [] as string[]);
|
||||||
|
if (buildEntries.length > 0) {
|
||||||
|
await Caching.PushToCache(
|
||||||
|
CloudRunnerFolders.ToLinuxFolder(`${CloudRunnerFolders.cacheFolderForCacheKeyFull}/build`),
|
||||||
|
CloudRunnerFolders.ToLinuxFolder(CloudRunnerFolders.projectBuildFolderAbsolute),
|
||||||
|
`build-${CloudRunner.buildParameters.buildGuid}`,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
RemoteClientLogger.log(`Skipping Build cache push (folder is empty)`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
RemoteClientLogger.log(`Skipping Build cache push (folder missing)`);
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
RemoteClientLogger.logWarning(`Build cache push skipped with error: ${error.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
if (!BuildParameters.shouldUseRetainedWorkspaceMode(CloudRunner.buildParameters)) {
|
if (!BuildParameters.shouldUseRetainedWorkspaceMode(CloudRunner.buildParameters)) {
|
||||||
await CloudRunnerSystem.Run(
|
await CloudRunnerSystem.Run(
|
||||||
|
|
Loading…
Reference in New Issue