@intentius/chant 0.124.92 → 0.124.94

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.
Files changed (93) hide show
  1. package/dist/__golden__/notify-defaults-plain.json +52 -0
  2. package/dist/__golden__/notify-defaults-relay.json +92 -0
  3. package/dist/ci-job-guard.d.ts +22 -8
  4. package/dist/ci-job-guard.d.ts.map +1 -1
  5. package/dist/ci-job-guard.js +93 -49
  6. package/dist/ci-jobs.d.ts +22 -0
  7. package/dist/ci-jobs.d.ts.map +1 -1
  8. package/dist/ci-jobs.js +23 -0
  9. package/dist/ci-product.d.ts +41 -1
  10. package/dist/ci-product.d.ts.map +1 -1
  11. package/dist/ci-product.js +45 -5
  12. package/dist/cli/handlers/run-wave.js +17 -3
  13. package/dist/cli/main.d.ts.map +1 -1
  14. package/dist/cli/main.js +4 -1
  15. package/dist/components/product-pipeline.d.ts +30 -0
  16. package/dist/components/product-pipeline.d.ts.map +1 -1
  17. package/dist/components/product-pipeline.js +28 -3
  18. package/dist/floor-table.data.d.ts.map +1 -1
  19. package/dist/floor-table.data.js +17 -4
  20. package/dist/gate-resume-run.d.ts +7 -0
  21. package/dist/gate-resume-run.d.ts.map +1 -1
  22. package/dist/gate-resume-run.js +42 -3
  23. package/dist/lexicon.d.ts +64 -1
  24. package/dist/lexicon.d.ts.map +1 -1
  25. package/dist/lifecycle/gate-applied.d.ts +18 -0
  26. package/dist/lifecycle/gate-applied.d.ts.map +1 -1
  27. package/dist/notify.d.ts +8 -0
  28. package/dist/notify.d.ts.map +1 -1
  29. package/dist/notify.js +8 -3
  30. package/dist/op/before-merge.d.ts +8 -0
  31. package/dist/op/before-merge.d.ts.map +1 -1
  32. package/dist/op/before-merge.js +6 -0
  33. package/dist/op/gate-run-locator.d.ts +17 -0
  34. package/dist/op/gate-run-locator.d.ts.map +1 -1
  35. package/dist/op/index.d.ts +4 -2
  36. package/dist/op/index.d.ts.map +1 -1
  37. package/dist/op/index.js +3 -2
  38. package/dist/op/op-waves-names.d.ts +65 -2
  39. package/dist/op/op-waves-names.d.ts.map +1 -1
  40. package/dist/op/op-waves-names.js +129 -0
  41. package/dist/op/op-waves-remainder.d.ts +110 -0
  42. package/dist/op/op-waves-remainder.d.ts.map +1 -0
  43. package/dist/op/op-waves-remainder.js +120 -0
  44. package/dist/op/op-waves-render-spec.d.ts +63 -5
  45. package/dist/op/op-waves-render-spec.d.ts.map +1 -1
  46. package/dist/op/op-waves-render-spec.js +68 -10
  47. package/dist/op/op-waves-run.d.ts +29 -1
  48. package/dist/op/op-waves-run.d.ts.map +1 -1
  49. package/dist/op/op-waves-run.js +194 -6
  50. package/dist/op/op-waves-split-resume.d.ts +57 -0
  51. package/dist/op/op-waves-split-resume.d.ts.map +1 -0
  52. package/dist/op/op-waves-split-resume.js +94 -0
  53. package/dist/op/op-waves-stand-down.d.ts +9 -1
  54. package/dist/op/op-waves-stand-down.d.ts.map +1 -1
  55. package/dist/op/op-waves-stand-down.js +14 -2
  56. package/dist/op/op-waves.d.ts +38 -2
  57. package/dist/op/op-waves.d.ts.map +1 -1
  58. package/dist/op/op-waves.js +13 -2
  59. package/dist/release-floors.d.ts +9 -1
  60. package/dist/release-floors.d.ts.map +1 -1
  61. package/dist/release-floors.js +9 -1
  62. package/dist/wave-runtime.mjs +368 -368
  63. package/package.json +1 -1
  64. package/src/__golden__/notify-defaults-plain.json +52 -0
  65. package/src/__golden__/notify-defaults-relay.json +92 -0
  66. package/src/ci-job-guard.default-branch.test.ts +125 -0
  67. package/src/ci-job-guard.ts +64 -10
  68. package/src/ci-jobs.ts +26 -0
  69. package/src/ci-product.ts +54 -5
  70. package/src/cli/handlers/run-wave.ts +16 -3
  71. package/src/cli/main.ts +4 -1
  72. package/src/components/product-pipeline.ts +49 -4
  73. package/src/floor-table.data.ts +17 -4
  74. package/src/gate-resume-run.ts +38 -3
  75. package/src/lexicon.ts +64 -1
  76. package/src/lifecycle/gate-applied.ts +16 -0
  77. package/src/notify-bundle.test.ts +3 -2
  78. package/src/notify-relay-name.test.ts +72 -0
  79. package/src/notify.ts +16 -3
  80. package/src/op/before-merge.ts +12 -0
  81. package/src/op/gate-run-locator.ts +14 -0
  82. package/src/op/index.ts +6 -1
  83. package/src/op/op-waves-names.ts +130 -2
  84. package/src/op/op-waves-remainder.test.ts +342 -0
  85. package/src/op/op-waves-remainder.ts +146 -0
  86. package/src/op/op-waves-render-spec.test.ts +107 -0
  87. package/src/op/op-waves-render-spec.ts +81 -10
  88. package/src/op/op-waves-run.ts +204 -7
  89. package/src/op/op-waves-split-resume.test.ts +149 -0
  90. package/src/op/op-waves-split-resume.ts +109 -0
  91. package/src/op/op-waves-stand-down.ts +15 -2
  92. package/src/op/op-waves.ts +46 -3
  93. package/src/release-floors.ts +13 -1
