gagen 0.2.4 → 0.2.6
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/README.md +48 -50
- package/esm/expression.d.ts +55 -2
- package/esm/expression.d.ts.map +1 -1
- package/esm/expression.js +66 -5
- package/esm/job.js +2 -2
- package/esm/matrix.d.ts.map +1 -1
- package/esm/matrix.js +19 -2
- package/esm/mod.d.ts +1 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/step.d.ts +15 -2
- package/esm/step.d.ts.map +1 -1
- package/esm/step.js +45 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,28 +20,28 @@ const checkout = step({
|
|
|
20
20
|
uses: "actions/checkout@v6",
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
const test = step({
|
|
23
|
+
const test = step.dependsOn(checkout)({
|
|
24
24
|
name: "Test",
|
|
25
25
|
run: "cargo test",
|
|
26
|
-
})
|
|
26
|
+
});
|
|
27
27
|
|
|
28
28
|
const installDeno = step({
|
|
29
29
|
uses: "denoland/setup-deno@v2",
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
const lint = step
|
|
33
|
-
{
|
|
34
|
-
name: "Clippy",
|
|
35
|
-
run: "cargo clippy",
|
|
36
|
-
},
|
|
37
|
-
step({
|
|
38
|
-
name: "Deno Lint",
|
|
39
|
-
run: "deno lint",
|
|
40
|
-
}).dependsOn(installDeno),
|
|
41
|
-
)
|
|
32
|
+
const lint = step
|
|
42
33
|
.dependsOn(checkout)
|
|
43
34
|
// this condition gets propagated to installDeno, but not checkout
|
|
44
|
-
.if(conditions.isBranch("main").not())
|
|
35
|
+
.if(conditions.isBranch("main").not())(
|
|
36
|
+
{
|
|
37
|
+
name: "Clippy",
|
|
38
|
+
run: "cargo clippy",
|
|
39
|
+
},
|
|
40
|
+
step.dependsOn(installDeno)({
|
|
41
|
+
name: "Deno Lint",
|
|
42
|
+
run: "deno lint",
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
45
|
|
|
46
46
|
// only specify the leaf steps — the other steps are pulled in automatically
|
|
47
47
|
createWorkflow({
|
|
@@ -95,11 +95,12 @@ os.equals("linux").and(ref.startsWith("refs/tags/"));
|
|
|
95
95
|
// => matrix.os == 'linux' && startsWith(github.ref, 'refs/tags/')
|
|
96
96
|
|
|
97
97
|
// use on steps
|
|
98
|
-
const deploy = step(
|
|
98
|
+
const deploy = step.dependsOn(build).if(
|
|
99
|
+
ref.equals("refs/heads/main").and(os.equals("linux")),
|
|
100
|
+
)({
|
|
99
101
|
name: "Deploy",
|
|
100
102
|
run: "deploy.sh",
|
|
101
|
-
|
|
102
|
-
}).dependsOn(build);
|
|
103
|
+
});
|
|
103
104
|
```
|
|
104
105
|
|
|
105
106
|
## Common conditions
|
|
@@ -128,17 +129,15 @@ isEvent("push"); // github.event_name == 'push'
|
|
|
128
129
|
isEvent("pull_request"); // github.event_name == 'pull_request'
|
|
129
130
|
|
|
130
131
|
// compose freely with .and() / .or() / .not()
|
|
131
|
-
const deploy = step({
|
|
132
|
+
const deploy = step.dependsOn(build).if(isBranch("main").and(isEvent("push")))({
|
|
132
133
|
name: "Deploy",
|
|
133
134
|
run: "deploy.sh",
|
|
134
|
-
|
|
135
|
-
}).dependsOn(build);
|
|
135
|
+
});
|
|
136
136
|
|
|
137
|
-
const cleanup = step({
|
|
137
|
+
const cleanup = step.dependsOn(build).if(status.always())({
|
|
138
138
|
name: "Cleanup",
|
|
139
139
|
run: "rm -rf dist",
|
|
140
|
-
|
|
141
|
-
}).dependsOn(build);
|
|
140
|
+
});
|
|
142
141
|
```
|
|
143
142
|
|
|
144
143
|
## Ternary expressions
|
|
@@ -179,11 +178,10 @@ This avoids running expensive setup steps when they aren't needed:
|
|
|
179
178
|
|
|
180
179
|
```ts
|
|
181
180
|
const checkout = step({ uses: "actions/checkout@v6" });
|
|
182
|
-
const build = step({ run: "cargo build" })
|
|
183
|
-
const test = step({
|
|
181
|
+
const build = step.dependsOn(checkout)({ run: "cargo build" });
|
|
182
|
+
const test = step.dependsOn(build).if(expr("matrix.job").equals("test"))({
|
|
184
183
|
run: "cargo test",
|
|
185
|
-
|
|
186
|
-
}).dependsOn(build);
|
|
184
|
+
});
|
|
187
185
|
|
|
188
186
|
// only test is passed — checkout and build inherit its condition
|
|
189
187
|
createWorkflow({
|
|
@@ -199,11 +197,12 @@ When multiple leaf steps have different conditions, dependencies get the OR of
|
|
|
199
197
|
those conditions:
|
|
200
198
|
|
|
201
199
|
```ts
|
|
202
|
-
const test = step(
|
|
203
|
-
|
|
204
|
-
);
|
|
205
|
-
const bench = step(
|
|
206
|
-
|
|
200
|
+
const test = step.dependsOn(checkout).if(jobExpr.equals("test"))({
|
|
201
|
+
run: "cargo test",
|
|
202
|
+
});
|
|
203
|
+
const bench = step.dependsOn(checkout).if(jobExpr.equals("bench"))({
|
|
204
|
+
run: "cargo bench",
|
|
205
|
+
});
|
|
207
206
|
|
|
208
207
|
createWorkflow({
|
|
209
208
|
...,
|
|
@@ -218,12 +217,11 @@ To prevent propagation, pass the unconditional steps to `steps` as well. Leaf
|
|
|
218
217
|
steps act as propagation barriers:
|
|
219
218
|
|
|
220
219
|
```ts
|
|
221
|
-
const build = step({ run: "cargo build" })
|
|
222
|
-
const test = step({ run: "cargo test" })
|
|
223
|
-
const linuxOnly = step({
|
|
220
|
+
const build = step.dependsOn(checkout)({ run: "cargo build" });
|
|
221
|
+
const test = step.dependsOn(build)({ run: "cargo test" });
|
|
222
|
+
const linuxOnly = step.dependsOn(build, test).if(os.equals("linux"))({
|
|
224
223
|
run: "linux-specific",
|
|
225
|
-
|
|
226
|
-
}).dependsOn(build, test);
|
|
224
|
+
});
|
|
227
225
|
|
|
228
226
|
// test is a leaf with no condition — blocks propagation to build and checkout
|
|
229
227
|
createWorkflow({
|
|
@@ -280,12 +278,12 @@ topologically sorted:
|
|
|
280
278
|
|
|
281
279
|
```ts
|
|
282
280
|
const checkout = step({ name: "Checkout", uses: "actions/checkout@v6" });
|
|
283
|
-
const buildA = step({ name: "Build A", run: "make a" })
|
|
284
|
-
const buildB = step({ name: "Build B", run: "make b" })
|
|
285
|
-
const integrate = step(
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
);
|
|
281
|
+
const buildA = step.dependsOn(checkout)({ name: "Build A", run: "make a" });
|
|
282
|
+
const buildB = step.dependsOn(checkout)({ name: "Build B", run: "make b" });
|
|
283
|
+
const integrate = step.dependsOn(buildA, buildB)({
|
|
284
|
+
name: "Integrate",
|
|
285
|
+
run: "make all",
|
|
286
|
+
});
|
|
289
287
|
|
|
290
288
|
createWorkflow({
|
|
291
289
|
...,
|
|
@@ -309,11 +307,10 @@ const setupDeno = step({
|
|
|
309
307
|
with: { "deno-version": "canary" },
|
|
310
308
|
});
|
|
311
309
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const
|
|
316
|
-
const lint = step({ run: "deno lint" }).dependsOn(setupDeno, checkout);
|
|
310
|
+
// ensure checkout runs after setupDeno, without making checkout depend on it
|
|
311
|
+
const checkout = step.comesAfter(setupDeno)({ uses: "actions/checkout@v6" });
|
|
312
|
+
const build = step.dependsOn(checkout)({ run: "cargo build" });
|
|
313
|
+
const lint = step.dependsOn(setupDeno, checkout)({ run: "deno lint" });
|
|
317
314
|
|
|
318
315
|
createWorkflow({
|
|
319
316
|
...,
|
|
@@ -493,9 +490,10 @@ const buildStep = step({ name: "Build", run: "make build" });
|
|
|
493
490
|
const upload = artifact.upload({ path: "dist/", retentionDays: 5 });
|
|
494
491
|
|
|
495
492
|
const download = artifact.download({ path: "dist/" });
|
|
496
|
-
const deployStep = step
|
|
497
|
-
|
|
498
|
-
|
|
493
|
+
const deployStep = step.dependsOn(download)({
|
|
494
|
+
name: "Deploy",
|
|
495
|
+
run: "make deploy",
|
|
496
|
+
});
|
|
499
497
|
|
|
500
498
|
const wf = createWorkflow({
|
|
501
499
|
name: "CI",
|
package/esm/expression.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export declare class ExpressionValue {
|
|
|
31
31
|
export declare abstract class Condition {
|
|
32
32
|
readonly sources: ReadonlySet<ExpressionSource>;
|
|
33
33
|
constructor(sources: ReadonlySet<ExpressionSource>);
|
|
34
|
-
and(other: Condition): Condition;
|
|
35
|
-
or(other: Condition): Condition;
|
|
34
|
+
and(other: Condition | boolean): Condition;
|
|
35
|
+
or(other: Condition | boolean): Condition;
|
|
36
36
|
not(): Condition;
|
|
37
37
|
/**
|
|
38
38
|
* Starts a ternary expression: `condition && trueValue || falseValue`.
|
|
@@ -117,6 +117,59 @@ export declare const conditions: {
|
|
|
117
117
|
* ```
|
|
118
118
|
*/
|
|
119
119
|
readonly isEvent: (event: string) => Condition;
|
|
120
|
+
/**
|
|
121
|
+
* Check if the event is a pull request.
|
|
122
|
+
*
|
|
123
|
+
* ```ts
|
|
124
|
+
* conditions.isPr() // github.event_name == 'pull_request'
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
readonly isPr: () => Condition;
|
|
128
|
+
/**
|
|
129
|
+
* Check the repository (owner/name).
|
|
130
|
+
*
|
|
131
|
+
* ```ts
|
|
132
|
+
* conditions.isRepository("denoland/deno") // github.repository == 'denoland/deno'
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
readonly isRepository: (repo: string) => Condition;
|
|
136
|
+
/**
|
|
137
|
+
* Check if the pull request is a draft.
|
|
138
|
+
*
|
|
139
|
+
* ```ts
|
|
140
|
+
* conditions.isDraftPr() // github.event.pull_request.draft == true
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
readonly isDraftPr: () => Condition;
|
|
144
|
+
/**
|
|
145
|
+
* Check if the pull request has a specific label.
|
|
146
|
+
*
|
|
147
|
+
* ```ts
|
|
148
|
+
* conditions.hasLabel("ci-full") // contains(github.event.pull_request.labels.*.name, 'ci-full')
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
readonly hasPrLabel: (label: string) => Condition;
|
|
152
|
+
/**
|
|
153
|
+
* Check the runner operating system.
|
|
154
|
+
*
|
|
155
|
+
* ```ts
|
|
156
|
+
* conditions.isRunnerOs("Linux") // runner.os == 'Linux'
|
|
157
|
+
* conditions.isRunnerOs("macOS") // runner.os == 'macOS'
|
|
158
|
+
* conditions.isRunnerOs("Windows") // runner.os == 'Windows'
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
readonly isRunnerOs: (os: "Linux" | "macOS" | "Windows") => Condition;
|
|
162
|
+
/**
|
|
163
|
+
* Check the runner architecture.
|
|
164
|
+
*
|
|
165
|
+
* ```ts
|
|
166
|
+
* conditions.isRunnerArch("X86") // runner.arch == 'X86'
|
|
167
|
+
* conditions.isRunnerArch("X64") // runner.arch == 'X64'
|
|
168
|
+
* conditions.isRunnerArch("ARM") // runner.arch == 'ARM'
|
|
169
|
+
* conditions.isRunnerArch("ARM64") // runner.arch == 'ARM64'
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
readonly isRunnerArch: (arch: "X86" | "X64" | "ARM" | "ARM64") => Condition;
|
|
120
173
|
};
|
|
121
174
|
export declare function formatLiteral(value: string | number | boolean): string;
|
|
122
175
|
export declare function sourcesFrom(...sourceables: ({
|
package/esm/expression.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../src/expression.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,gBAAgB,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAIvD,wEAAwE;AACxE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,eAAe,CAAC;AAEvE;;;GAGG;AACH,qBAAa,eAAe;;IAE1B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAAC;gBAI5C,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,gBAAgB,GAAG,WAAW,CAAC,gBAAgB,CA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AAC;IACrB,KAAK,EAAE,YAAY,CAAC;CACrB;AA+BD;;;GAGG;AACH,qBAAa,WAAW;;gBAKpB,QAAQ,EAAE,aAAa,EAAE,EACzB,OAAO,EAAE,WAAW,CAAC,gBAAgB,CAAC;IAOxC,sCAAsC;IACtC,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,aAAa;IAI3C;;;;;;;OAOG;IACH,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,eAAe;CAiB3C;AAED;;;GAGG;AACH,qBAAa,aAAa;;gBAMtB,QAAQ,EAAE,aAAa,EAAE,EACzB,OAAO,EAAE,GAAG,CAAC,gBAAgB,CAAC,EAC9B,SAAS,EAAE,SAAS;IAQtB,yCAAyC;IACzC,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,WAAW;CAMvC"}
|
package/esm/expression.js
CHANGED
|
@@ -81,9 +81,17 @@ export class Condition {
|
|
|
81
81
|
this.sources = sources;
|
|
82
82
|
}
|
|
83
83
|
and(other) {
|
|
84
|
+
if (other === true)
|
|
85
|
+
return this;
|
|
86
|
+
if (other === false)
|
|
87
|
+
return new RawCondition("false", this.sources);
|
|
84
88
|
return new LogicalCondition("&&", this, other, unionSources(this, other));
|
|
85
89
|
}
|
|
86
90
|
or(other) {
|
|
91
|
+
if (other === false)
|
|
92
|
+
return this;
|
|
93
|
+
if (other === true)
|
|
94
|
+
return new RawCondition("true", this.sources);
|
|
87
95
|
return new LogicalCondition("||", this, other, unionSources(this, other));
|
|
88
96
|
}
|
|
89
97
|
not() {
|
|
@@ -245,6 +253,8 @@ _RawCondition_expression = new WeakMap();
|
|
|
245
253
|
export function expr(expression) {
|
|
246
254
|
return new ExpressionValue(expression);
|
|
247
255
|
}
|
|
256
|
+
const ref = expr("github.ref");
|
|
257
|
+
const eventName = expr("github.event_name");
|
|
248
258
|
/** Common condition helpers for GitHub Actions workflows. */
|
|
249
259
|
export const conditions = {
|
|
250
260
|
/** Status check functions for use in step/job `if` fields. */
|
|
@@ -267,9 +277,7 @@ export const conditions = {
|
|
|
267
277
|
* conditions.isTag("v1.0.0") // github.ref == 'refs/tags/v1.0.0'
|
|
268
278
|
* ```
|
|
269
279
|
*/
|
|
270
|
-
isTag: (tag) => tag != null
|
|
271
|
-
? new ComparisonCondition("github.ref", "==", `refs/tags/${tag}`, EMPTY_SOURCES)
|
|
272
|
-
: new FunctionCallCondition("startsWith", ["github.ref", "'refs/tags/'"], EMPTY_SOURCES),
|
|
280
|
+
isTag: (tag) => tag != null ? ref.equals(`refs/tags/${tag}`) : ref.startsWith("refs/tags/"),
|
|
273
281
|
/**
|
|
274
282
|
* Check if the ref is a specific branch.
|
|
275
283
|
*
|
|
@@ -277,7 +285,7 @@ export const conditions = {
|
|
|
277
285
|
* conditions.isBranch("main") // github.ref == 'refs/heads/main'
|
|
278
286
|
* ```
|
|
279
287
|
*/
|
|
280
|
-
isBranch: (branch) =>
|
|
288
|
+
isBranch: (branch) => ref.equals(`refs/heads/${branch}`),
|
|
281
289
|
/**
|
|
282
290
|
* Check the event that triggered the workflow.
|
|
283
291
|
*
|
|
@@ -285,7 +293,60 @@ export const conditions = {
|
|
|
285
293
|
* conditions.isEvent("pull_request") // github.event_name == 'pull_request'
|
|
286
294
|
* ```
|
|
287
295
|
*/
|
|
288
|
-
isEvent: (event) =>
|
|
296
|
+
isEvent: (event) => eventName.equals(event),
|
|
297
|
+
/**
|
|
298
|
+
* Check if the event is a pull request.
|
|
299
|
+
*
|
|
300
|
+
* ```ts
|
|
301
|
+
* conditions.isPr() // github.event_name == 'pull_request'
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
isPr: () => eventName.equals("pull_request"),
|
|
305
|
+
/**
|
|
306
|
+
* Check the repository (owner/name).
|
|
307
|
+
*
|
|
308
|
+
* ```ts
|
|
309
|
+
* conditions.isRepository("denoland/deno") // github.repository == 'denoland/deno'
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
isRepository: (repo) => expr("github.repository").equals(repo),
|
|
313
|
+
/**
|
|
314
|
+
* Check if the pull request is a draft.
|
|
315
|
+
*
|
|
316
|
+
* ```ts
|
|
317
|
+
* conditions.isDraftPr() // github.event.pull_request.draft == true
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
isDraftPr: () => expr("github.event.pull_request.draft").equals(true),
|
|
321
|
+
/**
|
|
322
|
+
* Check if the pull request has a specific label.
|
|
323
|
+
*
|
|
324
|
+
* ```ts
|
|
325
|
+
* conditions.hasLabel("ci-full") // contains(github.event.pull_request.labels.*.name, 'ci-full')
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
hasPrLabel: (label) => expr("github.event.pull_request.labels.*.name").contains(label),
|
|
329
|
+
/**
|
|
330
|
+
* Check the runner operating system.
|
|
331
|
+
*
|
|
332
|
+
* ```ts
|
|
333
|
+
* conditions.isRunnerOs("Linux") // runner.os == 'Linux'
|
|
334
|
+
* conditions.isRunnerOs("macOS") // runner.os == 'macOS'
|
|
335
|
+
* conditions.isRunnerOs("Windows") // runner.os == 'Windows'
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
isRunnerOs: (os) => expr("runner.os").equals(os),
|
|
339
|
+
/**
|
|
340
|
+
* Check the runner architecture.
|
|
341
|
+
*
|
|
342
|
+
* ```ts
|
|
343
|
+
* conditions.isRunnerArch("X86") // runner.arch == 'X86'
|
|
344
|
+
* conditions.isRunnerArch("X64") // runner.arch == 'X64'
|
|
345
|
+
* conditions.isRunnerArch("ARM") // runner.arch == 'ARM'
|
|
346
|
+
* conditions.isRunnerArch("ARM64") // runner.arch == 'ARM64'
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
isRunnerArch: (arch) => expr("runner.arch").equals(arch),
|
|
289
350
|
};
|
|
290
351
|
// --- helpers ---
|
|
291
352
|
export function formatLiteral(value) {
|
package/esm/job.js
CHANGED
|
@@ -395,9 +395,9 @@ export class Job {
|
|
|
395
395
|
}
|
|
396
396
|
if (config.strategy.failFast != null) {
|
|
397
397
|
const ff = config.strategy.failFast;
|
|
398
|
-
s["fail-fast"] = typeof ff === "boolean"
|
|
398
|
+
s["fail-fast"] = typeof ff === "boolean" || typeof ff === "string"
|
|
399
399
|
? ff
|
|
400
|
-
:
|
|
400
|
+
: ff.toString();
|
|
401
401
|
}
|
|
402
402
|
if (config.strategy.maxParallel != null) {
|
|
403
403
|
s["max-parallel"] = config.strategy.maxParallel;
|
package/esm/matrix.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE7D,KAAK,iBAAiB,CAAC,CAAC,IACpB,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC,GAChD,CAAC,CAAC,SAAS;IAAE,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAA;CAAE,GAAG,MAAM,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC;AAoB7E,qBAAa,MAAM,CAAC,EAAE,SAAS,MAAM;;gBAGvB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;IASxD,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAGlC;AAED,KAAK,eAAe,CAAC,CAAC,SAAS,MAAM,IACjC,MAAM,CAAC,CAAC,CAAC,GACT;IACA,QAAQ,EAAE,CAAC,IAAI,CAAC,GAAG,eAAe;CACnC,CAAC;AAEJ,wBAAgB,YAAY,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,GAAG,EAAE,CAAC,GACL,eAAe,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAkBvC"}
|
package/esm/matrix.js
CHANGED
|
@@ -10,7 +10,24 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _Matrix_def;
|
|
13
|
-
import { ExpressionValue } from "./expression.js";
|
|
13
|
+
import { Condition, ExpressionValue } from "./expression.js";
|
|
14
|
+
/** Recursively serializes Condition/ExpressionValue objects to ${{ }} strings. */
|
|
15
|
+
function serializeValue(value) {
|
|
16
|
+
if (value instanceof Condition || value instanceof ExpressionValue) {
|
|
17
|
+
return value.toString();
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
return value.map(serializeValue);
|
|
21
|
+
}
|
|
22
|
+
if (typeof value === "object" && value !== null) {
|
|
23
|
+
const result = {};
|
|
24
|
+
for (const [k, v] of Object.entries(value)) {
|
|
25
|
+
result[k] = serializeValue(v);
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
14
31
|
export class Matrix {
|
|
15
32
|
constructor(def, keys) {
|
|
16
33
|
_Matrix_def.set(this, void 0);
|
|
@@ -20,7 +37,7 @@ export class Matrix {
|
|
|
20
37
|
}
|
|
21
38
|
}
|
|
22
39
|
toYaml() {
|
|
23
|
-
return __classPrivateFieldGet(this, _Matrix_def, "f");
|
|
40
|
+
return serializeValue(__classPrivateFieldGet(this, _Matrix_def, "f"));
|
|
24
41
|
}
|
|
25
42
|
}
|
|
26
43
|
_Matrix_def = new WeakMap();
|
package/esm/mod.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./_dnt.polyfills.js";
|
|
2
2
|
export { Step, step, StepRef } from "./step.js";
|
|
3
|
-
export type { ConditionLike, ConfigValue, StepConfig, StepLike, } from "./step.js";
|
|
3
|
+
export type { ConditionLike, ConfigValue, StepBuilder, StepConfig, StepFunction, StepLike, } from "./step.js";
|
|
4
4
|
export { Job, job } from "./job.js";
|
|
5
5
|
export type { JobConfig, JobDef, ReusableJobConfig, ReusableJobDef, ServiceContainer, StepsJobConfig, StepsJobDef, } from "./job.js";
|
|
6
6
|
export { createWorkflow, isLinting, Workflow } from "./workflow.js";
|
package/esm/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAChD,YAAY,EACV,aAAa,EACb,WAAW,EACX,UAAU,EACV,QAAQ,GACT,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,YAAY,EACV,SAAS,EACT,MAAM,EACN,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpE,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EACT,UAAU,EACV,aAAa,EACb,IAAI,EACJ,eAAe,EACf,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EACV,eAAe,EACf,WAAW,EACX,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACzD,YAAY,EACV,eAAe,EACf,cAAc,EACd,YAAY,GACb,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAChD,YAAY,EACV,aAAa,EACb,WAAW,EACX,WAAW,EACX,UAAU,EACV,YAAY,EACZ,QAAQ,GACT,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,YAAY,EACV,SAAS,EACT,MAAM,EACN,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpE,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EACT,UAAU,EACV,aAAa,EACb,IAAI,EACJ,eAAe,EACf,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EACV,eAAe,EACf,WAAW,EACX,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACzD,YAAY,EACV,eAAe,EACf,cAAc,EACd,YAAY,GACb,MAAM,eAAe,CAAC"}
|
package/esm/step.d.ts
CHANGED
|
@@ -33,8 +33,21 @@ export declare class Step<O extends string = never> implements ExpressionSource
|
|
|
33
33
|
if(condition: ConditionLike): StepRef<O>;
|
|
34
34
|
toYaml(effectiveIf?: Condition): Record<string, unknown>;
|
|
35
35
|
}
|
|
36
|
-
export
|
|
37
|
-
|
|
36
|
+
export interface StepBuilder {
|
|
37
|
+
<const O extends string = never>(config: StepConfig<O>): StepRef<O>;
|
|
38
|
+
(first: Step<string> | StepRef<string> | StepConfig, second: Step<string> | StepRef<string> | StepConfig, ...rest: (Step<string> | StepRef<string> | StepConfig)[]): StepRef<never>;
|
|
39
|
+
if(condition: ConditionLike): StepBuilder;
|
|
40
|
+
dependsOn(...deps: StepLike[]): StepBuilder;
|
|
41
|
+
comesAfter(...deps: StepLike[]): StepBuilder;
|
|
42
|
+
}
|
|
43
|
+
export interface StepFunction {
|
|
44
|
+
<const O extends string = never>(config: StepConfig<O>): Step<O>;
|
|
45
|
+
(first: Step<string> | StepRef<string> | StepConfig, second: Step<string> | StepRef<string> | StepConfig, ...rest: (Step<string> | StepRef<string> | StepConfig)[]): Step<never>;
|
|
46
|
+
if(condition: ConditionLike): StepBuilder;
|
|
47
|
+
dependsOn(...deps: StepLike[]): StepBuilder;
|
|
48
|
+
comesAfter(...deps: StepLike[]): StepBuilder;
|
|
49
|
+
}
|
|
50
|
+
export declare const step: StepFunction;
|
|
38
51
|
export declare class StepRef<O extends string = never> {
|
|
39
52
|
readonly step: Step<O>;
|
|
40
53
|
readonly condition?: ConditionLike;
|
package/esm/step.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../src/step.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,gBAAgB,EACrB,eAAe,EAGhB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,eAAe,GAAG,MAAM,CAAC;AACjE,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAA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,CAAC,CAAC,CAAC;CAOzC;AAID,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,CAQ/D;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,aAAa,GAAG,SAAS,CAMvD;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAClC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAM3C;AAID,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAE7E;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAM1D"}
|
package/esm/step.js
CHANGED
|
@@ -129,7 +129,7 @@ export class Step {
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
_Step_id = new WeakMap();
|
|
132
|
-
|
|
132
|
+
function buildStepFromArgs(...args) {
|
|
133
133
|
if (args.length === 1) {
|
|
134
134
|
return new Step(args[0]);
|
|
135
135
|
}
|
|
@@ -144,6 +144,49 @@ export function step(...args) {
|
|
|
144
144
|
}
|
|
145
145
|
return new Step(children);
|
|
146
146
|
}
|
|
147
|
+
function andConditions(existing, added) {
|
|
148
|
+
return existing != null
|
|
149
|
+
? toCondition(existing).and(toCondition(added))
|
|
150
|
+
: added;
|
|
151
|
+
}
|
|
152
|
+
function createStepBuilder(init) {
|
|
153
|
+
const builder = function (...args) {
|
|
154
|
+
const s = buildStepFromArgs(...args);
|
|
155
|
+
// don't merge config.if here — it's already picked up by
|
|
156
|
+
// computeEffectiveConditions (for the step itself) and
|
|
157
|
+
// propagatableConfigIf (for dependency context propagation).
|
|
158
|
+
// Merging it here would cause it to be counted twice.
|
|
159
|
+
return new StepRef(s, {
|
|
160
|
+
condition: init.condition,
|
|
161
|
+
dependencies: init.dependencies ?? [],
|
|
162
|
+
afterDependencies: init.afterDependencies ?? [],
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
builder.if = (condition) => {
|
|
166
|
+
return createStepBuilder({
|
|
167
|
+
...init,
|
|
168
|
+
condition: andConditions(init.condition, condition),
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
builder.dependsOn = (...deps) => {
|
|
172
|
+
return createStepBuilder({
|
|
173
|
+
...init,
|
|
174
|
+
dependencies: [...(init.dependencies ?? []), ...deps],
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
builder.comesAfter = (...deps) => {
|
|
178
|
+
return createStepBuilder({
|
|
179
|
+
...init,
|
|
180
|
+
afterDependencies: [...(init.afterDependencies ?? []), ...deps],
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
return builder;
|
|
184
|
+
}
|
|
185
|
+
export const step = Object.assign(buildStepFromArgs, {
|
|
186
|
+
if: (condition) => createStepBuilder({ condition }),
|
|
187
|
+
dependsOn: (...deps) => createStepBuilder({ dependencies: deps }),
|
|
188
|
+
comesAfter: (...deps) => createStepBuilder({ afterDependencies: deps }),
|
|
189
|
+
});
|
|
147
190
|
// --- StepRef: immutable wrapper for per-usage deps/conditions ---
|
|
148
191
|
export class StepRef {
|
|
149
192
|
constructor(step, init) {
|
|
@@ -200,11 +243,8 @@ export class StepRef {
|
|
|
200
243
|
});
|
|
201
244
|
}
|
|
202
245
|
if(condition) {
|
|
203
|
-
const newCond = this.condition != null
|
|
204
|
-
? toCondition(condition).and(toCondition(this.condition))
|
|
205
|
-
: condition;
|
|
206
246
|
return new StepRef(this.step, {
|
|
207
|
-
condition:
|
|
247
|
+
condition: andConditions(this.condition, condition),
|
|
208
248
|
dependencies: this.dependencies,
|
|
209
249
|
afterDependencies: this.afterDependencies,
|
|
210
250
|
});
|