Skip to content

Commit 77fdcc8

Browse files
committed
v3
1 parent fa33820 commit 77fdcc8

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

components/server/ee/src/prebuilds/start-prebuild-context-parser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class StartPrebuildContextParser implements IPrefixContextParser {
2323
throw new Error("cannot start prebuilds on an issue context")
2424
}
2525

26+
// FIXME: The manual prebuild prefix forces non-incremental prebuilds. How to trigger incremental prebuilds?
2627
const result: StartPrebuildContext = {
2728
title: `Prebuild of "${context.title}"`,
2829
actual: context

components/server/ee/src/workspace/workspace-factory.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,32 @@ export class WorkspaceFactoryEE extends WorkspaceFactory {
5757
}
5858

5959
let ws;
60-
let parentPrebuild;
6160

6261
// Find an older full prebuild to start an incremental prebuild
6362
for (const parent of (context.commitHistory || [])) {
64-
parentPrebuild = await this.db.trace({span}).findPrebuiltWorkspaceByCommit(commitContext.repository.cloneUrl, parent);
65-
if (!!parentPrebuild) {
66-
log.debug(`Found parent prebuild for ${commitContext.revision}`, parentPrebuild);
67-
if (parentPrebuild.state === 'available') {
68-
const incrementalPrebuildContext: PrebuiltWorkspaceContext = {
69-
title: `Incremental prebuild of "${commitContext.title}"`,
70-
originalContext: commitContext,
71-
prebuiltWorkspace: parentPrebuild,
72-
}
73-
ws = await this.createForPrebuiltWorkspace({span}, user, incrementalPrebuildContext, normalizedContextURL);
74-
break;
75-
}
63+
const parentPrebuild = await this.db.trace({span}).findPrebuiltWorkspaceByCommit(commitContext.repository.cloneUrl, parent);
64+
if (!parentPrebuild) {
65+
continue;
7666
}
67+
log.debug(`Considering parent prebuild for ${commitContext.revision}`, parentPrebuild);
68+
if (parentPrebuild.state !== 'available') {
69+
continue;
70+
}
71+
const buildWorkspace = await this.db.trace({span}).findById(parentPrebuild.buildWorkspaceId);
72+
if (!buildWorkspace) {
73+
continue;
74+
}
75+
if (!!buildWorkspace.basedOnPrebuildId) {
76+
continue;
77+
}
78+
// FIXME: If the workspace image (ref or dockerfile commit) has changed, or if the prebuild tasks have changed, the prebuild is no longer relevant
79+
const incrementalPrebuildContext: PrebuiltWorkspaceContext = {
80+
title: `Incremental prebuild of "${commitContext.title}"`,
81+
originalContext: commitContext,
82+
prebuiltWorkspace: parentPrebuild,
83+
}
84+
ws = await this.createForPrebuiltWorkspace({span}, user, incrementalPrebuildContext, normalizedContextURL);
85+
break;
7786
}
7887

7988
if (!ws) {

0 commit comments

Comments
 (0)