@@ -0,0 +1,52 @@
1
+ [
2
+ {
3
+ "type": "message",
4
+ "attachments": [
5
+ {
6
+ "contentType": "application/vnd.microsoft.card.adaptive",
7
+ "contentUrl": null,
8
+ "content": {
9
+ "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
10
+ "type": "AdaptiveCard",
11
+ "version": "1.4",
12
+ "body": [
13
+ {
14
+ "type": "TextBlock",
15
+ "text": "terragucci: wave 1 (wave-1) of tf-apply waits for an approval",
16
+ "weight": "Bolder",
17
+ "wrap": true
18
+ },
19
+ {
20
+ "type": "FactSet",
21
+ "facts": [
22
+ {
23
+ "title": "Targets",
24
+ "value": "network"
25
+ },
26
+ {
27
+ "title": "Digest",
28
+ "value": "jcs1-sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
29
+ },
30
+ {
31
+ "title": "Approve",
32
+ "value": "terragucci approve tf-apply wave-1 --plan jcs1-sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
33
+ },
34
+ {
35
+ "title": "Run",
36
+ "value": "https://github.com/acme/db/actions/runs/42"
37
+ }
38
+ ]
39
+ }
40
+ ],
41
+ "actions": [
42
+ {
43
+ "type": "Action.OpenUrl",
44
+ "title": "Open the run",
45
+ "url": "https://github.com/acme/db/actions/runs/42"
46
+ }
47
+ ]
48
+ }
49
+ }
50
+ ]
51
+ }
52
+ ]
@@ -0,0 +1,92 @@
1
+ [
2
+ {
3
+ "text": "*terragucci: wave 1 (wave-1) of tf-apply waits for an approval*\nTargets: network\nDigest: `jcs1-sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`\nApprove: `terragucci approve tf-apply wave-1 --plan jcs1-sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`\nRun: <https://github.com/acme/db/actions/runs/42>",
4
+ "blocks": [
5
+ {
6
+ "type": "section",
7
+ "text": {
8
+ "type": "mrkdwn",
9
+ "text": "*terragucci: wave 1 (wave-1) of tf-apply waits for an approval*\nTargets: network\nDigest: `jcs1-sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`\nApprove: `terragucci approve tf-apply wave-1 --plan jcs1-sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`\nRun: <https://github.com/acme/db/actions/runs/42>"
10
+ }
11
+ },
12
+ {
13
+ "type": "actions",
14
+ "elements": [
15
+ {
16
+ "type": "button",
17
+ "text": {
18
+ "type": "plain_text",
19
+ "text": "Approve"
20
+ },
21
+ "action_id": "chant-approve",
22
+ "value": "eyJ2IjoxLCJpZCI6ImQ0MDM4OWRjOWM2ZDAzZDUxYTU3MDE5NzQ4OTMyMWU5N2Q0NWNjMGJkODg0NmExMGM1N2I5MDQ2YTMxMmI4YjIiLCJzb3VyY2UiOiJ0ZXJyYWd1Y2NpIiwiYXQiOiIyMDI2LTEwLTExVDEyOjAwOjAwLjAwMFoiLCJnYXRlIjoid2F2ZS0xIiwiZGlnZXN0IjoiamNzMS1zaGEyNTY6YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYSJ9.6122dfab74cb9b2729f23dae8546cf5948d4b01cc34fdb33dfa128c1a6772437",
23
+ "style": "primary"
24
+ },
25
+ {
26
+ "type": "button",
27
+ "text": {
28
+ "type": "plain_text",
29
+ "text": "Decline"
30
+ },
31
+ "action_id": "chant-decline",
32
+ "value": "eyJ2IjoxLCJpZCI6ImQ0MDM4OWRjOWM2ZDAzZDUxYTU3MDE5NzQ4OTMyMWU5N2Q0NWNjMGJkODg0NmExMGM1N2I5MDQ2YTMxMmI4YjIiLCJzb3VyY2UiOiJ0ZXJyYWd1Y2NpIiwiYXQiOiIyMDI2LTEwLTExVDEyOjAwOjAwLjAwMFoiLCJnYXRlIjoid2F2ZS0xIiwiZGlnZXN0IjoiamNzMS1zaGEyNTY6YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYSJ9.6122dfab74cb9b2729f23dae8546cf5948d4b01cc34fdb33dfa128c1a6772437"
33
+ }
34
+ ]
35
+ }
36
+ ]
37
+ },
38
+ {
39
+ "type": "message",
40
+ "attachments": [
41
+ {
42
+ "contentType": "application/vnd.microsoft.card.adaptive",
43
+ "contentUrl": null,
44
+ "content": {
45
+ "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
46
+ "type": "AdaptiveCard",
47
+ "version": "1.4",
48
+ "body": [
49
+ {
50
+ "type": "TextBlock",
51
+ "text": "terragucci: wave 1 (wave-1) of tf-apply waits for an approval",
52
+ "weight": "Bolder",
53
+ "wrap": true
54
+ },
55
+ {
56
+ "type": "FactSet",
57
+ "facts": [
58
+ {
59
+ "title": "Targets",
60
+ "value": "network"
61
+ },
62
+ {
63
+ "title": "Digest",
64
+ "value": "jcs1-sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
65
+ },
66
+ {
67
+ "title": "Approve",
68
+ "value": "terragucci approve tf-apply wave-1 --plan jcs1-sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
69
+ },
70
+ {
71
+ "title": "Run",
72
+ "value": "https://github.com/acme/db/actions/runs/42"
73
+ },
74
+ {
75
+ "title": "Approve in chat",
76
+ "value": "mention the relay and reply: approve eyJ2IjoxLCJpZCI6ImQ0MDM4OWRjOWM2ZDAzZDUxYTU3MDE5NzQ4OTMyMWU5N2Q0NWNjMGJkODg0NmExMGM1N2I5MDQ2YTMxMmI4YjIiLCJzb3VyY2UiOiJ0ZXJyYWd1Y2NpIiwiYXQiOiIyMDI2LTEwLTExVDEyOjAwOjAwLjAwMFoiLCJnYXRlIjoid2F2ZS0xIiwiZGlnZXN0IjoiamNzMS1zaGEyNTY6YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYSJ9.6122dfab74cb9b2729f23dae8546cf5948d4b01cc34fdb33dfa128c1a6772437"
77
+ }
78
+ ]
79
+ }
80
+ ],
81
+ "actions": [
82
+ {
83
+ "type": "Action.OpenUrl",
84
+ "title": "Open the run",
85
+ "url": "https://github.com/acme/db/actions/runs/42"
86
+ }
87
+ ]
88
+ }
89
+ }
90
+ ]
91
+ }
92
+ ]
@@ -3,6 +3,14 @@ import { type BeforeMergeRecord, type BeforeMergeRun } from "./op/before-merge.j
3
3
  import { type FollowOnRecord, type FollowOnRun } from "./op/follow-on-run.js";
4
4
  /** The variable the generated step carries its expectation in. */
5
5
  export declare const JOB_GUARD_ENV = "CHANT_JOB_GUARD";
6
+ /**
7
+ * The variable a GitHub or Forgejo job carries the repository's default
8
+ * branch in (#5032), from `github.event.repository.default_branch`. GitLab
9
+ * sets `CI_DEFAULT_BRANCH` itself.
10
+ */
11
+ export declare const JOB_DEFAULT_BRANCH_ENV = "CHANT_DEFAULT_BRANCH";
12
+ /** The job variable that sets {@link JOB_DEFAULT_BRANCH_ENV} on GitHub and Forgejo (#5032). */
13
+ export declare const GITHUB_DEFAULT_BRANCH_ENV: Record<string, string>;
6
14
  /** The audience of the token the guard requests on GitHub, which no cloud role should trust. */
7
15
  export declare const JOB_GUARD_AUDIENCE = "chant-check-job";
8
16
  export type JobGuardForge = "github" | "gitlab" | "forgejo";
