feat(workflow): resume a parked run from a chosen step
Each finished stage records the run's step results; a retry may name a resume point, and the next attempt skips the steps before it with their results loaded. A run with a repository resumes only on its pushed branch. The canvas offers Resume/Re-run from here on parked runs.
This commit is contained in:
37 files changed
+606
-88
No files matched your search
@@ -68,6 +68,24 @@ export function withRuns(graph: WorkflowGraph, stages: StageRun[]): WorkflowGrap
|
||||
};
|
||||
}
|
||||
|
||||
/** How a parked run can restart at a step: the top-level step it stopped at
|
||||
* resumes, earlier ones re-run. Later steps, and runs that are not parked,
|
||||
* offer nothing. */
|
||||
export interface Restart {
|
||||
label: "Resume from here" | "Re-run from here";
|
||||
from: string;
|
||||
}
|
||||
|
||||
export function restartAt(graph: WorkflowGraph, path: (string | number)[]): Restart | null {
|
||||
const top = (data: StepNodeData) => (data.path && data.path.length >= 2 ? Number(data.path[1]) : -1);
|
||||
const node = graph.nodes.find((candidate) => JSON.stringify(candidate.data.path) === JSON.stringify(path))?.data;
|
||||
if (!node?.stage) return null;
|
||||
const stopped = Math.max(-1, ...graph.nodes.filter((candidate) => candidate.data.run).map((candidate) => top(candidate.data)));
|
||||
const at = top(node);
|
||||
if (at < 0 || at > stopped) return null;
|
||||
return { label: at === stopped ? "Resume from here" : "Re-run from here", from: node.stage };
|
||||
}
|
||||
|
||||
export interface GraphNode {
|
||||
id: string;
|
||||
type: "step" | "add";
|
||||
|
||||
Reference in new issue
Block a user