Skip to content

Commit 4a70961

Browse files
[server] Add more tests around "prebuild selection" (#20358)
* [server] Extend and fix context parser tests around prebuild discovery * [server] Add more "prebuild selection" tests to ContextService * review comments * [server] Fix order of commits in MockRepositoryProvider to be aligned with actual implementation Co-authored-by: Filip Troníček <[email protected]> --------- Co-authored-by: Filip Troníček <[email protected]>
1 parent 66a1ba0 commit 4a70961

File tree

4 files changed

+316
-49
lines changed

4 files changed

+316
-49
lines changed

components/server/src/prebuilds/incremental-workspace-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class IncrementalWorkspaceService {
6666
return history;
6767
}
6868

69-
public async findGoodBaseForIncrementalBuild(
69+
public async findBaseForIncrementalWorkspace(
7070
context: CommitContext,
7171
config: WorkspaceConfig,
7272
history: WithCommitHistory,

components/server/src/prebuilds/prebuild-manager.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,11 @@ export class PrebuildManager {
381381
JSON.stringify(filterPrebuildTasks(config?.tasks));
382382
// If there is an existing prebuild that isn't failed and it's based on the current config, we return it here instead of triggering a new prebuild.
383383
if (isSameConfig) {
384-
return { prebuildId: existingPB.id, wsid: existingPB.buildWorkspaceId, done: true };
384+
return {
385+
prebuildId: existingPB.id,
386+
wsid: existingPB.buildWorkspaceId,
387+
done: existingPB.state === "available",
388+
};
385389
}
386390
}
387391
}
@@ -407,7 +411,7 @@ export class PrebuildManager {
407411
commitHistory: repoHist.commitHistory.slice(0, prebuildInterval),
408412
})),
409413
};
410-
const prebuild = await this.incrementalPrebuildsService.findGoodBaseForIncrementalBuild(
414+
const prebuild = await this.incrementalPrebuildsService.findBaseForIncrementalWorkspace(
411415
context,
412416
config,
413417
history,
@@ -416,7 +420,11 @@ export class PrebuildManager {
416420
true,
417421
);
418422
if (prebuild) {
419-
return { prebuildId: prebuild.id, wsid: prebuild.buildWorkspaceId, done: true };
423+
return {
424+
prebuildId: prebuild.id,
425+
wsid: prebuild.buildWorkspaceId,
426+
done: prebuild.state === "available",
427+
};
420428
}
421429
}
422430

0 commit comments

Comments
 (0)