Skip to content

Commit 8ca52a6

Browse files
committed
Implement a 'Use Last Successful Prebuild' workspace creation mode
1 parent c67e609 commit 8ca52a6

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

components/dashboard/src/start/CreateWorkspace.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ export default class CreateWorkspace extends React.Component<CreateWorkspaceProp
269269
return (
270270
<RunningPrebuildView
271271
runningPrebuild={result.runningWorkspacePrebuild}
272+
onUseLastSuccessfulPrebuild={() =>
273+
this.createWorkspace(CreateWorkspaceMode.UseLastSuccessfulPrebuild)
274+
}
272275
onIgnorePrebuild={() => this.createWorkspace(CreateWorkspaceMode.ForceNew)}
273276
onPrebuildSucceeded={() => this.createWorkspace(CreateWorkspaceMode.UsePrebuild)}
274277
/>
@@ -531,6 +534,7 @@ interface RunningPrebuildViewProps {
531534
starting: RunningWorkspacePrebuildStarting;
532535
sameCluster: boolean;
533536
};
537+
onUseLastSuccessfulPrebuild: () => void;
534538
onIgnorePrebuild: () => void;
535539
onPrebuildSucceeded: () => void;
536540
}
@@ -565,8 +569,14 @@ function RunningPrebuildView(props: RunningPrebuildViewProps) {
565569
{/* TODO(gpl) Copied around in Start-/CreateWorkspace. This should properly go somewhere central. */}
566570
<div className="h-full mt-6 w-11/12 lg:w-3/5">
567571
<PrebuildLogs workspaceId={workspaceId} onIgnorePrebuild={props.onIgnorePrebuild}>
572+
<button
573+
className="secondary"
574+
onClick={() => props.onUseLastSuccessfulPrebuild && props.onUseLastSuccessfulPrebuild()}
575+
>
576+
Use Last Successful Prebuild
577+
</button>
568578
<button className="secondary" onClick={() => props.onIgnorePrebuild && props.onIgnorePrebuild()}>
569-
Skip Prebuild
579+
Don't Wait For Prebuild
570580
</button>
571581
</PrebuildLogs>
572582
</div>

components/gitpod-protocol/src/protocol.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,8 @@ export enum CreateWorkspaceMode {
13721372
UsePrebuild = "use-prebuild",
13731373
// SelectIfRunning returns a list of currently running workspaces for the context URL if there are any, otherwise falls back to Default mode
13741374
SelectIfRunning = "select-if-running",
1375+
// UseLastSuccessfulPrebuild returns ...
1376+
UseLastSuccessfulPrebuild = "use-last-successful-prebuild",
13751377
}
13761378

13771379
export namespace WorkspaceCreationResult {

components/server/ee/src/workspace/gitpod-server-impl.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,21 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
963963

964964
const logCtx: LogContext = { userId: user.id };
965965
const cloneUrl = context.repository.cloneUrl;
966+
if (mode === CreateWorkspaceMode.UseLastSuccessfulPrebuild) {
967+
const maxDepth = this.config.incrementalPrebuilds.commitHistory;
968+
const hostContext = this.hostContextProvider.get(context.repository.host);
969+
const repoProvider = hostContext?.services?.repositoryProvider;
970+
if (repoProvider) {
971+
const commitHistory = await repoProvider.getCommitHistory(
972+
user,
973+
context.repository.owner,
974+
context.repository.name,
975+
context.revision,
976+
maxDepth,
977+
);
978+
log.info("findPrebuiltWorkspace: incremental workspace", { commitHistory });
979+
}
980+
}
966981
const prebuiltWorkspace = await this.workspaceDb
967982
.trace(ctx)
968983
.findPrebuiltWorkspaceByCommit(cloneUrl, commitSHAs);

0 commit comments

Comments
 (0)