willfire 0.1.34 → 0.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/execute.d.ts +2 -2
- package/dist/execute.js +8 -6
- package/dist/jobs/absentInputs.js +1 -1
- package/dist/jobs/evalIf.d.ts +1 -1
- package/dist/jobs/expandJobs.js +4 -6
- package/dist/jobs/workflowCallInputs.d.ts +2 -1
- package/dist/jobs/workflowCallInputs.js +1 -1
- package/dist/matrix/expandMatrix.d.ts +1 -1
- package/dist/matrix/expandMatrixDetailed.d.ts +1 -1
- package/dist/matrix/expandMatrixDetailed.js +7 -4
- package/dist/names/lookupPath.d.ts +1 -1
- package/dist/triggers/getPrTrigger.d.ts +2 -1
- package/dist/triggers/getPrTrigger.js +1 -1
- package/dist/triggers/workflowDispatches.js +3 -2
- package/dist/types.d.ts +4 -3
- package/package.json +1 -1
package/dist/execute.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* with a reason — never a guess.
|
|
7
7
|
*/
|
|
8
8
|
import { type Scope } from "./expr/val.js";
|
|
9
|
-
import type { ResolveRef, WorkflowSource } from "./types.js";
|
|
9
|
+
import type { ResolveRef, Workflow, WorkflowSource } from "./types.js";
|
|
10
10
|
/** A host path a sandboxed runner must expose inside, at the same path. */
|
|
11
11
|
export interface Mount {
|
|
12
12
|
path: string;
|
|
@@ -54,7 +54,7 @@ export type ExecOutcome = {
|
|
|
54
54
|
* running it yields.
|
|
55
55
|
*/
|
|
56
56
|
export interface JobExecutor {
|
|
57
|
-
executeJob(jobId: string, job:
|
|
57
|
+
executeJob(jobId: string, job: Workflow, wf: Workflow, scope: Scope): Promise<ExecOutcome>;
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Render every `${{ }}` to literal text, or null when any cannot be settled —
|
package/dist/execute.js
CHANGED
|
@@ -194,15 +194,16 @@ async function runSteps(steps, scope, ctx) {
|
|
|
194
194
|
/** A `uses:` step: a runner-provided postcondition, an action to run, or a stop. */
|
|
195
195
|
async function runUses(step, label, scope, ctx) {
|
|
196
196
|
const uses = step.uses;
|
|
197
|
+
const withBlock = step.with ?? {};
|
|
197
198
|
if (CHECKOUT_RE.test(uses)) {
|
|
198
199
|
// Runner-provided, and its postcondition — the head tree at the workspace
|
|
199
200
|
// path — is already true. Any input beyond `fetch-depth: 0` asks for a
|
|
200
201
|
// different tree than the one provided.
|
|
201
|
-
const withKeys = Object.keys(
|
|
202
|
+
const withKeys = Object.keys(withBlock);
|
|
202
203
|
if (withKeys.length === 0) {
|
|
203
204
|
return { ok: true, v: {} };
|
|
204
205
|
}
|
|
205
|
-
if (withKeys.length === 1 && String(
|
|
206
|
+
if (withKeys.length === 1 && String(withBlock["fetch-depth"]) === "0") {
|
|
206
207
|
// Unmet inside a composite: the pre-scan that picks the tree provider
|
|
207
208
|
// only reads the job's own steps.
|
|
208
209
|
if (!ctx.hasHistory) {
|
|
@@ -215,12 +216,12 @@ async function runUses(step, label, scope, ctx) {
|
|
|
215
216
|
if (SETUP_NODE_RE.test(uses)) {
|
|
216
217
|
// The execution world ships exactly one node: asking for it is already
|
|
217
218
|
// satisfied, asking for anything else cannot be.
|
|
218
|
-
const withKeys = Object.keys(
|
|
219
|
+
const withKeys = Object.keys(withBlock);
|
|
219
220
|
if (withKeys.length === 0) {
|
|
220
221
|
return { ok: true, v: {} };
|
|
221
222
|
}
|
|
222
223
|
if (withKeys.length === 1 && withKeys[0] === "node-version") {
|
|
223
|
-
const wanted = renderTemplate(String(
|
|
224
|
+
const wanted = renderTemplate(String(withBlock["node-version"]), scope);
|
|
224
225
|
if (wanted === null) {
|
|
225
226
|
return err(`${label}: cannot resolve node-version`);
|
|
226
227
|
}
|
|
@@ -467,9 +468,10 @@ export function makeExecutor(opts) {
|
|
|
467
468
|
if (!Array.isArray(job.steps)) {
|
|
468
469
|
return fail(`job '${jobId}' has no steps`);
|
|
469
470
|
}
|
|
471
|
+
const steps = job.steps;
|
|
470
472
|
// Any checkout input might be the `fetch-depth: 0` form. Over-asking for
|
|
471
473
|
// one the walk will refuse anyway costs a clone, never correctness.
|
|
472
|
-
const needsHistory =
|
|
474
|
+
const needsHistory = steps.some((s) => s !== null &&
|
|
473
475
|
s !== undefined &&
|
|
474
476
|
typeof s.uses === "string" &&
|
|
475
477
|
CHECKOUT_RE.test(s.uses) &&
|
|
@@ -479,7 +481,7 @@ export function makeExecutor(opts) {
|
|
|
479
481
|
return fail(`cannot materialize workspace ${workspace.owner}/${workspace.repo}@${workspace.sha}`);
|
|
480
482
|
}
|
|
481
483
|
const jobScope = { ...scope, github: { ...github, ...scope.github } };
|
|
482
|
-
const walked = await runSteps(
|
|
484
|
+
const walked = await runSteps(steps, jobScope, {
|
|
483
485
|
tree,
|
|
484
486
|
hasHistory: needsHistory,
|
|
485
487
|
envLayers: [wf?.env, job.env],
|
|
@@ -7,7 +7,7 @@ const INPUT_TRIGGERS = ["workflow_dispatch", "workflow_call"];
|
|
|
7
7
|
*/
|
|
8
8
|
export function absentInputs(wf) {
|
|
9
9
|
// Tolerates the YAML 1.1 `on` -> true key, as the callee's own lookup does.
|
|
10
|
-
const on = wf["on"] ?? wf["true"];
|
|
10
|
+
const on = (wf["on"] ?? wf["true"]);
|
|
11
11
|
const out = {};
|
|
12
12
|
for (const trigger of INPUT_TRIGGERS) {
|
|
13
13
|
for (const name of Object.keys(on?.[trigger]?.["inputs"] ?? {})) {
|
package/dist/jobs/evalIf.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ import type { Scope } from "../expr/val.js";
|
|
|
7
7
|
* unknown, because every one of them is written against `inputs.*` or
|
|
8
8
|
* `needs.*`.
|
|
9
9
|
*/
|
|
10
|
-
export declare function evalIf(cond:
|
|
10
|
+
export declare function evalIf(cond: unknown, scope?: Scope): "run" | "skipped" | "unknown";
|
package/dist/jobs/expandJobs.js
CHANGED
|
@@ -22,7 +22,7 @@ const SHA_RE = /^[0-9a-f]{40}$/i;
|
|
|
22
22
|
const isSha = (ref) => SHA_RE.test(ref);
|
|
23
23
|
export async function expandJobs(wf, ctx, reader, source, depth = 0, prefix = "", prefixResolved = true, scope = {}, executor) {
|
|
24
24
|
const entries = [];
|
|
25
|
-
const jobs = wf
|
|
25
|
+
const jobs = (wf["jobs"] ?? {});
|
|
26
26
|
const statuses = {};
|
|
27
27
|
// Nothing dispatched or called this run, so an input this workflow declares
|
|
28
28
|
// and nothing supplied reads as the empty string (#125) — laid under, never
|
|
@@ -57,10 +57,8 @@ export async function expandJobs(wf, ctx, reader, source, depth = 0, prefix = ""
|
|
|
57
57
|
const job = jobRaw ?? {};
|
|
58
58
|
let status = evalIf(job.if, scoped);
|
|
59
59
|
let reason = job.if !== undefined && job.if !== null ? `if: ${JSON.stringify(job.if)}` : "";
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
needs = [needs];
|
|
63
|
-
}
|
|
60
|
+
const needsRaw = job["needs"];
|
|
61
|
+
const needs = typeof needsRaw === "string" ? [needsRaw] : (needsRaw ?? []);
|
|
64
62
|
const cond = String(job.if ?? "");
|
|
65
63
|
if (status !== "skipped" && !cond.includes("always()")) {
|
|
66
64
|
for (const n of needs) {
|
|
@@ -94,7 +92,7 @@ export async function expandJobs(wf, ctx, reader, source, depth = 0, prefix = ""
|
|
|
94
92
|
// call names its checks exactly the same way a local one does — probe
|
|
95
93
|
// PR #9, `call-remote-tag / r-inner` alongside `call-plain / inner`.
|
|
96
94
|
const combos = expandMatrixDetailed(job.strategy, prScope(scoped));
|
|
97
|
-
const uses = job
|
|
95
|
+
const uses = job["uses"];
|
|
98
96
|
if (combos === null) {
|
|
99
97
|
entries.push({
|
|
100
98
|
job: prefix + jobId,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Workflow } from "../types.js";
|
|
2
|
+
import type { YamlMap } from "../yamlValue.js";
|
|
2
3
|
/** The `on.workflow_call.inputs` block, tolerating the YAML 1.1 `on` -> true key. */
|
|
3
|
-
export declare function workflowCallInputs(wf: Workflow):
|
|
4
|
+
export declare function workflowCallInputs(wf: Workflow): YamlMap;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** The `on.workflow_call.inputs` block, tolerating the YAML 1.1 `on` -> true key. */
|
|
2
2
|
export function workflowCallInputs(wf) {
|
|
3
|
-
const on = wf?.["on"] ?? wf?.["true"];
|
|
3
|
+
const on = (wf?.["on"] ?? wf?.["true"]);
|
|
4
4
|
const inputs = on?.["workflow_call"]?.["inputs"];
|
|
5
5
|
return inputs !== null && typeof inputs === "object" ? inputs : {};
|
|
6
6
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Scope } from "../expr/val.js";
|
|
2
2
|
import type { Combo } from "../types.js";
|
|
3
3
|
/** Return list of matrix combination dicts, or null if dynamic. */
|
|
4
|
-
export declare function expandMatrix(strategy:
|
|
4
|
+
export declare function expandMatrix(strategy: unknown, scope?: Scope): Combo[] | null;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Scope } from "../expr/val.js";
|
|
2
2
|
import type { DetailedCombos } from "../types.js";
|
|
3
|
-
export declare function expandMatrixDetailed(strategy:
|
|
3
|
+
export declare function expandMatrixDetailed(strategy: unknown, scope?: Scope): DetailedCombos;
|
|
@@ -42,7 +42,9 @@ function comboList(v, scope) {
|
|
|
42
42
|
return val.v;
|
|
43
43
|
}
|
|
44
44
|
export function expandMatrixDetailed(strategy, scope = {}) {
|
|
45
|
-
const matrix = strategy
|
|
45
|
+
const matrix = strategy !== null && typeof strategy === "object"
|
|
46
|
+
? strategy["matrix"]
|
|
47
|
+
: undefined;
|
|
46
48
|
if (matrix === null || matrix === undefined) {
|
|
47
49
|
return [null];
|
|
48
50
|
}
|
|
@@ -52,13 +54,14 @@ export function expandMatrixDetailed(strategy, scope = {}) {
|
|
|
52
54
|
if (typeof matrix === "string") {
|
|
53
55
|
return null;
|
|
54
56
|
}
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
+
const m = matrix;
|
|
58
|
+
const include = comboList(m["include"], scope);
|
|
59
|
+
const exclude = comboList(m["exclude"], scope);
|
|
57
60
|
if (include === null || exclude === null) {
|
|
58
61
|
return null;
|
|
59
62
|
}
|
|
60
63
|
const axes = {};
|
|
61
|
-
for (const [k, v] of Object.entries(
|
|
64
|
+
for (const [k, v] of Object.entries(m)) {
|
|
62
65
|
if (k !== "include" && k !== "exclude") {
|
|
63
66
|
const vals = axisValues(v, scope);
|
|
64
67
|
if (vals === null) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { YamlValue } from "../yamlValue.js";
|
|
2
|
-
export declare function lookupPath(obj:
|
|
2
|
+
export declare function lookupPath(obj: YamlValue | undefined, path: string): YamlValue | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Workflow } from "../types.js";
|
|
2
|
+
import type { YamlMap } from "../yamlValue.js";
|
|
2
3
|
export declare const MISSING: unique symbol;
|
|
3
|
-
export declare function getPrTrigger(wf: Workflow):
|
|
4
|
+
export declare function getPrTrigger(wf: Workflow): YamlMap | typeof MISSING;
|
|
@@ -10,7 +10,7 @@ export function workflowDispatches(wf, ctx) {
|
|
|
10
10
|
if (trig === MISSING) {
|
|
11
11
|
return [false, "no pull_request trigger"];
|
|
12
12
|
}
|
|
13
|
-
const types = trig["types"] ?? DEFAULT_TYPES;
|
|
13
|
+
const types = (trig["types"] ?? DEFAULT_TYPES);
|
|
14
14
|
if (!types.includes(ctx.action)) {
|
|
15
15
|
return [false, `action '${ctx.action}' not in types [${types}]`];
|
|
16
16
|
}
|
|
@@ -39,7 +39,8 @@ export function workflowDispatches(wf, ctx) {
|
|
|
39
39
|
if ("paths" in trig && !ctx.files.some((f) => matchFilters(f, trig["paths"]))) {
|
|
40
40
|
return [false, "no changed file matches paths"];
|
|
41
41
|
}
|
|
42
|
-
if ("paths-ignore" in trig &&
|
|
42
|
+
if ("paths-ignore" in trig &&
|
|
43
|
+
ctx.files.every((f) => matchFilters(f, trig["paths-ignore"]))) {
|
|
43
44
|
return [false, "all changed files match paths-ignore"];
|
|
44
45
|
}
|
|
45
46
|
return [true, "trigger matched"];
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { JobExecutor } from "./execute.js";
|
|
2
|
+
import type { YamlMap } from "./yamlValue.js";
|
|
2
3
|
export interface EntryBase {
|
|
3
4
|
workflow: string;
|
|
4
5
|
reason: string;
|
|
@@ -134,8 +135,8 @@ export interface Ctx {
|
|
|
134
135
|
stackTarget?: string;
|
|
135
136
|
files: string[];
|
|
136
137
|
}
|
|
137
|
-
export type Workflow =
|
|
138
|
-
export type Combo =
|
|
138
|
+
export type Workflow = YamlMap;
|
|
139
|
+
export type Combo = YamlMap | null;
|
|
139
140
|
/**
|
|
140
141
|
* A matrix combination plus the keys that appear in its check-name
|
|
141
142
|
* parenthetical. The two differ: a key contributed by an `include` entry that
|
|
@@ -148,7 +149,7 @@ export type Combo = Record<string, any> | null;
|
|
|
148
149
|
* created from scratch shows all of its own keys.
|
|
149
150
|
*/
|
|
150
151
|
export interface DetailedCombo {
|
|
151
|
-
values:
|
|
152
|
+
values: YamlMap;
|
|
152
153
|
displayKeys: string[];
|
|
153
154
|
}
|
|
154
155
|
/**
|