gagen 0.3.0 → 0.3.2

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 CHANGED
@@ -1,4 +1,4 @@
1
- # `gagen`
1
+ # gagen
2
2
 
3
3
  [![JSR](https://jsr.io/badges/@david/gagen)](https://jsr.io/@david/gagen)
4
4
  [![npm Version](https://img.shields.io/npm/v/gagen.svg?style=flat)](http://www.npmjs.com/package/gagen)
@@ -16,7 +16,7 @@ initial code is more easily maintainable.
16
16
  ## Basic usage
17
17
 
18
18
  ```ts
19
- #!/usr/bin/env -S deno run --allow-read=ci.yml --allow-write=ci.yml
19
+ #!/usr/bin/env -S deno run --allow-read=ci.generated.yml --allow-write=ci.generated.yml
20
20
  import { conditions, createWorkflow, step } from "gagen";
21
21
 
22
22
  const checkout = step({
@@ -49,39 +49,77 @@ const lint = step
49
49
  // only specify the leaf steps — the other steps are pulled in automatically
50
50
  createWorkflow({
51
51
  name: "ci",
52
- on: { push: { branches: ["main"] } },
52
+ on: ["push", "pull_request"],
53
53
  jobs: [{
54
54
  id: "build",
55
55
  runsOn: "ubuntu-latest",
56
- steps: [test, lint],
56
+ steps: [lint, test],
57
57
  }],
58
58
  }).writeOrLint({
59
- filePath: new URL("./ci.yml", import.meta.url),
60
- header: "# GENERATED BY ./ci.generate.ts -- DO NOT DIRECTLY EDIT",
59
+ filePath: new URL("./ci.generated.yml", import.meta.url),
60
+ header: "# GENERATED BY ./ci.ts -- DO NOT DIRECTLY EDIT",
61
61
  });
62
62
  ```
63
63
 
64
- This generates a `ci.yml` with steps in the correct order and figures out that
65
- it should only install deno when the lint step should be run.
64
+ This generates a `ci.generated.yml` with steps in the correct order and figures
65
+ out that it should only install deno when the lint step should be run and it
66
+ defers that step only until it's necessary.
66
67
 
67
- When run normally, this writes `ci.yml`. When run with `--lint`, it reads the
68
- existing file and compares the parsed YAML exiting with a non-zero code if
69
- they differ. This lets you add a CI step to verify the generated file is up to
70
- date:
68
+ ```yaml
69
+ # GENERATED BY ./ci.ts -- DO NOT DIRECTLY EDIT
70
+
71
+ name: ci
72
+ on:
73
+ - push
74
+ - pull_request
75
+ jobs:
76
+ build:
77
+ runs-on: ubuntu-latest
78
+ steps:
79
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
80
+ - name: Clippy
81
+ if: github.ref != 'refs/heads/main'
82
+ run: cargo clippy
83
+ - uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282
84
+ if: github.ref != 'refs/heads/main'
85
+ - name: Deno Lint
86
+ if: github.ref != 'refs/heads/main'
87
+ run: deno lint
88
+ - name: Test
89
+ run: cargo test
90
+
91
+ # gagen:pin actions/checkout@v6 = de0fac2e4500dabe0009e67214ff5f5447ce83dd
92
+ # gagen:pin denoland/setup-deno@v2 = 667a34cdef165d8d2b2e98dde39547c9daac7282
93
+ ```
94
+
95
+ When run normally, this writes `ci.generated.yml`. When run with `--lint`, it
96
+ reads the existing file and compares the parsed YAML — exiting with a non-zero
97
+ code if they differ. This lets you add a CI step to verify the generated file is
98
+ up to date:
71
99
 
72
100
  ```ts
73
101
  const lintStep = step({
74
102
  name: "Lint CI generation",
75
- run: "./.github/workflows/ci.generate.ts --lint",
103
+ run: "./.github/workflows/ci.ts --lint",
76
104
  });
77
105
  ```
78
106
 
79
- ## Dependency pinning
107
+ ## Dependency pinning—the output is a lockfile
108
+
109
+ By default, `writeOrLint` pins action references to their resolved commit hashes
110
+ then stores that hash value locked in the output.
111
+
112
+ For example, if you write the following step in a workflow:
113
+
114
+ <!-- deno-fmt-ignore -->
115
+
116
+ ```ts
117
+ step({
118
+ uses: "actions/checkout@v6",
119
+ })
120
+ ```
80
121
 
81
- By default, `writeOrLint` pins action references to their resolved commit
82
- hashes. A `uses` value like `actions/checkout@v6` becomes
83
- `actions/checkout@<sha>` in the output, with a mapping comment appended to the
84
- file so that the original tag is preserved:
122
+ It will output:
85
123
 
86
124
  ```yaml
87
125
  steps:
@@ -89,10 +127,13 @@ steps:
89
127
  # gagen:pin actions/checkout@v6 = 11bd71901bbe5b1630ceea73d27597364c9af683
90
128
  ```
91
129
 
130
+ Then the next time it runs, it will read the output to get a locked set of
131
+ dependencies.
132
+
92
133
  To force re-resolving all pins, run with the `--update-pins` flag:
93
134
 
94
135
  ```sh
95
- ./ci.generate.ts --update-pins
136
+ ./ci.ts --update-pins
96
137
  ```
97
138
 
98
139
  Pinning can be disabled by setting `pinDeps` to `false`:
@@ -197,7 +238,7 @@ const runner = os.equals("linux").then("ubuntu-latest")
197
238
 
198
239
  // use in job config
199
240
  createWorkflow({
200
- ...,
241
+ // ...,
201
242
  jobs: [
202
243
  { id: "build", runsOn: runner, steps: [test] },
203
244
  ],
@@ -295,7 +336,7 @@ const preBuild = job("pre_build", {
295
336
  // automatically adds needs: [pre_build] to this job
296
337
  const wf = createWorkflow({
297
338
  name: "ci",
298
- on: { push: { branches: ["main"] } },
339
+ on: ["push", "pull_request"],
299
340
  jobs: [
300
341
  preBuild,
301
342
  {
@@ -370,17 +411,16 @@ Error: Cycle detected in step ordering: A → B → A
370
411
  `defineMatrix()` gives you typed access to matrix values:
371
412
 
372
413
  ```ts
373
- import { defineMatrix } from "gagen";
414
+ import { createWorkflow, defineMatrix } from "gagen";
374
415
 
375
416
  const matrix = defineMatrix({
376
417
  include: [
377
- { os: "linux", runner: "ubuntu-latest" },
378
- { os: "macos", runner: "macos-latest" },
418
+ { runner: "ubuntu-latest" },
419
+ { runner: "macos-latest" },
379
420
  ],
380
421
  });
381
422
 
382
- matrix.os; // ExpressionValue("matrix.os") — autocompletes
383
- matrix.runner; // ExpressionValue("matrix.runner")
423
+ matrix.runner; // ExpressionValue("matrix.runner") — autocompletes
384
424
  matrix.foo; // TypeScript error — not a matrix key
385
425
 
386
426
  createWorkflow({
@@ -430,14 +470,14 @@ import { createWorkflow } from "gagen";
430
470
 
431
471
  const wf = createWorkflow({
432
472
  name: "ci",
433
- on: { push: { branches: ["main"] } },
473
+ on: ["push", "pull_request"],
434
474
  permissions: { contents: "read", packages: "write" },
435
475
  });
436
476
 
437
477
  // or use a scalar value
438
478
  const wf2 = createWorkflow({
439
479
  name: "ci",
440
- on: { push: { branches: ["main"] } },
480
+ on: ["push", "pull_request"],
441
481
  permissions: "read-all",
442
482
  });
443
483
 
@@ -458,57 +498,6 @@ createWorkflow({
458
498
  Permission scopes (`contents`, `packages`, `id-token`, etc.) and levels (`read`,
459
499
  `write`, `none`) are fully typed.
460
500
 
461
- ## Reusable workflows
462
-
463
- Define reusable workflows with `workflow_call` triggers and call them from other
464
- jobs:
465
-
466
- ```ts
467
- import { createWorkflow } from "gagen";
468
-
469
- // define a reusable workflow
470
- const wf = createWorkflow({
471
- name: "Reusable Build",
472
- on: {
473
- workflow_call: {
474
- inputs: {
475
- environment: { type: "string", required: true },
476
- debug: { type: "boolean", default: false },
477
- },
478
- outputs: {
479
- build_id: {
480
- description: "The build ID",
481
- value: "${{ jobs.build.outputs.id }}",
482
- },
483
- },
484
- secrets: {
485
- deploy_key: { required: true },
486
- },
487
- },
488
- },
489
- });
490
- ```
491
-
492
- Call a reusable workflow from a job using `uses` instead of `runsOn`:
493
-
494
- ```ts
495
- const wf = createWorkflow({
496
- name: "CI",
497
- on: { push: { branches: ["main"] } },
498
- jobs: [
499
- {
500
- id: "build",
501
- uses: "octo-org/example/.github/workflows/build.yml@main",
502
- with: { environment: "production" },
503
- secrets: "inherit",
504
- },
505
- ],
506
- });
507
- ```
508
-
509
- Reusable jobs support `with`, `secrets` (either `"inherit"` or a record), and
510
- all common job fields (`name`, `needs`, `if`, `permissions`, `concurrency`).
511
-
512
501
  ## Artifacts
513
502
 
514
503
  Link upload and download artifact steps across jobs with automatic `needs`
@@ -523,22 +512,30 @@ import {
523
512
 
524
513
  const artifact = defineArtifact("build-output");
525
514
 
526
- const buildStep = step({ name: "Build", run: "make build" });
527
- const upload = artifact.upload({ path: "dist/" });
528
-
529
- const download = artifact.download({ dirPath: "output/" });
530
- const deployStep = step.dependsOn(download)({
531
- name: "Deploy",
532
- run: "make deploy",
533
- });
534
-
535
515
  const wf = createWorkflow({
536
516
  name: "CI",
537
- on: { push: { branches: ["main"] } },
517
+ on: ["push", "pull_request"],
538
518
  jobs: [
539
- { id: "build", runsOn: "ubuntu-latest", steps: [buildStep, upload] },
540
- // needs: [build] is inferred automatically from the artifact link
541
- { id: "deploy", runsOn: "ubuntu-latest", steps: [deployStep] },
519
+ {
520
+ id: "build",
521
+ runsOn: "ubuntu-latest",
522
+ steps: [
523
+ step({ name: "Build", run: "make build" }),
524
+ artifact.upload({ path: "dist/" }),
525
+ ],
526
+ },
527
+ // `needs: [build]` is inferred automatically from the artifact link
528
+ {
529
+ id: "deploy",
530
+ runsOn: "ubuntu-latest",
531
+ steps: [
532
+ artifact.download({ dirPath: "output/" }),
533
+ step({
534
+ name: "Deploy",
535
+ run: "make deploy",
536
+ }),
537
+ ],
538
+ },
542
539
  ],
543
540
  });
544
541
  ```
@@ -560,8 +557,8 @@ const artifact = defineArtifact("build-output", {
560
557
  ```ts
561
558
  const matrix = defineMatrix({
562
559
  include: [
563
- { os: "linux", runner: "ubuntu-latest" },
564
- { os: "macos", runner: "macos-latest" },
560
+ { runner: "ubuntu-latest" },
561
+ { runner: "macos-latest" },
565
562
  ],
566
563
  });
567
564
 
package/esm/pin.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pin.d.ts","sourceRoot":"","sources":["../src/pin.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACvB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAID,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,GACX;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM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,CAcxE;AAED,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GACV,MAAM,CA2BR;AAED,MAAM,MAAM,WAAW,GAAG,CACxB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,KACR,MAAM,CAAC;AAEZ,8DAA8D;AAC9D,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,WAAwB,EACjC,KAAK,CAAC,EAAE,SAAS,QAAQ,EAAE,GAC1B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,EAAE,CAAA;CAAE,CAkDvC;AAED,6DAA6D;AAC7D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,CAO1D;AAED,8CAA8C;AAC9C,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,EAAE,CAQ5D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,QAAQ,EAAE,GACf,OAAO,CA8CT"}
package/esm/pin.js CHANGED
@@ -51,12 +51,31 @@ export function pinYamlContent(yamlStr, resolve = resolveRef, cache) {
51
51
  const content = yamlStr.replace(/^(\s+(?:-\s+)?uses:\s+)(.+)$/gm, (_match, prefix, usesValue) => {
52
52
  const trimmed = usesValue.trim();
53
53
  const parsed = parseActionUses(trimmed);
54
- if (!parsed || isCommitHash(parsed.ref))
54
+ if (!parsed)
55
55
  return `${prefix}${usesValue}`;
56
+ if (isCommitHash(parsed.ref)) {
57
+ // already pinned — preserve the existing pin entry from cache
58
+ if (cache) {
59
+ for (const entry of cache) {
60
+ const ep = parseActionUses(entry.original);
61
+ if (ep &&
62
+ `${ep.owner}/${ep.repo}` === `${parsed.owner}/${parsed.repo}` &&
63
+ entry.hash === parsed.ref) {
64
+ if (!pins.some((p) => p.original === entry.original)) {
65
+ pins.push(entry);
66
+ }
67
+ break;
68
+ }
69
+ }
70
+ }
71
+ return `${prefix}${usesValue}`;
72
+ }
56
73
  let hash = seen.get(trimmed);
57
74
  if (!hash) {
58
75
  hash = resolve(parsed.owner, parsed.repo, parsed.ref);
59
76
  seen.set(trimmed, hash);
77
+ }
78
+ if (!pins.some((p) => p.original === trimmed)) {
60
79
  pins.push({ original: trimmed, hash });
61
80
  }
62
81
  const pinned = trimmed.replace(`@${parsed.ref}`, `@${hash}`);
@@ -68,7 +87,8 @@ export function pinYamlContent(yamlStr, resolve = resolveRef, cache) {
68
87
  export function formatPinComments(pins) {
69
88
  if (pins.length === 0)
70
89
  return "";
71
- const lines = pins.map((p) => `# gagen:pin ${p.original} = ${p.hash}`);
90
+ const sorted = [...pins].sort((a, b) => a.original < b.original ? -1 : a.original > b.original ? 1 : 0);
91
+ const lines = sorted.map((p) => `# gagen:pin ${p.original} = ${p.hash}`);
72
92
  return "\n" + lines.join("\n") + "\n";
73
93
  }
74
94
  /** Extracts pin entries from file content. */
package/esm/workflow.d.ts CHANGED
@@ -44,7 +44,7 @@ export interface WorkflowTriggers {
44
44
  export interface WorkflowConfig {
45
45
  name: string;
46
46
  runName?: string;
47
- on: WorkflowTriggers;
47
+ on: WorkflowTriggers | string[];
48
48
  permissions?: Permissions;
49
49
  concurrency?: {
50
50
  group: string;
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAgB,KAAK,MAAM,EAAgB,MAAM,UAAU,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAQ,MAAM,WAAW,CAAC;AAOnD,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,UAAU,CAAC;AAGtD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,QAAQ,GAAG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CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAIpE,WAAW,CACT,OAAO,EAAE;QACP,QAAQ,EAAE,GAAG,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,OAAO,GAAG;YAAE,OAAO,EAAE,WAAW,CAAA;SAAE,CAAC;KAC9C,GACA,IAAI;CAmDR;AAED,0EAA0E;AAC1E,eAAO,MAAM,SAAS,EAAE,OAAyC,CAAC;AAElE,iFAAiF;AACjF,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,QAAQ,CAE/D"}
package/esm/workflow.js CHANGED
@@ -47,7 +47,9 @@ export class Workflow {
47
47
  if (__classPrivateFieldGet(this, _Workflow_config, "f").runName != null) {
48
48
  obj["run-name"] = __classPrivateFieldGet(this, _Workflow_config, "f").runName;
49
49
  }
50
- obj.on = serializeTriggers(__classPrivateFieldGet(this, _Workflow_config, "f").on);
50
+ obj.on = Array.isArray(__classPrivateFieldGet(this, _Workflow_config, "f").on)
51
+ ? __classPrivateFieldGet(this, _Workflow_config, "f").on
52
+ : serializeTriggers(__classPrivateFieldGet(this, _Workflow_config, "f").on);
51
53
  if (__classPrivateFieldGet(this, _Workflow_config, "f").permissions != null) {
52
54
  obj.permissions = __classPrivateFieldGet(this, _Workflow_config, "f").permissions;
53
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gagen",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Generate complex GitHub Actions YAML files using a declarative API.",
5
5
  "repository": {
6
6
  "type": "git",