MCPcopy Create free account
hub / github.com/delinoio/oss / jobTaskGraph

Function jobTaskGraph

scripts/ci/task-graph.mjs:32–87  ·  view source on GitHub ↗
(job)

Source from the content-addressed store, hash-verified

30// Contract checks follow dependencies as well as leaf commands so a cached
31// aggregate cannot silently lose a validation that used to live in Actions.
32export function jobTaskGraph(job) {
33 const graph = new Map();
34 function visit(workspace, name) {
35 const id = `${workspace}#${name}`;
36 if (graph.has(id)) return;
37 const owner = workspaces.get(workspace);
38 if (!owner) throw new Error(`Unknown workspace ${workspace}`);
39 const task = { ...(rootTasks[name] ?? {}), ...(owner.tasks[name] ?? {}) };
40 graph.set(id, { command: owner.manifest.scripts[name] ?? "", task });
41 for (const dep of task.dependsOn ?? []) {
42 if (dep.startsWith("^")) {
43 for (const [dependency, range] of Object.entries({
44 ...owner.manifest.dependencies,
45 ...owner.manifest.devDependencies,
46 })) {
47 if (range.startsWith("workspace:")) visit(dependency, dep.slice(1));
48 }
49 } else if (dep.includes("#")) visit(...dep.split("#"));
50 else visit(workspace, dep);
51 }
52 }
53 for (const { run } of job.steps) {
54 const match = run?.match(
55 /^node scripts\/ci\/run-affected\.mjs (\S+) (.+)$/u,
56 );
57 if (match) {
58 // The closed desktop matrix selects one phase at runtime. Contract
59 // inventory follows every phase without treating expression words as tasks.
60 if (match[2] === "ci:${{ matrix.phase }}") {
61 for (const phase of [
62 "checks",
63 "tests-1",
64 "tests-2",
65 "tests-3",
66 "tests-4",
67 ])
68 visit(match[1], `ci:${phase}`);
69 } else for (const name of match[2].split(" ")) visit(match[1], name);
70 }
71 const rust = run?.match(/^node scripts\/ci\/run-rust\.mjs (test|clippy)$/u);
72 if (rust) {
73 // Inventory includes every explicit selection variant. Runtime selects
74 // exactly one after validating the central package list.
75 for (const name of Object.keys(
76 workspaces.get("@delinoio/ci").manifest.scripts,
77 )) {
78 if (
79 name === `ci:rust:${rust[1]}` ||
80 name.startsWith(`ci:rust:${rust[1]}:`)
81 )
82 visit("@delinoio/ci", name);
83 }
84 }
85 }
86 return graph;
87}
88
89export function jobCommands(job) {

Callers 2

jobCommandsFunction · 0.85

Calls 2

visitFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected