@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.
- package/dist/__golden__/notify-defaults-plain.json +52 -0
- package/dist/__golden__/notify-defaults-relay.json +92 -0
- package/dist/ci-job-guard.d.ts +22 -8
- package/dist/ci-job-guard.d.ts.map +1 -1
- package/dist/ci-job-guard.js +93 -49
- package/dist/ci-jobs.d.ts +22 -0
- package/dist/ci-jobs.d.ts.map +1 -1
- package/dist/ci-jobs.js +23 -0
- package/dist/ci-product.d.ts +41 -1
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +45 -5
- package/dist/cli/handlers/run-wave.js +17 -3
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +4 -1
- package/dist/components/product-pipeline.d.ts +30 -0
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +28 -3
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +17 -4
- package/dist/gate-resume-run.d.ts +7 -0
- package/dist/gate-resume-run.d.ts.map +1 -1
- package/dist/gate-resume-run.js +42 -3
- package/dist/lexicon.d.ts +64 -1
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/gate-applied.d.ts +18 -0
- package/dist/lifecycle/gate-applied.d.ts.map +1 -1
- package/dist/notify.d.ts +8 -0
- package/dist/notify.d.ts.map +1 -1
- package/dist/notify.js +8 -3
- package/dist/op/before-merge.d.ts +8 -0
- package/dist/op/before-merge.d.ts.map +1 -1
- package/dist/op/before-merge.js +6 -0
- package/dist/op/gate-run-locator.d.ts +17 -0
- package/dist/op/gate-run-locator.d.ts.map +1 -1
- package/dist/op/index.d.ts +4 -2
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +3 -2
- package/dist/op/op-waves-names.d.ts +65 -2
- package/dist/op/op-waves-names.d.ts.map +1 -1
- package/dist/op/op-waves-names.js +129 -0
- package/dist/op/op-waves-remainder.d.ts +110 -0
- package/dist/op/op-waves-remainder.d.ts.map +1 -0
- package/dist/op/op-waves-remainder.js +120 -0
- package/dist/op/op-waves-render-spec.d.ts +63 -5
- package/dist/op/op-waves-render-spec.d.ts.map +1 -1
- package/dist/op/op-waves-render-spec.js +68 -10
- package/dist/op/op-waves-run.d.ts +29 -1
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +194 -6
- package/dist/op/op-waves-split-resume.d.ts +57 -0
- package/dist/op/op-waves-split-resume.d.ts.map +1 -0
- package/dist/op/op-waves-split-resume.js +94 -0
- package/dist/op/op-waves-stand-down.d.ts +9 -1
- package/dist/op/op-waves-stand-down.d.ts.map +1 -1
- package/dist/op/op-waves-stand-down.js +14 -2
- package/dist/op/op-waves.d.ts +38 -2
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +13 -2
- package/dist/release-floors.d.ts +9 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +9 -1
- package/dist/wave-runtime.mjs +368 -368
- package/package.json +1 -1
- package/src/__golden__/notify-defaults-plain.json +52 -0
- package/src/__golden__/notify-defaults-relay.json +92 -0
- package/src/ci-job-guard.default-branch.test.ts +125 -0
- package/src/ci-job-guard.ts +64 -10
- package/src/ci-jobs.ts +26 -0
- package/src/ci-product.ts +54 -5
- package/src/cli/handlers/run-wave.ts +16 -3
- package/src/cli/main.ts +4 -1
- package/src/components/product-pipeline.ts +49 -4
- package/src/floor-table.data.ts +17 -4
- package/src/gate-resume-run.ts +38 -3
- package/src/lexicon.ts +64 -1
- package/src/lifecycle/gate-applied.ts +16 -0
- package/src/notify-bundle.test.ts +3 -2
- package/src/notify-relay-name.test.ts +72 -0
- package/src/notify.ts +16 -3
- package/src/op/before-merge.ts +12 -0
- package/src/op/gate-run-locator.ts +14 -0
- package/src/op/index.ts +6 -1
- package/src/op/op-waves-names.ts +130 -2
- package/src/op/op-waves-remainder.test.ts +342 -0
- package/src/op/op-waves-remainder.ts +146 -0
- package/src/op/op-waves-render-spec.test.ts +107 -0
- package/src/op/op-waves-render-spec.ts +81 -10
- package/src/op/op-waves-run.ts +204 -7
- package/src/op/op-waves-split-resume.test.ts +149 -0
- package/src/op/op-waves-split-resume.ts +109 -0
- package/src/op/op-waves-stand-down.ts +15 -2
- package/src/op/op-waves.ts +46 -3
- package/src/release-floors.ts +13 -1
package/package.json
CHANGED
|
@@ -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
|
+
]
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #5032: a waves job that runs from the repository's default branch, by
|
|
3
|
+
* the name the forge gives it at run time, with or without named branches
|
|
4
|
+
* beside it. The default branch here is `trunk`, never `main`.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, expect, test } from "vitest";
|
|
7
|
+
import { spawnSync } from "node:child_process";
|
|
8
|
+
import { CHANT_EXIT } from "./exit-codes";
|
|
9
|
+
import {
|
|
10
|
+
checkJob,
|
|
11
|
+
describeJobGuard,
|
|
12
|
+
JOB_DEFAULT_BRANCH_ENV,
|
|
13
|
+
JOB_GUARD_DEFAULT_BRANCH_JS,
|
|
14
|
+
JOB_GUARD_ENV,
|
|
15
|
+
JOB_GUARD_JS,
|
|
16
|
+
jobGuardLine,
|
|
17
|
+
jobGuardSpec,
|
|
18
|
+
jobSeen,
|
|
19
|
+
parseJobGuardSpec,
|
|
20
|
+
type JobGuardSpec,
|
|
21
|
+
} from "./ci-job-guard";
|
|
22
|
+
import { opWaveDefaultBranch, tipAppliesTargets } from "./op/op-waves-stand-down";
|
|
23
|
+
import { githubWavesBranchIf, gitlabWavesBranches, wavesNamedBranches } from "./ci-jobs";
|
|
24
|
+
import type { OpWavesSpec } from "./op/op-waves";
|
|
25
|
+
|
|
26
|
+
const noFetch = (() => Promise.reject(new Error("no fetch"))) as unknown as typeof fetch;
|
|
27
|
+
const program = (spec: JobGuardSpec, env: Record<string, string>) =>
|
|
28
|
+
spawnSync(process.execPath, ["-e", JOB_GUARD_DEFAULT_BRANCH_JS], { env: { PATH: process.env.PATH ?? "", [JOB_GUARD_ENV]: JSON.stringify(spec), ...env }, encoding: "utf-8" });
|
|
29
|
+
|
|
30
|
+
describe("the guard on the default branch (#5032)", () => {
|
|
31
|
+
test("the spec says so only when asked, and parses back", () => {
|
|
32
|
+
expect(jobGuardSpec({ forge: "github", job: "w", branches: [] , defaultBranch: true })).toEqual({ forge: "github", job: "w", branches: [], defaultBranch: true });
|
|
33
|
+
expect(jobGuardSpec({ forge: "github", job: "w", branches: ["main"] })).not.toHaveProperty("defaultBranch");
|
|
34
|
+
expect(parseJobGuardSpec(JSON.stringify({ forge: "gitlab", job: "w", branches: [], defaultBranch: true })).defaultBranch).toBe(true);
|
|
35
|
+
expect(() => parseJobGuardSpec(JSON.stringify({ forge: "gitlab", job: "w", branches: [], defaultBranch: "main" }))).toThrow(/defaultBranch is true or absent/);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const github: JobGuardSpec = { forge: "github", job: "wave 1 (wave-1) of tf-apply", product: "terragucci", branches: [], defaultBranch: true };
|
|
39
|
+
const forgejo: JobGuardSpec = { ...github, forge: "forgejo", branches: ["release"] };
|
|
40
|
+
const gitlab: JobGuardSpec = { forge: "gitlab", job: "wave 1 (wave-1) of tf-apply", branches: ["release"], defaultBranch: true };
|
|
41
|
+
|
|
42
|
+
test("GitHub admits the default branch the event names, and refuses main when it is not that", async () => {
|
|
43
|
+
const at = (ref: string, def?: string) => ({ GITHUB_REF: ref, ...(def !== undefined ? { [JOB_DEFAULT_BRANCH_ENV]: def } : {}) });
|
|
44
|
+
expect(checkJob(github, await jobSeen(github, at("refs/heads/trunk", "trunk"), noFetch)).problems).toEqual([]);
|
|
45
|
+
expect(checkJob(github, await jobSeen(github, at("refs/heads/main", "trunk"), noFetch)).problems).toEqual(["ref: expected refs/heads/trunk, found refs/heads/main"]);
|
|
46
|
+
expect(checkJob(github, await jobSeen(github, at("refs/heads/trunk"), noFetch)).problems).toEqual([`ref: the job runs from the default branch, and the forge names none (no ${JOB_DEFAULT_BRANCH_ENV})`]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("Forgejo admits the default branch and the named one beside it", async () => {
|
|
50
|
+
const seen = (ref: string) => jobSeen(forgejo, { GITHUB_REF: ref, [JOB_DEFAULT_BRANCH_ENV]: "trunk" }, noFetch);
|
|
51
|
+
expect(checkJob(forgejo, await seen("refs/heads/trunk")).checked).toContain("ref refs/heads/trunk");
|
|
52
|
+
expect(checkJob(forgejo, await seen("refs/heads/release")).checked).toContain("ref refs/heads/release");
|
|
53
|
+
expect(checkJob(forgejo, await seen("refs/heads/dev")).problems).toEqual(["ref: expected refs/heads/trunk or refs/heads/release, found refs/heads/dev"]);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("GitLab reads CI_DEFAULT_BRANCH, and still asks for a protected ref", async () => {
|
|
57
|
+
const env = (ref: string, prot = "true") => ({ CI_COMMIT_REF_NAME: ref, CI_COMMIT_REF_PROTECTED: prot, CI_DEFAULT_BRANCH: "trunk" });
|
|
58
|
+
expect(checkJob(gitlab, await jobSeen(gitlab, env("trunk"), noFetch)).problems).toEqual([]);
|
|
59
|
+
expect(checkJob(gitlab, await jobSeen(gitlab, env("release"), noFetch)).problems).toEqual([]);
|
|
60
|
+
expect(checkJob(gitlab, await jobSeen(gitlab, env("main"), noFetch)).problems).toEqual(["ref: expected trunk or release, found main"]);
|
|
61
|
+
expect(checkJob(gitlab, await jobSeen(gitlab, env("trunk", "false"), noFetch)).problems).toEqual(["ref: expected a protected ref (CI_COMMIT_REF_PROTECTED true), found false"]);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("a spec without defaultBranch reads no default branch", async () => {
|
|
65
|
+
const plain: JobGuardSpec = { forge: "gitlab", job: "w", branches: ["main"] };
|
|
66
|
+
expect(await jobSeen(plain, { CI_COMMIT_REF_NAME: "trunk", CI_DEFAULT_BRANCH: "trunk" }, noFetch)).not.toHaveProperty("defaultBranch");
|
|
67
|
+
expect(checkJob(plain, await jobSeen(plain, { CI_COMMIT_REF_NAME: "trunk", CI_COMMIT_REF_PROTECTED: "true", CI_DEFAULT_BRANCH: "trunk" }, noFetch)).problems).toEqual(["ref: expected main, found trunk"]);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const cases: Array<[string, JobGuardSpec, Record<string, string>]> = [
|
|
71
|
+
["GitHub on the default branch", github, { GITHUB_REF: "refs/heads/trunk", [JOB_DEFAULT_BRANCH_ENV]: "trunk" }],
|
|
72
|
+
["GitHub on main, which is not it", github, { GITHUB_REF: "refs/heads/main", [JOB_DEFAULT_BRANCH_ENV]: "trunk" }],
|
|
73
|
+
["GitHub with no default branch named", github, { GITHUB_REF: "refs/heads/trunk" }],
|
|
74
|
+
["Forgejo on the named branch", forgejo, { GITHUB_REF: "refs/heads/release", [JOB_DEFAULT_BRANCH_ENV]: "trunk" }],
|
|
75
|
+
["Forgejo elsewhere", forgejo, { GITHUB_REF: "refs/heads/dev", [JOB_DEFAULT_BRANCH_ENV]: "trunk" }],
|
|
76
|
+
["GitLab on the default branch", gitlab, { CI_COMMIT_REF_NAME: "trunk", CI_COMMIT_REF_PROTECTED: "true", CI_DEFAULT_BRANCH: "trunk" }],
|
|
77
|
+
["GitLab on main, which is not it", gitlab, { CI_COMMIT_REF_NAME: "main", CI_COMMIT_REF_PROTECTED: "true", CI_DEFAULT_BRANCH: "trunk" }],
|
|
78
|
+
["GitLab with only the named branch to go by", { ...gitlab }, { CI_COMMIT_REF_NAME: "release", CI_COMMIT_REF_PROTECTED: "true" }],
|
|
79
|
+
];
|
|
80
|
+
for (const [name, spec, env] of cases) {
|
|
81
|
+
test(`the node -e program agrees with checkJob: ${name}`, async () => {
|
|
82
|
+
const r = program(spec, env);
|
|
83
|
+
const want = describeJobGuard(spec, checkJob(spec, await jobSeen(spec, env, noFetch)));
|
|
84
|
+
expect(r.status).toBe(want.ok ? 0 : CHANT_EXIT.misplaced);
|
|
85
|
+
expect(r.stdout.trim().split("\n").filter(Boolean)).toEqual(want.out);
|
|
86
|
+
expect(r.stderr.trim().split("\n").filter(Boolean)).toEqual(want.err);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
test("the program holds no single quote, and a job without defaultBranch keeps the program it had", () => {
|
|
91
|
+
expect(JOB_GUARD_DEFAULT_BRANCH_JS).not.toContain("'");
|
|
92
|
+
expect(JOB_GUARD_JS).not.toContain(JOB_DEFAULT_BRANCH_ENV);
|
|
93
|
+
expect(jobGuardLine()).toBe(`(cd / && node -e '${JOB_GUARD_JS}')`);
|
|
94
|
+
expect(jobGuardLine({})).toBe(jobGuardLine());
|
|
95
|
+
expect(jobGuardLine({ defaultBranch: true })).toBe(`(cd / && node -e '${JOB_GUARD_DEFAULT_BRANCH_JS}')`);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe("the branches a waves spec runs from (#5032)", () => {
|
|
100
|
+
test("named alone, or beside the default branch", () => {
|
|
101
|
+
expect(wavesNamedBranches({})).toEqual(["main"]);
|
|
102
|
+
expect(wavesNamedBranches({ defaultBranch: true })).toEqual([]);
|
|
103
|
+
expect(wavesNamedBranches({ defaultBranch: true, branches: ["release"] })).toEqual(["release"]);
|
|
104
|
+
expect(githubWavesBranchIf({ defaultBranch: true, branches: ["release"] })).toBe("github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || github.ref == 'refs/heads/release'");
|
|
105
|
+
expect(gitlabWavesBranches({ defaultBranch: true, branches: ["release"] }).map((b) => b.operand)).toEqual(["$CI_DEFAULT_BRANCH", '"release"']);
|
|
106
|
+
expect(gitlabWavesBranches({ branches: ["main"] }).map((b) => b.operand)).toEqual(['"main"']);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
describe("the stand-down on the default branch (#5032)", () => {
|
|
111
|
+
const atTip = { name: "tf-apply", op: "tf-apply", defaultBranch: true, waves: [{ name: "wave-1", runs: [{ target: "network" }] }] } as unknown as OpWavesSpec;
|
|
112
|
+
test("a newer commit on the default branch, by its run-time name, makes the wave stand down", () => {
|
|
113
|
+
expect(tipAppliesTargets(atTip, "trunk", "wave-1", ["network"], "trunk")).toBe(true);
|
|
114
|
+
expect(tipAppliesTargets(atTip, "main", "wave-1", ["network"], "trunk")).toBe(false);
|
|
115
|
+
expect(tipAppliesTargets(atTip, "trunk", "wave-1", ["network"])).toBe(false);
|
|
116
|
+
expect(tipAppliesTargets({ ...atTip, branches: ["release"] }, "release", "wave-1", ["network"], "trunk")).toBe(true);
|
|
117
|
+
// Without defaultBranch the spec runs on main, as before.
|
|
118
|
+
expect(tipAppliesTargets({ ...atTip, defaultBranch: undefined } as unknown as OpWavesSpec, "main", "wave-1", ["network"], "trunk")).toBe(true);
|
|
119
|
+
});
|
|
120
|
+
test("the job's environment names it: CHANT_DEFAULT_BRANCH, else GitLab's CI_DEFAULT_BRANCH", () => {
|
|
121
|
+
expect(opWaveDefaultBranch({ CHANT_DEFAULT_BRANCH: "trunk" })).toBe("trunk");
|
|
122
|
+
expect(opWaveDefaultBranch({ CI_DEFAULT_BRANCH: "trunk" })).toBe("trunk");
|
|
123
|
+
expect(opWaveDefaultBranch({ CHANT_DEFAULT_BRANCH: " " })).toBeUndefined();
|
|
124
|
+
});
|
|
125
|
+
});
|
package/src/ci-job-guard.ts
CHANGED
|
@@ -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
|
|
@@ -80,6 +85,16 @@ import { followOnPath, followOnProblems, followOnRecordProblems, followOnRunFrom
|
|
|
80
85
|
/** The variable the generated step carries its expectation in. */
|
|
81
86
|
export const JOB_GUARD_ENV = "CHANT_JOB_GUARD";
|
|
82
87
|
|
|
88
|
+
/**
|
|
89
|
+
* The variable a GitHub or Forgejo job carries the repository's default
|
|
90
|
+
* branch in (#5032), from `github.event.repository.default_branch`. GitLab
|
|
91
|
+
* sets `CI_DEFAULT_BRANCH` itself.
|
|
92
|
+
*/
|
|
93
|
+
export const JOB_DEFAULT_BRANCH_ENV = "CHANT_DEFAULT_BRANCH";
|
|
94
|
+
|
|
95
|
+
/** The job variable that sets {@link JOB_DEFAULT_BRANCH_ENV} on GitHub and Forgejo (#5032). */
|
|
96
|
+
export const GITHUB_DEFAULT_BRANCH_ENV: Record<string, string> = { [JOB_DEFAULT_BRANCH_ENV]: "${{ github.event.repository.default_branch }}" };
|
|
97
|
+
|
|
83
98
|
/** The audience of the token the guard requests on GitHub, which no cloud role should trust. */
|
|
84
99
|
export const JOB_GUARD_AUDIENCE = "chant-check-job";
|
|
85
100
|
|
|
@@ -96,6 +111,8 @@ export interface JobGuardSpec {
|
|
|
96
111
|
forgeEnvironment?: string;
|
|
97
112
|
/** The branches the job may run from. */
|
|
98
113
|
branches: string[];
|
|
114
|
+
/** The job may also run from the repository's default branch, by the name the forge gives at run time (#5032). */
|
|
115
|
+
defaultBranch?: true;
|
|
99
116
|
/** GitLab: the tags the job's runner must carry. */
|
|
100
117
|
runnerTags?: string[];
|
|
101
118
|
/** GitHub and Forgejo: the runner must be self-hosted. */
|
|
@@ -114,6 +131,8 @@ export interface JobSeen {
|
|
|
114
131
|
forgeEnvironmentError?: string;
|
|
115
132
|
ref?: string;
|
|
116
133
|
refProtected?: string;
|
|
134
|
+
/** The repository's default branch, as the forge names it (#5032). Read only when the spec has `defaultBranch`. */
|
|
135
|
+
defaultBranch?: string;
|
|
117
136
|
runnerTags?: string[];
|
|
118
137
|
runnerEnvironment?: string;
|
|
119
138
|
/** The decision the run names (#4984), from its variables. */
|
|
@@ -148,6 +167,8 @@ export interface JobGuardInput {
|
|
|
148
167
|
environment?: string;
|
|
149
168
|
/** The branches the job runs from. */
|
|
150
169
|
branches: readonly string[];
|
|
170
|
+
/** The job also runs from the repository's default branch, whatever the forge calls it (#5032). */
|
|
171
|
+
defaultBranch?: boolean;
|
|
151
172
|
/** The job's runner, as the spec gives it. */
|
|
152
173
|
runner?: CiRunner;
|
|
153
174
|
/** GitHub: the job may request an OIDC token (`id-token: write`), so the guard can read its environment. */
|
|
@@ -171,6 +192,7 @@ export function jobGuardSpec(input: JobGuardInput): JobGuardSpec {
|
|
|
171
192
|
...(input.product && input.product !== "chant" ? { product: input.product } : {}),
|
|
172
193
|
...(input.environment !== undefined && readsEnvironment ? { forgeEnvironment: input.environment } : {}),
|
|
173
194
|
branches: [...input.branches],
|
|
195
|
+
...(input.defaultBranch === true ? { defaultBranch: true as const } : {}),
|
|
174
196
|
...(input.forge === "gitlab" && labels.length > 0 ? { runnerTags: labels } : {}),
|
|
175
197
|
...(input.forge !== "gitlab" && labels.includes("self-hosted") ? { selfHosted: true } : {}),
|
|
176
198
|
...(input.beforeMerge ? { beforeMerge: { op: input.beforeMerge.op } } : {}),
|
|
@@ -192,6 +214,7 @@ export function parseJobGuardSpec(raw: string | undefined): JobGuardSpec {
|
|
|
192
214
|
if (o.forge !== "github" && o.forge !== "gitlab" && o.forge !== "forgejo") throw new Error(`${JOB_GUARD_ENV}.forge is ${JSON.stringify(o.forge)}; give github, gitlab or forgejo`);
|
|
193
215
|
if (typeof o.job !== "string" || o.job === "") throw new Error(`${JOB_GUARD_ENV}.job names no job`);
|
|
194
216
|
if (!Array.isArray(o.branches) || o.branches.some((b) => typeof b !== "string")) throw new Error(`${JOB_GUARD_ENV}.branches is not a list of branches`);
|
|
217
|
+
if (o.defaultBranch !== undefined && o.defaultBranch !== true) throw new Error(`${JOB_GUARD_ENV}.defaultBranch is true or absent`);
|
|
195
218
|
if (o.forgeEnvironment !== undefined && typeof o.forgeEnvironment !== "string") throw new Error(`${JOB_GUARD_ENV}.forgeEnvironment is not a name`);
|
|
196
219
|
if (o.runnerTags !== undefined && (!Array.isArray(o.runnerTags) || o.runnerTags.some((t) => typeof t !== "string"))) throw new Error(`${JOB_GUARD_ENV}.runnerTags is not a list of tags`);
|
|
197
220
|
if (o.beforeMerge !== undefined && (typeof o.beforeMerge !== "object" || o.beforeMerge === null || typeof o.beforeMerge.op !== "string")) throw new Error(`${JOB_GUARD_ENV}.beforeMerge is { op }`);
|
|
@@ -201,6 +224,9 @@ export function parseJobGuardSpec(raw: string | undefined): JobGuardSpec {
|
|
|
201
224
|
|
|
202
225
|
const shown = (v: string | null | undefined): string => (v === undefined || v === null || v === "" ? "none" : v);
|
|
203
226
|
|
|
227
|
+
/** The variable the guard reads the default branch from (#5032). */
|
|
228
|
+
const defaultBranchVar = (forge: JobGuardForge): string => (forge === "gitlab" ? "CI_DEFAULT_BRANCH" : JOB_DEFAULT_BRANCH_ENV);
|
|
229
|
+
|
|
204
230
|
/** The tags CI_RUNNER_TAGS lists: a JSON array, or a comma-separated list. */
|
|
205
231
|
export function runnerTagsOf(raw: string | undefined): string[] | undefined {
|
|
206
232
|
if (raw === undefined) return undefined;
|
|
@@ -237,8 +263,11 @@ export function checkJob(expect: JobGuardSpec, seen: JobSeen): JobGuardResult {
|
|
|
237
263
|
else out.checked.push(`forge environment ${fe}`);
|
|
238
264
|
}
|
|
239
265
|
|
|
240
|
-
|
|
241
|
-
|
|
266
|
+
// #5032: the repository's default branch, by the name the forge gives this run, beside the named ones.
|
|
267
|
+
const named = expect.branches.filter((b) => b !== "");
|
|
268
|
+
const def = expect.defaultBranch ? (seen.defaultBranch ?? "").trim() : "";
|
|
269
|
+
const branches = def !== "" && !named.includes(def) ? [def, ...named] : named;
|
|
270
|
+
if (branches.length === 0) 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");
|
|
242
271
|
else if (expect.forge === "gitlab") {
|
|
243
272
|
if (!seen.ref || !branches.includes(seen.ref)) out.problems.push(`ref: expected ${branches.join(" or ")}, found ${shown(seen.ref)}`);
|
|
244
273
|
else out.checked.push(`ref ${seen.ref}`);
|
|
@@ -373,15 +402,19 @@ export const lifecycleFileByGit: LifecycleFileReader = (forge, env, path) => {
|
|
|
373
402
|
|
|
374
403
|
/** What the forge's own variables and token say, before the decision is read. */
|
|
375
404
|
async function forgeSeen(expect: JobGuardSpec, env: NodeJS.ProcessEnv, fetchFn: typeof fetch): Promise<JobSeen> {
|
|
405
|
+
// #5032: the default branch, read only when the spec runs from it.
|
|
406
|
+
const def = expect.defaultBranch ? env[defaultBranchVar(expect.forge)] : undefined;
|
|
407
|
+
const defaultBranch = def !== undefined && def.trim() !== "" ? { defaultBranch: def.trim() } : {};
|
|
376
408
|
if (expect.forge === "gitlab") {
|
|
377
409
|
return {
|
|
410
|
+
...defaultBranch,
|
|
378
411
|
forgeEnvironment: env.CI_ENVIRONMENT_NAME || null,
|
|
379
412
|
...(env.CI_COMMIT_REF_NAME !== undefined ? { ref: env.CI_COMMIT_REF_NAME } : {}),
|
|
380
413
|
...(env.CI_COMMIT_REF_PROTECTED !== undefined ? { refProtected: env.CI_COMMIT_REF_PROTECTED } : {}),
|
|
381
414
|
...(env.CI_RUNNER_TAGS !== undefined ? { runnerTags: runnerTagsOf(env.CI_RUNNER_TAGS) } : {}),
|
|
382
415
|
};
|
|
383
416
|
}
|
|
384
|
-
const seen: JobSeen = { ...(env.GITHUB_REF !== undefined ? { ref: env.GITHUB_REF } : {}) };
|
|
417
|
+
const seen: JobSeen = { ...(env.GITHUB_REF !== undefined ? { ref: env.GITHUB_REF } : {}), ...defaultBranch };
|
|
385
418
|
let claims: Record<string, unknown> | undefined;
|
|
386
419
|
if (expect.forge === "github" && expect.forgeEnvironment !== undefined) {
|
|
387
420
|
try {
|
|
@@ -478,8 +511,19 @@ const FOLLOW_ON_JS = [
|
|
|
478
511
|
* Exits chant's `misplaced` (9) with one line per value that differs, and
|
|
479
512
|
* when the variable holds no spec it can read. A test runs it against
|
|
480
513
|
* {@link checkJob} so the two stay the same.
|
|
514
|
+
*
|
|
515
|
+
* `defaultBranch` (#5032) gives the program that also reads the default
|
|
516
|
+
* branch, for a spec with `defaultBranch`; a job without it carries the
|
|
517
|
+
* program as it was.
|
|
481
518
|
*/
|
|
482
|
-
|
|
519
|
+
function jobGuardProgram(defaultBranch: boolean): string {
|
|
520
|
+
const branchLines = defaultBranch
|
|
521
|
+
? [
|
|
522
|
+
`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);`,
|
|
523
|
+
'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");',
|
|
524
|
+
]
|
|
525
|
+
: ['const b=x.branches.filter((v)=>v!=="");', 'if(b.length===0)P.push("ref: the job names no branch to run from");'];
|
|
526
|
+
return [
|
|
483
527
|
'"use strict";',
|
|
484
528
|
`const E=process.env,A=${JSON.stringify(JOB_GUARD_AUDIENCE)};`,
|
|
485
529
|
"const shown=(v)=>v===undefined||v===null||v===\"\"?\"none\":v;",
|
|
@@ -502,8 +546,7 @@ export const JOB_GUARD_JS = [
|
|
|
502
546
|
"seenOf().then((s)=>{const P=[],C=[],S=[];const fe=x.forgeEnvironment;",
|
|
503
547
|
'if(x.forge==="forgejo")S.push("forge environment (Forgejo has none)");',
|
|
504
548
|
'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)}',
|
|
505
|
-
|
|
506
|
-
'if(b.length===0)P.push("ref: the job names no branch to run from");',
|
|
549
|
+
...branchLines,
|
|
507
550
|
'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);',
|
|
508
551
|
'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")}',
|
|
509
552
|
'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)}',
|
|
@@ -521,10 +564,21 @@ export const JOB_GUARD_JS = [
|
|
|
521
564
|
'console.log(at+": "+(C.length?C.join(", "):"nothing to check")+(S.length?"; not checked: "+S.join(", "):""))',
|
|
522
565
|
"}).catch((e)=>fail(e&&e.message?e.message:String(e)));",
|
|
523
566
|
].join("");
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/** The guard as one `node -e` program; see {@link jobGuardProgram}. */
|
|
570
|
+
export const JOB_GUARD_JS = jobGuardProgram(false);
|
|
571
|
+
|
|
572
|
+
/** The same program for a spec with `defaultBranch` (#5032), which also reads the default branch. */
|
|
573
|
+
export const JOB_GUARD_DEFAULT_BRANCH_JS = jobGuardProgram(true);
|
|
524
574
|
|
|
525
|
-
/**
|
|
526
|
-
|
|
527
|
-
|
|
575
|
+
/**
|
|
576
|
+
* The shell line of the guard step: `node -e` from `/`, so no file of the
|
|
577
|
+
* checkout is in reach. #5032: a spec with `defaultBranch` gets the program
|
|
578
|
+
* that reads the default branch.
|
|
579
|
+
*/
|
|
580
|
+
export function jobGuardLine(spec?: Pick<JobGuardSpec, "defaultBranch">): string {
|
|
581
|
+
return `(cd / && node -e '${spec?.defaultBranch ? JOB_GUARD_DEFAULT_BRANCH_JS : JOB_GUARD_JS}')`;
|
|
528
582
|
}
|
|
529
583
|
|
|
530
584
|
/** 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`. */
|
package/src/ci-jobs.ts
CHANGED
|
@@ -60,6 +60,32 @@ export function pushBranches(branches: readonly string[] | undefined): string[]
|
|
|
60
60
|
return branches && branches.length > 0 ? [...branches] : [DEFAULT_BRANCH];
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* The branches an Op waves spec names (#5032): with `defaultBranch` its
|
|
65
|
+
* `branches` alone, beside the repository's default branch that the forge
|
|
66
|
+
* names at run time; without it {@link pushBranches}'.
|
|
67
|
+
*/
|
|
68
|
+
export function wavesNamedBranches(spec: { branches?: readonly string[]; defaultBranch?: boolean }): string[] {
|
|
69
|
+
return spec.defaultBranch === true ? [...(spec.branches ?? [])] : pushBranches(spec.branches);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** GitHub and Forgejo: the `if:` expression for a ref the waves run from (#5032), the default branch first. */
|
|
73
|
+
export function githubWavesBranchIf(spec: { branches?: readonly string[]; defaultBranch?: boolean }): string {
|
|
74
|
+
const quoted = (b: string): string => `'refs/heads/${b.replace(/'/g, "''")}'`;
|
|
75
|
+
return [
|
|
76
|
+
...(spec.defaultBranch === true ? ["github.ref == format('refs/heads/{0}', github.event.repository.default_branch)"] : []),
|
|
77
|
+
...wavesNamedBranches(spec).map((b) => `github.ref == ${quoted(b)}`),
|
|
78
|
+
].join(" || ");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** GitLab: each branch a waves spec runs from as a rule's operand (#5032): `$CI_DEFAULT_BRANCH`, then each named one quoted. */
|
|
82
|
+
export function gitlabWavesBranches(spec: { branches?: readonly string[]; defaultBranch?: boolean }): Array<{ branch: string; operand: string }> {
|
|
83
|
+
return [
|
|
84
|
+
...(spec.defaultBranch === true ? [{ branch: "", operand: "$CI_DEFAULT_BRANCH" }] : []),
|
|
85
|
+
...wavesNamedBranches(spec).map((b) => ({ branch: b, operand: JSON.stringify(b) })),
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
|
|
63
89
|
/**
|
|
64
90
|
* The branches a trigger filters on: a `pull_request` trigger's list, or
|
|
65
91
|
* undefined for every branch; a `push` trigger's, with {@link pushBranches}'
|
package/src/ci-product.ts
CHANGED
|
@@ -258,23 +258,68 @@ export const PRODUCT_PLAN_ARTIFACTS_FLOOR = "0.124.91";
|
|
|
258
258
|
/**
|
|
259
259
|
* The first chant whose GitHub and Forgejo product plan, after a `login` or with `idTokens`, starts every step after the checkout but the login's without `ACTIONS_ID_TOKEN_REQUEST_URL` and `ACTIONS_ID_TOKEN_REQUEST_TOKEN` (#5021), as after a `trade`: the setup, the probe and the plan step, in the plan and the re-plan job, so the change's code can request no token. A product's own `idTokens` leave them in the plan step, whose verb requests them.
|
|
260
260
|
*/
|
|
261
|
-
export const PRODUCT_PLAN_LOGIN_TOKENS_FLOOR =
|
|
261
|
+
export const PRODUCT_PLAN_LOGIN_TOKENS_FLOOR = "0.124.92";
|
|
262
262
|
|
|
263
263
|
/**
|
|
264
264
|
* The first chant whose pull request jobs on GitHub and Forgejo name the pull request's head, `github.event.pull_request.head.sha`, where `github.sha` named the merge preview (#5020): the product plan's pending step (`CHANT_PENDING_SHA`), the note job's `HEAD_SHA` (the product plan's, the pull request loop's and the product pipeline's) and the `env-post` job's. `pr-post --head <head>` takes a report, a plan note hand-off or a run record for the head or for the run's merge preview the plan job checked out (`plannedForHead`), so a product's plan verb may write its hand-off for either.
|
|
265
265
|
*/
|
|
266
|
-
export const PR_HEAD_SHA_FLOOR =
|
|
266
|
+
export const PR_HEAD_SHA_FLOOR = "0.124.92";
|
|
267
267
|
|
|
268
268
|
/**
|
|
269
269
|
* The first chant whose Op waves generators keep a product's own names (#5022): `jobNames` (every job they write: a wave's, deciding, share and job group jobs, a split wave's plan, gate, apply and record jobs, the policy and evidence jobs, the apply status, stale, before-merge done and control jobs; `needs:`, `if:`, `{job}` and `--from-job` follow it), `stageNames` (GitLab), `artifactNames` (the outcome, decision, saved plan and check claims artifacts, and the pattern a wave job downloads the earlier outcomes with), `workflowFile` (the generators' file and the follow-on's dispatch), `runIf` (the jobs go in the product's own workflow, each running on a push it admits or a before-merge or follow-on dispatch, with its own permissions; on GitLab joined to every rule) and `dispatchInputs` (the dispatch inputs' names, which the comment job's dispatch and the follow-on use), with `buildForgejoOpWavesDoc` for the Forgejo jobs, and whose product pipeline's `wavesBeforeMerge` takes `workflowFile` and `dispatchInputs`.
|
|
270
270
|
*/
|
|
271
|
-
export const OP_WAVES_NAMES_FLOOR =
|
|
271
|
+
export const OP_WAVES_NAMES_FLOOR = "0.124.92";
|
|
272
272
|
|
|
273
273
|
/**
|
|
274
274
|
* 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.
|
|
275
275
|
*/
|
|
276
|
-
export const PRODUCT_JOB_NAMES_FLOOR =
|
|
277
|
-
|
|
276
|
+
export const PRODUCT_JOB_NAMES_FLOOR = "0.124.92";
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* 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.
|
|
280
|
+
*/
|
|
281
|
+
export const OP_WAVES_DEFAULT_BRANCH_FLOOR = "0.124.93";
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* 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.
|
|
285
|
+
*/
|
|
286
|
+
export const OP_WAVES_FIRST_WAVE_NEEDS_FLOOR = "0.124.93";
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* 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.
|
|
290
|
+
*/
|
|
291
|
+
export const NOTIFY_RELAY_NAME_FLOOR = "0.124.93";
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* 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.
|
|
295
|
+
*/
|
|
296
|
+
export const OP_WAVES_RESUME_NAMES_FLOOR = "0.124.93";
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* 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.
|
|
300
|
+
*/
|
|
301
|
+
export const WAVES_BEFORE_MERGE_ENVIRONMENT_FLOOR = "0.124.93";
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* 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.
|
|
305
|
+
*/
|
|
306
|
+
export const NOTE_POLL_NAMES_FLOOR = "0.124.93";
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* 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.
|
|
310
|
+
*/
|
|
311
|
+
export const OP_WAVES_COMMAND_TOKEN_FLOOR = NEXT_RELEASE;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* 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.
|
|
315
|
+
*/
|
|
316
|
+
export const OP_WAVES_GITLAB_CACHE_FLOOR = NEXT_RELEASE;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* 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.
|
|
320
|
+
*/
|
|
321
|
+
export const OP_WAVES_GROUPS_FLOOR = NEXT_RELEASE;
|
|
322
|
+
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";
|
|
278
323
|
|
|
279
324
|
/**
|
|
280
325
|
* Day-2 actions in the product pipeline (#4654): the `action` comment
|
|
@@ -487,6 +532,10 @@ export type { ProductMcpContext, ProductMcpHook } from "./cli/mcp/product-tools"
|
|
|
487
532
|
* and `destructiveHint`, and a contribution's `annotations` add the rest.
|
|
488
533
|
*/
|
|
489
534
|
export { MCP_TOOL_ANNOTATIONS_FLOOR, PRODUCT_MCP_PROPOSE_FLOOR, PRODUCT_TOOL_PROPOSE_WORDS } from "./cli/mcp/product-tools";
|
|
535
|
+
/** #5047: the Op waves keep the stopped-apply record (`approvals.remainder`, `approvals.spendStanding`), in place of a product's own. */
|
|
536
|
+
export { OP_WAVES_REMAINDER_FLOOR } from "./release-floors";
|
|
537
|
+
export { OP_WAVES_SPLIT_RESUME_FLOOR } from "./release-floors";
|
|
538
|
+
export { OP_WAVES_REMAINDER_PARITY_FLOOR } from "./release-floors";
|
|
490
539
|
export type { McpToolContribution, ToolAnnotations } from "./mcp/types";
|
|
491
540
|
export {
|
|
492
541
|
activeOtlp,
|
|
@@ -131,9 +131,22 @@ async function runOpWaveJobCommand(ctx: CommandContext): Promise<number> {
|
|
|
131
131
|
if (args.renderSpec) {
|
|
132
132
|
const at = await import("../../op/op-waves-render-spec");
|
|
133
133
|
const file = relative(process.cwd(), path);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const
|
|
134
|
+
const command = at.opWavesSpecCommandFromEnv();
|
|
135
|
+
// #5046: with CHANT_WAVES_SPEC_RUNS=head the runs come from the applied commit; the gate and record jobs take them from the saved plan.
|
|
136
|
+
const runsAtHead = at.opWavesSpecRunsAtHead() && phase !== "gate" && phase !== "record";
|
|
137
|
+
const rendered = at.renderOpWavesJobSpec({
|
|
138
|
+
specFile: file,
|
|
139
|
+
base: args.base ?? "HEAD^1",
|
|
140
|
+
cwd: process.cwd(),
|
|
141
|
+
render: at.commandSpecRender(command, file, process.cwd()),
|
|
142
|
+
fallback: gitShowAtBase,
|
|
143
|
+
parse: parseOpWavesSpec,
|
|
144
|
+
...(runsAtHead ? { runsAtHead, headRender: (baseSha: string) => at.commandSpecRender(command, file, process.cwd(), { [at.OP_WAVES_SPEC_BASE_ENV]: baseSha }) } : {}),
|
|
145
|
+
});
|
|
146
|
+
show = rendered.show;
|
|
147
|
+
spec = rendered.spec;
|
|
148
|
+
if (runsAtHead) console.error(`${spec.name}: the runs come from the spec rendered at ${rendered.sha.slice(0, 12)}, the applied commit; the rules from the one rendered at base`);
|
|
149
|
+
const missing = at.renderedJobMissing(spec, args.wave, job, rendered.at);
|
|
137
150
|
if (missing) {
|
|
138
151
|
console.error(`${missing}, so this job has nothing to apply`);
|
|
139
152
|
return 0;
|
package/src/cli/main.ts
CHANGED
|
@@ -618,7 +618,10 @@ Ops:
|
|
|
618
618
|
--render-spec runs the command CHANT_WAVES_SPEC_COMMAND
|
|
619
619
|
names (a JSON argv) with CHANT_WAVES_SPEC_AT set to
|
|
620
620
|
the base, writes the spec it prints over --spec, and
|
|
621
|
-
reads the rules at base from it (#4982).
|
|
621
|
+
reads the rules at base from it (#4982). With
|
|
622
|
+
CHANT_WAVES_SPEC_RUNS=head the spec it writes is
|
|
623
|
+
printed at HEAD, with CHANT_WAVES_SPEC_BASE set to
|
|
624
|
+
the base, and the rules still come from base (#5046).
|
|
622
625
|
--phase plan|gate|apply|record: one of a wave's four
|
|
623
626
|
jobs before merge (#4987). plan saves the plan and
|
|
624
627
|
writes nothing to chant/lifecycle; gate decides the
|