@@ -17,6 +25,8 @@ export interface JobGuardSpec {
17
25
  forgeEnvironment?: string;
18
26
  /** The branches the job may run from. */
19
27
  branches: string[];
28
+ /** The job may also run from the repository's default branch, by the name the forge gives at run time (#5032). */
29
+ defaultBranch?: true;
20
30
  /** GitLab: the tags the job's runner must carry. */
21
31
  runnerTags?: string[];
22
32
  /** GitHub and Forgejo: the runner must be self-hosted. */
@@ -36,6 +46,8 @@ export interface JobSeen {
36
46
  forgeEnvironmentError?: string;
37
47
  ref?: string;
38
48
  refProtected?: string;
49
+ /** The repository's default branch, as the forge names it (#5032). Read only when the spec has `defaultBranch`. */
50
+ defaultBranch?: string;
39
51
  runnerTags?: string[];
40
52
  runnerEnvironment?: string;
41
53
  /** The decision the run names (#4984), from its variables. */
@@ -68,6 +80,8 @@ export interface JobGuardInput {
68
80
  environment?: string;
69
81
  /** The branches the job runs from. */
70
82
  branches: readonly string[];
83
+ /** The job also runs from the repository's default branch, whatever the forge calls it (#5032). */
84
+ defaultBranch?: boolean;
71
85
  /** The job's runner, as the spec gives it. */
72
86
  runner?: CiRunner;
73
87
  /** GitHub: the job may request an OIDC token (`id-token: write`), so the guard can read its environment. */
@@ -115,16 +129,16 @@ export declare function describeJobGuard(expect: JobGuardSpec, result: JobGuardR
115
129
  out: string[];
116
130
  err: string[];
117
131
  };
132
+ /** The guard as one `node -e` program; see {@link jobGuardProgram}. */
133
+ export declare const JOB_GUARD_JS: string;
134
+ /** The same program for a spec with `defaultBranch` (#5032), which also reads the default branch. */
135
+ export declare const JOB_GUARD_DEFAULT_BRANCH_JS: string;
118
136
  /**
119
- * The guard as one `node -e` program: the same checks as {@link checkJob},
120
- * {@link jobSeen} and {@link describeJobGuard}, reading {@link JOB_GUARD_ENV}.
121
- * Exits chant's `misplaced` (9) with one line per value that differs, and
122
- * when the variable holds no spec it can read. A test runs it against
123
- * {@link checkJob} so the two stay the same.
137
+ * The shell line of the guard step: `node -e` from `/`, so no file of the
138
+ * checkout is in reach. #5032: a spec with `defaultBranch` gets the program
139
+ * that reads the default branch.
124
140
  */
125
- export declare const JOB_GUARD_JS: string;
126
- /** The shell line of the guard step: `node -e` from `/`, so no file of the checkout is in reach. */
127
- export declare function jobGuardLine(): string;
141
+ export declare function jobGuardLine(spec?: Pick<JobGuardSpec, "defaultBranch">): string;
128
142
  /** How the guard's lines name an op-wave job: `wave 2 (prod) of deploy`, `share 1 of job group eu of wave 2 (prod) of deploy`. */
129
143
  export declare function opWaveJobLabel(spec: string, job: {
130
144
  kind: "wave" | "decide" | "share";
@@ -1 +1 @@
1
- {"version":3,"file":"ci-job-guard.d.ts","sourceRoot":"","sources":["../src/ci-job-guard.ts"],"names":[],"mappings":"AA0EA,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,EAAwK,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtP,OAAO,EAAqI,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE9M,kEAAkE;AAClE,eAAO,MAAM,aAAa,oBAAoB,CAAC;AAE/C,gGAAgG;AAChG,eAAO,MAAM,kBAAkB,oBAAoB,CAAC;AAEpD,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE5D,8DAA8D;AAC9D,M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,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,EAAE,MAAM,EAAE,CAAA;CAAE,CAW5H;AA6HD,uEAAuE;AACvE,eAAO,MAAM,YAAY,QAAyB,CAAC;AAEnD,qGAAqG;AACrG,eAAO,MAAM,2BAA2B,QAAwB,CAAC;AAEjE;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,MAAM,CAE/E;AAED,kIAAkI;AAClI,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE;IAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAM/J"}
@@ -17,7 +17,12 @@
17
17
  * ref GitHub and Forgejo: GITHUB_REF is refs/heads/<branch>
18
18
  * for one of the branches the waves apply from. GitLab:
19
19
  * CI_COMMIT_REF_NAME is one of them, and
20
- * CI_COMMIT_REF_PROTECTED is "true".
20
+ * CI_COMMIT_REF_PROTECTED is "true". With
21
+ * `defaultBranch` (#5032) the repository's default
22
+ * branch is one of them, by the name the forge gives
23
+ * at run time: GitLab's CI_DEFAULT_BRANCH, and on
24
+ * GitHub and Forgejo CHANT_DEFAULT_BRANCH, which the
25
+ * job sets from github.event.repository.default_branch.
21
26
  * runner GitLab: CI_RUNNER_TAGS holds each of the job's tags.
22
27
  * GitHub and Forgejo expose no labels, only whether the
23
28
  * runner is self-hosted: when the job's labels include
@@ -78,6 +83,14 @@ import { BEFORE_MERGE_DIGEST_ENV, BEFORE_MERGE_HEAD_ENV, BEFORE_MERGE_PR_ENV, be
78
83
  import { followOnPath, followOnProblems, followOnRecordProblems, followOnRunFromEnv, OP_WAVES_COMMIT_ENV, OP_WAVES_WAVE_ENV, parseFollowOn } from "./op/follow-on-run.js";
79
84
  /** The variable the generated step carries its expectation in. */
80
85
  export const JOB_GUARD_ENV = "CHANT_JOB_GUARD";
86
+ /**
87
+ * The variable a GitHub or Forgejo job carries the repository's default
88
+ * branch in (#5032), from `github.event.repository.default_branch`. GitLab
89
+ * sets `CI_DEFAULT_BRANCH` itself.
90
+ */
91
+ export const JOB_DEFAULT_BRANCH_ENV = "CHANT_DEFAULT_BRANCH";
92
+ /** The job variable that sets {@link JOB_DEFAULT_BRANCH_ENV} on GitHub and Forgejo (#5032). */
93
+ export const GITHUB_DEFAULT_BRANCH_ENV = { [JOB_DEFAULT_BRANCH_ENV]: "${{ github.event.repository.default_branch }}" };
81
94
  /** The audience of the token the guard requests on GitHub, which no cloud role should trust. */
82
95
  export const JOB_GUARD_AUDIENCE = "chant-check-job";
83
96
  /**
@@ -93,6 +106,7 @@ export function jobGuardSpec(input) {
93
106
  ...(input.product && input.product !== "chant" ? { product: input.product } : {}),
94
107
  ...(input.environment !== undefined && readsEnvironment ? { forgeEnvironment: input.environment } : {}),
95
108
  branches: [...input.branches],
109
+ ...(input.defaultBranch === true ? { defaultBranch: true } : {}),
96
110
  ...(input.forge === "gitlab" && labels.length > 0 ? { runnerTags: labels } : {}),
97
111
  ...(input.forge !== "gitlab" && labels.includes("self-hosted") ? { selfHosted: true } : {}),
98
112
  ...(input.beforeMerge ? { beforeMerge: { op: input.beforeMerge.op } } : {}),
@@ -119,6 +133,8 @@ export function parseJobGuardSpec(raw) {
119
133
  throw new Error(`${JOB_GUARD_ENV}.job names no job`);
120
134
  if (!Array.isArray(o.branches) || o.branches.some((b) => typeof b !== "string"))
121
135
  throw new Error(`${JOB_GUARD_ENV}.branches is not a list of branches`);
136
+ if (o.defaultBranch !== undefined && o.defaultBranch !== true)
137
+ throw new Error(`${JOB_GUARD_ENV}.defaultBranch is true or absent`);
122
138
  if (o.forgeEnvironment !== undefined && typeof o.forgeEnvironment !== "string")
123
139
  throw new Error(`${JOB_GUARD_ENV}.forgeEnvironment is not a name`);
124
140
  if (o.runnerTags !== undefined && (!Array.isArray(o.runnerTags) || o.runnerTags.some((t) => typeof t !== "string")))
@@ -130,6 +146,8 @@ export function parseJobGuardSpec(raw) {
130
146
  return o;
131
147
  }
132
148
  const shown = (v) => (v === undefined || v === null || v === "" ? "none" : v);
149
+ /** The variable the guard reads the default branch from (#5032). */
150
+ const defaultBranchVar = (forge) => (forge === "gitlab" ? "CI_DEFAULT_BRANCH" : JOB_DEFAULT_BRANCH_ENV);
133
151
  /** The tags CI_RUNNER_TAGS lists: a JSON array, or a comma-separated list. */
134
152
  export function runnerTagsOf(raw) {
135
153
  if (raw === undefined)
@@ -172,9 +190,12 @@ export function checkJob(expect, seen) {
172
190
  else
173
191
  out.checked.push(`forge environment ${fe}`);
174
192
  }
175
- const branches = expect.branches.filter((b) => b !== "");
193
+ // #5032: the repository's default branch, by the name the forge gives this run, beside the named ones.
194
+ const named = expect.branches.filter((b) => b !== "");
195
+ const def = expect.defaultBranch ? (seen.defaultBranch ?? "").trim() : "";
196
+ const branches = def !== "" && !named.includes(def) ? [def, ...named] : named;
176
197
  if (branches.length === 0)
177
- out.problems.push("ref: the job names no branch to run from");
198
+ out.problems.push(expect.defaultBranch ? `ref: the job runs from the default branch, and the forge names none (no ${defaultBranchVar(expect.forge)})` : "ref: the job names no branch to run from");
178
199
  else if (expect.forge === "gitlab") {
179
200
  if (!seen.ref || !branches.includes(seen.ref))
180
201
  out.problems.push(`ref: expected ${branches.join(" or ")}, found ${shown(seen.ref)}`);
@@ -328,15 +349,19 @@ export const lifecycleFileByGit = (forge, env, path) => {
328
349
  };
329
350
  /** What the forge's own variables and token say, before the decision is read. */
330
351
  async function forgeSeen(expect, env, fetchFn) {
352
+ // #5032: the default branch, read only when the spec runs from it.
353
+ const def = expect.defaultBranch ? env[defaultBranchVar(expect.forge)] : undefined;
354
+ const defaultBranch = def !== undefined && def.trim() !== "" ? { defaultBranch: def.trim() } : {};
331
355
  if (expect.forge === "gitlab") {
332
356
  return {
357
+ ...defaultBranch,
333
358
  forgeEnvironment: env.CI_ENVIRONMENT_NAME || null,
334
359
  ...(env.CI_COMMIT_REF_NAME !== undefined ? { ref: env.CI_COMMIT_REF_NAME } : {}),
335
360
  ...(env.CI_COMMIT_REF_PROTECTED !== undefined ? { refProtected: env.CI_COMMIT_REF_PROTECTED } : {}),
336
361
  ...(env.CI_RUNNER_TAGS !== undefined ? { runnerTags: runnerTagsOf(env.CI_RUNNER_TAGS) } : {}),
337
362
  };
338
363
  }
339
- const seen = { ...(env.GITHUB_REF !== undefined ? { ref: env.GITHUB_REF } : {}) };
364
+ const seen = { ...(env.GITHUB_REF !== undefined ? { ref: env.GITHUB_REF } : {}), ...defaultBranch };
340
365
  let claims;
341
366
  if (expect.forge === "github" && expect.forgeEnvironment !== undefined) {
342
367
  try {
@@ -431,52 +456,71 @@ const FOLLOW_ON_JS = [
431
456
  * Exits chant's `misplaced` (9) with one line per value that differs, and
432
457
  * when the variable holds no spec it can read. A test runs it against
433
458
  * {@link checkJob} so the two stay the same.
459
+ *
460
+ * `defaultBranch` (#5032) gives the program that also reads the default
461
+ * branch, for a spec with `defaultBranch`; a job without it carries the
462
+ * program as it was.
463
+ */
464
+ function jobGuardProgram(defaultBranch) {
465
+ const branchLines = defaultBranch
466
+ ? [
467
+ `const b=x.branches.filter((v)=>v!=="");const DV=x.forge==="gitlab"?"CI_DEFAULT_BRANCH":${JSON.stringify(JOB_DEFAULT_BRANCH_ENV)};const D=x.defaultBranch?String(E[DV]||"").trim():"";if(D!==""&&!b.includes(D))b.unshift(D);`,
468
+ 'if(b.length===0)P.push(x.defaultBranch?"ref: the job runs from the default branch, and the forge names none (no "+DV+")":"ref: the job names no branch to run from");',
469
+ ]
470
+ : ['const b=x.branches.filter((v)=>v!=="");', 'if(b.length===0)P.push("ref: the job names no branch to run from");'];
471
+ return [
472
+ '"use strict";',
473
+ `const E=process.env,A=${JSON.stringify(JOB_GUARD_AUDIENCE)};`,
474
+ "const shown=(v)=>v===undefined||v===null||v===\"\"?\"none\":v;",
475
+ `const fail=(m)=>{console.error("check-job: "+m);process.exit(${CHANT_EXIT.misplaced})};`,
476
+ "let x;try{x=JSON.parse(E." + JOB_GUARD_ENV + "||\"\")}catch(e){fail(\"" + JOB_GUARD_ENV + " is not JSON\")}",
477
+ "if(!x||![\"github\",\"gitlab\",\"forgejo\"].includes(x.forge)||!Array.isArray(x.branches))fail(\"" + JOB_GUARD_ENV + " is not a guard spec\");",
478
+ 'const tags=(r)=>{if(r===undefined)return undefined;const t=r.trim();if(t.startsWith("[")){try{const v=JSON.parse(t);if(Array.isArray(v))return v.map(String)}catch(e){}}return t===""?[]:t.split(",").map((s)=>s.trim()).filter((s)=>s!=="")};',
479
+ 'const claimsOf=(tok)=>{const p=tok.split(".")[1];if(!p)throw new Error("the forge\\u0027s OIDC token is not a JWT");const c=JSON.parse(Buffer.from(p.replace(/-/g,"+").replace(/_/g,"/"),"base64").toString("utf-8"));if(!c||typeof c!=="object")throw new Error("the forge\\u0027s OIDC token has no claims");return c};',
480
+ ...BEFORE_MERGE_JS,
481
+ ...FOLLOW_ON_JS,
482
+ "async function seenOf(){",
483
+ 'if(x.forge==="gitlab")return foSeen(bmSeen({forgeEnvironment:E.CI_ENVIRONMENT_NAME||null,ref:E.CI_COMMIT_REF_NAME,refProtected:E.CI_COMMIT_REF_PROTECTED,runnerTags:tags(E.CI_RUNNER_TAGS)}));',
484
+ "const s={ref:E.GITHUB_REF};let c;",
485
+ 'if(x.forge==="github"&&x.forgeEnvironment!==undefined){try{',
486
+ 'if(!E.ACTIONS_ID_TOKEN_REQUEST_URL||!E.ACTIONS_ID_TOKEN_REQUEST_TOKEN)throw new Error("the job may request no OIDC token (no ACTIONS_ID_TOKEN_REQUEST_URL); it needs the id-token: write permission");',
487
+ 'const r=await fetch(E.ACTIONS_ID_TOKEN_REQUEST_URL+"&audience="+encodeURIComponent(A),{headers:{authorization:"bearer "+E.ACTIONS_ID_TOKEN_REQUEST_TOKEN}});',
488
+ 'if(!r.ok)throw new Error("the OIDC token request answered "+r.status);const v=(await r.json()).value;if(typeof v!=="string")throw new Error("the OIDC token request answered no token");',
489
+ 'c=claimsOf(v);s.forgeEnvironment=typeof c.environment==="string"&&c.environment!==""?c.environment:null}catch(e){s.forgeEnvironmentError=e&&e.message?e.message:String(e)}}',
490
+ 'const run=c&&typeof c.runner_environment==="string"?c.runner_environment:E.RUNNER_ENVIRONMENT;if(run)s.runnerEnvironment=run;return foSeen(bmSeen(s))}',
491
+ "seenOf().then((s)=>{const P=[],C=[],S=[];const fe=x.forgeEnvironment;",
492
+ 'if(x.forge==="forgejo")S.push("forge environment (Forgejo has none)");',
493
+ 'else if(fe!==undefined){if(s.forgeEnvironmentError!==undefined)P.push("forge environment: expected "+fe+", and it could not be read: "+s.forgeEnvironmentError);else if(s.forgeEnvironment!==fe)P.push("forge environment: expected "+fe+", found "+shown(s.forgeEnvironment));else C.push("forge environment "+fe)}',
494
+ ...branchLines,
495
+ 'else if(x.forge==="gitlab"){if(!s.ref||!b.includes(s.ref))P.push("ref: expected "+b.join(" or ")+", found "+shown(s.ref));else C.push("ref "+s.ref);',
496
+ 'if(s.refProtected!=="true")P.push("ref: expected a protected ref (CI_COMMIT_REF_PROTECTED true), found "+shown(s.refProtected));else C.push("protected ref")}',
497
+ 'else{const refs=b.map((v)=>"refs/heads/"+v);if(!s.ref||!refs.includes(s.ref))P.push("ref: expected "+refs.join(" or ")+", found "+shown(s.ref));else C.push("ref "+s.ref)}',
498
+ ...[
499
+ String.raw `if(s.beforeMerge){const r=s.beforeMerge;if(!x.beforeMerge)P.push("before merge: the run names pull request "+(r.pr||"none")+"'s head "+(r.head||"none")+", and this job applies only the pushes to its branches");`,
500
+ String.raw `else if(s.bmErr!==undefined)P.push("before merge: the decisions on chant/lifecycle could not be read: "+s.bmErr);`,
501
+ String.raw `else{const Q=bmProblems(x.beforeMerge.op,r,s.rec||undefined);if(Q.length)P.push(...Q);else C.push("before merge: pull request "+r.pr+"'s decided head "+r.head.slice(0,12))}}`,
502
+ ].map(noQuote),
503
+ "{const F=foProblems(x.rest,foRun,bmOn);P.push(...F.p);if(F.c){const G=!x.beforeMerge?[\"follow-on: this job names no op whose follow-on records it reads, so it admits no follow-on\"]:s.foErr!==undefined?[\"follow-on: the follow-on records on chant/lifecycle could not be read: \"+s.foErr]:foRecProblems(x.beforeMerge.op,foRun.wave,(bmOn?bmRun.head:foRun.commit)||\"\",bmOn?(bmRun.digest||\"\"):undefined,s.foRec);if(G.length)P.push(...G);else C.push(F.c)}}",
504
+ 'if(x.forge==="gitlab"){const w=x.runnerTags||[];if(w.length>0){const h=s.runnerTags;const miss=w.filter((t)=>!(h||[]).includes(t));',
505
+ 'if(h===undefined)P.push("runner: expected tags "+w.join(", ")+", and the job has no CI_RUNNER_TAGS");else if(miss.length>0)P.push("runner: expected tags "+w.join(", ")+", found "+(h.length?h.join(", "):"none"));else C.push("runner tags "+w.join(", "))}}',
506
+ 'else if(x.selfHosted){if(s.runnerEnvironment===undefined)S.push("runner (the runner says nothing about itself: no RUNNER_ENVIRONMENT)");else if(s.runnerEnvironment!=="self-hosted")P.push("runner: expected self-hosted, found "+s.runnerEnvironment);else C.push("self-hosted runner")}',
507
+ 'const at=(x.product||"chant")+" check-job: "+x.job;',
508
+ 'if(P.length>0){for(const p of P)console.error(at+": "+p);console.error(at+": this job does not run where the spec set it to run, so it stops before any credential is taken or code checked out");process.exit(' + CHANT_EXIT.misplaced + ")}",
509
+ 'console.log(at+": "+(C.length?C.join(", "):"nothing to check")+(S.length?"; not checked: "+S.join(", "):""))',
510
+ "}).catch((e)=>fail(e&&e.message?e.message:String(e)));",
511
+ ].join("");
512
+ }
513
+ /** The guard as one `node -e` program; see {@link jobGuardProgram}. */
514
+ export const JOB_GUARD_JS = jobGuardProgram(false);
515
+ /** The same program for a spec with `defaultBranch` (#5032), which also reads the default branch. */
516
+ export const JOB_GUARD_DEFAULT_BRANCH_JS = jobGuardProgram(true);
517
+ /**
518
+ * The shell line of the guard step: `node -e` from `/`, so no file of the
519
+ * checkout is in reach. #5032: a spec with `defaultBranch` gets the program
520
+ * that reads the default branch.
434
521
  */
435
- export const JOB_GUARD_JS = [
436
- '"use strict";',
437
- `const E=process.env,A=${JSON.stringify(JOB_GUARD_AUDIENCE)};`,
438
- "const shown=(v)=>v===undefined||v===null||v===\"\"?\"none\":v;",
439
- `const fail=(m)=>{console.error("check-job: "+m);process.exit(${CHANT_EXIT.misplaced})};`,
440
- "let x;try{x=JSON.parse(E." + JOB_GUARD_ENV + "||\"\")}catch(e){fail(\"" + JOB_GUARD_ENV + " is not JSON\")}",
441
- "if(!x||![\"github\",\"gitlab\",\"forgejo\"].includes(x.forge)||!Array.isArray(x.branches))fail(\"" + JOB_GUARD_ENV + " is not a guard spec\");",
442
- 'const tags=(r)=>{if(r===undefined)return undefined;const t=r.trim();if(t.startsWith("[")){try{const v=JSON.parse(t);if(Array.isArray(v))return v.map(String)}catch(e){}}return t===""?[]:t.split(",").map((s)=>s.trim()).filter((s)=>s!=="")};',
443
- 'const claimsOf=(tok)=>{const p=tok.split(".")[1];if(!p)throw new Error("the forge\\u0027s OIDC token is not a JWT");const c=JSON.parse(Buffer.from(p.replace(/-/g,"+").replace(/_/g,"/"),"base64").toString("utf-8"));if(!c||typeof c!=="object")throw new Error("the forge\\u0027s OIDC token has no claims");return c};',
444
- ...BEFORE_MERGE_JS,
445
- ...FOLLOW_ON_JS,
446
- "async function seenOf(){",
447
- 'if(x.forge==="gitlab")return foSeen(bmSeen({forgeEnvironment:E.CI_ENVIRONMENT_NAME||null,ref:E.CI_COMMIT_REF_NAME,refProtected:E.CI_COMMIT_REF_PROTECTED,runnerTags:tags(E.CI_RUNNER_TAGS)}));',
448
- "const s={ref:E.GITHUB_REF};let c;",
449
- 'if(x.forge==="github"&&x.forgeEnvironment!==undefined){try{',
450
- 'if(!E.ACTIONS_ID_TOKEN_REQUEST_URL||!E.ACTIONS_ID_TOKEN_REQUEST_TOKEN)throw new Error("the job may request no OIDC token (no ACTIONS_ID_TOKEN_REQUEST_URL); it needs the id-token: write permission");',
451
- 'const r=await fetch(E.ACTIONS_ID_TOKEN_REQUEST_URL+"&audience="+encodeURIComponent(A),{headers:{authorization:"bearer "+E.ACTIONS_ID_TOKEN_REQUEST_TOKEN}});',
452
- 'if(!r.ok)throw new Error("the OIDC token request answered "+r.status);const v=(await r.json()).value;if(typeof v!=="string")throw new Error("the OIDC token request answered no token");',
453
- 'c=claimsOf(v);s.forgeEnvironment=typeof c.environment==="string"&&c.environment!==""?c.environment:null}catch(e){s.forgeEnvironmentError=e&&e.message?e.message:String(e)}}',
454
- 'const run=c&&typeof c.runner_environment==="string"?c.runner_environment:E.RUNNER_ENVIRONMENT;if(run)s.runnerEnvironment=run;return foSeen(bmSeen(s))}',
455
- "seenOf().then((s)=>{const P=[],C=[],S=[];const fe=x.forgeEnvironment;",
456
- 'if(x.forge==="forgejo")S.push("forge environment (Forgejo has none)");',
457
- 'else if(fe!==undefined){if(s.forgeEnvironmentError!==undefined)P.push("forge environment: expected "+fe+", and it could not be read: "+s.forgeEnvironmentError);else if(s.forgeEnvironment!==fe)P.push("forge environment: expected "+fe+", found "+shown(s.forgeEnvironment));else C.push("forge environment "+fe)}',
458
- 'const b=x.branches.filter((v)=>v!=="");',
459
- 'if(b.length===0)P.push("ref: the job names no branch to run from");',
460
- 'else if(x.forge==="gitlab"){if(!s.ref||!b.includes(s.ref))P.push("ref: expected "+b.join(" or ")+", found "+shown(s.ref));else C.push("ref "+s.ref);',
461
- 'if(s.refProtected!=="true")P.push("ref: expected a protected ref (CI_COMMIT_REF_PROTECTED true), found "+shown(s.refProtected));else C.push("protected ref")}',
462
- 'else{const refs=b.map((v)=>"refs/heads/"+v);if(!s.ref||!refs.includes(s.ref))P.push("ref: expected "+refs.join(" or ")+", found "+shown(s.ref));else C.push("ref "+s.ref)}',
463
- ...[
464
- String.raw `if(s.beforeMerge){const r=s.beforeMerge;if(!x.beforeMerge)P.push("before merge: the run names pull request "+(r.pr||"none")+"'s head "+(r.head||"none")+", and this job applies only the pushes to its branches");`,
465
- String.raw `else if(s.bmErr!==undefined)P.push("before merge: the decisions on chant/lifecycle could not be read: "+s.bmErr);`,
466
- String.raw `else{const Q=bmProblems(x.beforeMerge.op,r,s.rec||undefined);if(Q.length)P.push(...Q);else C.push("before merge: pull request "+r.pr+"'s decided head "+r.head.slice(0,12))}}`,
467
- ].map(noQuote),
468
- "{const F=foProblems(x.rest,foRun,bmOn);P.push(...F.p);if(F.c){const G=!x.beforeMerge?[\"follow-on: this job names no op whose follow-on records it reads, so it admits no follow-on\"]:s.foErr!==undefined?[\"follow-on: the follow-on records on chant/lifecycle could not be read: \"+s.foErr]:foRecProblems(x.beforeMerge.op,foRun.wave,(bmOn?bmRun.head:foRun.commit)||\"\",bmOn?(bmRun.digest||\"\"):undefined,s.foRec);if(G.length)P.push(...G);else C.push(F.c)}}",
469
- 'if(x.forge==="gitlab"){const w=x.runnerTags||[];if(w.length>0){const h=s.runnerTags;const miss=w.filter((t)=>!(h||[]).includes(t));',
470
- 'if(h===undefined)P.push("runner: expected tags "+w.join(", ")+", and the job has no CI_RUNNER_TAGS");else if(miss.length>0)P.push("runner: expected tags "+w.join(", ")+", found "+(h.length?h.join(", "):"none"));else C.push("runner tags "+w.join(", "))}}',
471
- 'else if(x.selfHosted){if(s.runnerEnvironment===undefined)S.push("runner (the runner says nothing about itself: no RUNNER_ENVIRONMENT)");else if(s.runnerEnvironment!=="self-hosted")P.push("runner: expected self-hosted, found "+s.runnerEnvironment);else C.push("self-hosted runner")}',
472
- 'const at=(x.product||"chant")+" check-job: "+x.job;',
473
- 'if(P.length>0){for(const p of P)console.error(at+": "+p);console.error(at+": this job does not run where the spec set it to run, so it stops before any credential is taken or code checked out");process.exit(' + CHANT_EXIT.misplaced + ")}",
474
- 'console.log(at+": "+(C.length?C.join(", "):"nothing to check")+(S.length?"; not checked: "+S.join(", "):""))',
475
- "}).catch((e)=>fail(e&&e.message?e.message:String(e)));",
476
- ].join("");
477
- /** The shell line of the guard step: `node -e` from `/`, so no file of the checkout is in reach. */
478
- export function jobGuardLine() {
479
- return `(cd / && node -e '${JOB_GUARD_JS}')`;
522
+ export function jobGuardLine(spec) {
523
+ return `(cd / && node -e '${spec?.defaultBranch ? JOB_GUARD_DEFAULT_BRANCH_JS : JOB_GUARD_JS}')`;
480
524
  }
481
525
  /** How the guard's lines name an op-wave job: `wave 2 (prod) of deploy`, `share 1 of job group eu of wave 2 (prod) of deploy`. */
482
526
  export function opWaveJobLabel(spec, job) {
package/dist/ci-jobs.d.ts CHANGED
@@ -50,6 +50,28 @@ export declare const PR_ENV_REPORT_DIR = ".chant/pr-env";
50
50
  * forge.
51
51
  */
52
52
  export declare function pushBranches(branches: readonly string[] | undefined): string[];
53
+ /**
54
+ * The branches an Op waves spec names (#5032): with `defaultBranch` its
55
+ * `branches` alone, beside the repository's default branch that the forge
56
+ * names at run time; without it {@link pushBranches}'.
57
+ */
58
+ export declare function wavesNamedBranches(spec: {
59
+ branches?: readonly string[];
60
+ defaultBranch?: boolean;
61
+ }): string[];
62
+ /** GitHub and Forgejo: the `if:` expression for a ref the waves run from (#5032), the default branch first. */
63
+ export declare function githubWavesBranchIf(spec: {
64
+ branches?: readonly string[];
65
+ defaultBranch?: boolean;
66
+ }): string;
67
+ /** GitLab: each branch a waves spec runs from as a rule's operand (#5032): `$CI_DEFAULT_BRANCH`, then each named one quoted. */
68
+ export declare function gitlabWavesBranches(spec: {
69
+ branches?: readonly string[];
70
+ defaultBranch?: boolean;
71
+ }): Array<{
72
+ branch: string;
73
+ operand: string;
74
+ }>;
53
75
  /**
54
76
  * The branches a trigger filters on: a `pull_request` trigger's list, or
55
77
  * undefined for every branch; a `push` trigger's, with {@link pushBranches}'
@@ -1 +1 @@
1
- {"version":3,"file":"ci-jobs.d.ts","sourceRoot":"","sources":["../src/ci-jobs.ts"],"names":[],"mappings":"AAA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;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAYxE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAqBrI;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AACrD,eAAO,MAAM,wBAAwB,mBAAmB,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAuB3I;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,SAAS,GAAG,MAAM,EAAE,CAWtG;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,GAAG,IAAI,CAqBtF"}
package/dist/ci-jobs.js CHANGED
@@ -52,6 +52,29 @@ export const PR_ENV_REPORT_DIR = ".chant/pr-env";
52
52
  export function pushBranches(branches) {
53
53
  return branches && branches.length > 0 ? [...branches] : [DEFAULT_BRANCH];
54
54
  }
55
+ /**
56
+ * The branches an Op waves spec names (#5032): with `defaultBranch` its
57
+ * `branches` alone, beside the repository's default branch that the forge
58
+ * names at run time; without it {@link pushBranches}'.
59
+ */
60
+ export function wavesNamedBranches(spec) {
61
+ return spec.defaultBranch === true ? [...(spec.branches ?? [])] : pushBranches(spec.branches);
62
+ }
63
+ /** GitHub and Forgejo: the `if:` expression for a ref the waves run from (#5032), the default branch first. */
64
+ export function githubWavesBranchIf(spec) {
65
+ const quoted = (b) => `'refs/heads/${b.replace(/'/g, "''")}'`;
66
+ return [
67
+ ...(spec.defaultBranch === true ? ["github.ref == format('refs/heads/{0}', github.event.repository.default_branch)"] : []),
68
+ ...wavesNamedBranches(spec).map((b) => `github.ref == ${quoted(b)}`),
69
+ ].join(" || ");
70
+ }
71
+ /** GitLab: each branch a waves spec runs from as a rule's operand (#5032): `$CI_DEFAULT_BRANCH`, then each named one quoted. */
72
+ export function gitlabWavesBranches(spec) {
73
+ return [
74
+ ...(spec.defaultBranch === true ? [{ branch: "", operand: "$CI_DEFAULT_BRANCH" }] : []),
75
+ ...wavesNamedBranches(spec).map((b) => ({ branch: b, operand: JSON.stringify(b) })),
76
+ ];
77
+ }
55
78
  /**
56
79
  * The branches a trigger filters on: a `pull_request` trigger's list, or
57
80
  * undefined for every branch; a `push` trigger's, with {@link pushBranches}'
@@ -163,7 +163,43 @@ export declare const OP_WAVES_NAMES_FLOOR = "0.124.92";
163
163
  * The first chant whose product pipeline names its comment job and its waves' jobs as the product does (#5027): `commentJob: { jobName }` (default `comment`, such as terragucci's `apply-comment`), refused when another job of the workflow has the name, and `wavesJobNames`, the Op waves generators' `jobNames`, which `waves.pipeline` carries to the generator and `waves.jobs` takes, and under which the comment job's re-run of a merged pull request's apply looks for the waves' jobs (`CHANT_COMMENT_JOBS` `applyJobs`, `rerunApplyJobs`), so terragucci's `apply-wave-<k>`, `-share-<n>`, group jobs and `apply-rest` run again. Without them the job is `comment` and the re-run looks for `RERUN_APPLY_JOBS`, as before.
164
164
  */
165
165
  export declare const PRODUCT_JOB_NAMES_FLOOR = "0.124.92";
166
- export { opWavesArtifacts, opWavesDispatchInputs, opWavesNamer, opWavesWorkflowFile, type OpWavesArtifactNames, type OpWavesDispatchInput, type OpWavesJobNames, type OpWavesJobRef, type OpWavesJobRole, type OpWavesStageNames, type OpWavesStageRef } from "./op/op-waves-names.js";
166
+ /**
167
+ * The first chant whose Op waves run from the repository's default branch by the name the forge gives it at run time (#5032): the spec's `defaultBranch: true`, with or without `branches` beside it. Every job's guard admits the default branch (GitLab's `CI_DEFAULT_BRANCH`; on GitHub and Forgejo `CHANT_DEFAULT_BRANCH`, which each guarded job sets from `github.event.repository.default_branch`) and the named branches, every GitLab rule matches `$CI_DEFAULT_BRANCH` (the push's, the before-merge and the follow-on pipelines', the evidence, status, control and stale-notes jobs'), the GitHub and Forgejo jobs' `if:` names it when the product gives no `runIf`, and the stand-down counts a newer commit on it. Without it the waves run from `branches`, default `main`, as before.
168
+ */
169
+ export declare const OP_WAVES_DEFAULT_BRANCH_FLOOR = "0.124.93";
170
+ /**
171
+ * The first chant whose Op waves generators take `firstWaveNeeds` (#5032): the product's own jobs, such as terragucci's `check`, that the first wave's own or deciding job (and before merge its plan job, and on GitLab its policy job) needs, so a push that fails the product's check applies nothing. GitHub and Forgejo: each must pass, or, in a dispatched run, not have run, and it goes with `runIf`; GitLab: optional needs, each to pass. Absent, the jobs render as before.
172
+ */
173
+ export declare const OP_WAVES_FIRST_WAVE_NEEDS_FLOOR = "0.124.93";
174
+ /**
175
+ * The first chant whose notify config takes `relayName` (#5033): the relay's name as people mention it in Teams, a plain value, which `sendNotify` (and so a wave's and a drift notice's messages) passes to the Teams card over the product's words' own, so a waiting wave's card spells out `reply @<name> approve <token>`. Without it the messages are as before.
176
+ */
177
+ export declare const NOTIFY_RELAY_NAME_FLOOR = "0.124.93";
178
+ /**
179
+ * The first chant whose Op waves resume keeps a product's names (#5034): `resumeWorkflowFile` names the GitHub and Forgejo resume workflow's file (such as terragucci's `terragucci-resume.yml`; default `<spec>-resume.yml`, refused on GitLab and when it is the waves' own file), and `jobNames` is called for the resume job with the role `resume` (GitHub and Forgejo `resume`, GitLab `<spec>-resume` by default). Without them the files render as before.
180
+ */
181
+ export declare const OP_WAVES_RESUME_NAMES_FLOOR = "0.124.93";
182
+ /**
183
+ * The first chant whose Op waves before merge take `beforeMerge.environment` (#5037): the forge environment the job after the last wave runs in, so a merge token scoped to it reaches that job alone (GitLab `environment: { name, action: access }`, GitHub `environment: <name>`; Forgejo refuses it), with the product pipeline's `wavesBeforeMerge.environment` carried through `waves.pipeline`. Without it the job is as before.
184
+ */
185
+ export declare const WAVES_BEFORE_MERGE_ENVIRONMENT_FLOOR = "0.124.93";
186
+ /**
187
+ * The first chant whose GitLab note poll keeps a product's names (#5038): the product pipeline's `noteCommandsJob` gives its job's name (default `note-commands`), its stage (default the job's name) and the variable and value a pipeline schedule starts it with (default `CHANT_NOTE_COMMANDS=1`), such as terragucci's `comments` job and `TERRAGUCCI_SCHEDULE=comments`, rendered in the job, its stage, its rule, its resource group and the workflow's rules. Refused on GitHub and Forgejo, without `noteCommands`, and on a name another job has. Without it the pipeline is as before.
188
+ */
189
+ export declare const NOTE_POLL_NAMES_FLOOR = "0.124.93";
190
+ /**
191
+ * The first chant whose Op waves generators take `commandToken` (#5044), GitHub and Forgejo: the jobs that run only the default branch's code (a push's wave, deciding, share and job group jobs; a split wave's gate and record jobs) hand their command step the job's token as `GITHUB_TOKEN`, so the spec's `respond` posts a refused wave's diff and a failed apply's triage and a product's hooks can read the forge, and ask for `permissions` beside chant's own. A split wave's plan and applying jobs never get it; GitLab refuses it. Without it no wave job holds a token, as before.
192
+ */
193
+ export declare const OP_WAVES_COMMAND_TOKEN_FLOOR = "0.124.94";
194
+ /**
195
+ * The first chant whose GitLab Op waves generator takes `cache` (#5045): the `cache:` entry or entries of each job that runs the wave's command (the wave's own, deciding, share and job group jobs, the policy job, a split wave's plan and applying jobs), such as terragucci's Terragrunt sources and providers cache. The gate and record jobs take none; GitHub and Forgejo refuse it, since a wave's `setup` step does this there. Without it no wave job has a cache, as before.
196
+ */
197
+ export declare const OP_WAVES_GITLAB_CACHE_FLOOR = "0.124.94";
198
+ /**
199
+ * The first chant whose Op waves generators take `controlGroup` and `resumeGroup` (#5053): the control job's group (GitHub and Forgejo `concurrency` with `cancel-in-progress: false`, GitLab `resource_group`), with `{commit}` standing for the commit it tells the control repo about, so a push's run and a resume's run send one dispatch per commit; and the GitLab resume job's `resource_group`. Without them neither job has a group, as before.
200
+ */
201
+ export declare const OP_WAVES_GROUPS_FLOOR = "0.124.94";
202
+ export { opWavesArtifacts, opWavesCommandToken, opWavesControlGroup, opWavesDispatchInputs, opWavesGitlabCache, opWavesNamer, opWavesResumeGroup, opWavesResumeWorkflowFile, opWavesWorkflowFile, type OpWavesArtifactNames, type OpWavesCommandToken, type OpWavesDispatchInput, type OpWavesJobNames, type OpWavesJobRef, type OpWavesJobRole, type OpWavesStageNames, type OpWavesStageRef } from "./op/op-waves-names.js";
167
203
  /**
168
204
  * Day-2 actions in the product pipeline (#4654): the `action` comment
169
205
  * command counted as answered by the product's own workflow
@@ -311,6 +347,10 @@ export type { ProductMcpContext, ProductMcpHook } from "./cli/mcp/product-tools.
311
347
  * and `destructiveHint`, and a contribution's `annotations` add the rest.
312
348
  */
313
349
  export { MCP_TOOL_ANNOTATIONS_FLOOR, PRODUCT_MCP_PROPOSE_FLOOR, PRODUCT_TOOL_PROPOSE_WORDS } from "./cli/mcp/product-tools.js";
350
+ /** #5047: the Op waves keep the stopped-apply record (`approvals.remainder`, `approvals.spendStanding`), in place of a product's own. */
351
+ export { OP_WAVES_REMAINDER_FLOOR } from "./release-floors.js";
352
+ export { OP_WAVES_SPLIT_RESUME_FLOOR } from "./release-floors.js";
353
+ export { OP_WAVES_REMAINDER_PARITY_FLOOR } from "./release-floors.js";
314
354
  export type { McpToolContribution, ToolAnnotations } from "./mcp/types.js";
315
355
  export { activeOtlp, configureOtlp, OTLP_EXPORTER_FLOOR, RunEventTrace, type CapabilityTraceFacts, type CapabilityTraceSpan, type OtlpExporter, } from "./otlp.js";
316
356
  //# sourceMappingURL=ci-product.d.ts.map