@intentius/chant 0.124.84 → 0.124.86
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/bundle-check.d.ts +102 -0
- package/dist/bundle-check.d.ts.map +1 -0
- package/dist/bundle-check.js +310 -0
- package/dist/chant-install.d.ts +100 -0
- package/dist/chant-install.d.ts.map +1 -0
- package/dist/chant-install.js +158 -0
- package/dist/ci-commit.d.ts +19 -6
- package/dist/ci-commit.d.ts.map +1 -1
- package/dist/ci-commit.js +23 -4
- package/dist/ci-evidence-jobs.d.ts +54 -0
- package/dist/ci-evidence-jobs.d.ts.map +1 -0
- package/dist/ci-evidence-jobs.js +55 -0
- package/dist/ci-image.d.ts +274 -0
- package/dist/ci-image.d.ts.map +1 -0
- package/dist/ci-image.js +635 -0
- package/dist/ci-login.d.ts +150 -0
- package/dist/ci-login.d.ts.map +1 -0
- package/dist/ci-login.js +240 -0
- package/dist/ci-product.d.ts +16 -0
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +17 -0
- package/dist/cli/commands/import-index.js +2 -2
- package/dist/cli/handlers/build.d.ts +8 -0
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +22 -4
- package/dist/cli/handlers/ci-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-check.js +57 -2
- package/dist/cli/handlers/ci-evidence.d.ts +3 -0
- package/dist/cli/handlers/ci-evidence.d.ts.map +1 -0
- package/dist/cli/handlers/ci-evidence.js +171 -0
- package/dist/cli/handlers/components.js +3 -3
- package/dist/cli/handlers/dead-guards.d.ts +3 -0
- package/dist/cli/handlers/dead-guards.d.ts.map +1 -0
- package/dist/cli/handlers/dead-guards.js +35 -0
- package/dist/cli/handlers/graph.js +4 -4
- package/dist/cli/handlers/lifecycle.d.ts +2 -1
- package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
- package/dist/cli/handlers/lifecycle.js +5 -4
- package/dist/cli/handlers/local-chant.d.ts +16 -0
- package/dist/cli/handlers/local-chant.d.ts.map +1 -0
- package/dist/cli/handlers/local-chant.js +109 -0
- package/dist/cli/handlers/operator.js +2 -2
- package/dist/cli/handlers/search.js +5 -5
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +38 -0
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +28 -0
- package/dist/cli/registry.d.ts +16 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/check-hooks.d.ts +49 -0
- package/dist/components/check-hooks.d.ts.map +1 -1
- package/dist/components/check-hooks.js +64 -4
- package/dist/components/check-steps.d.ts +17 -0
- package/dist/components/check-steps.d.ts.map +1 -1
- package/dist/components/check-steps.js +37 -5
- package/dist/components/product-pipeline.d.ts +23 -0
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +6 -2
- package/dist/components/product-plan.d.ts +137 -0
- package/dist/components/product-plan.d.ts.map +1 -0
- package/dist/components/product-plan.js +143 -0
- package/dist/components/release-compile.d.ts.map +1 -1
- package/dist/components/release-compile.js +2 -2
- package/dist/config.d.ts +39 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +35 -3
- package/dist/dead-guards.d.ts +82 -0
- package/dist/dead-guards.d.ts.map +1 -0
- package/dist/dead-guards.js +436 -0
- package/dist/discovery/files.d.ts +3 -1
- package/dist/discovery/files.d.ts.map +1 -1
- package/dist/discovery/files.js +5 -3
- package/dist/drift-issue.d.ts +152 -0
- package/dist/drift-issue.d.ts.map +1 -0
- package/dist/drift-issue.js +167 -0
- package/dist/floor-table.d.ts +30 -0
- package/dist/floor-table.d.ts.map +1 -0
- package/dist/floor-table.data.d.ts +3 -0
- package/dist/floor-table.data.d.ts.map +1 -0
- package/dist/floor-table.data.js +178 -0
- package/dist/floor-table.js +56 -0
- package/dist/forge-flags.d.ts +90 -0
- package/dist/forge-flags.d.ts.map +1 -0
- package/dist/forge-flags.js +184 -0
- package/dist/lexicon.d.ts +69 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/gated-op.d.ts +7 -1
- package/dist/lifecycle/gated-op.d.ts.map +1 -1
- package/dist/lifecycle/gated-op.js +7 -4
- package/dist/local-chant.d.ts +98 -0
- package/dist/local-chant.d.ts.map +1 -0
- package/dist/local-chant.js +307 -0
- package/dist/op/activities/predict-behaviour.js +2 -2
- package/dist/op/op-waves-evidence-spec.d.ts +13 -0
- package/dist/op/op-waves-evidence-spec.d.ts.map +1 -0
- package/dist/op/op-waves-evidence-spec.js +21 -0
- package/dist/op/op-waves-evidence.d.ts +38 -0
- package/dist/op/op-waves-evidence.d.ts.map +1 -0
- package/dist/op/op-waves-evidence.js +57 -0
- package/dist/op/op-waves-run.d.ts +4 -0
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +24 -1
- package/dist/op/op-waves.d.ts +17 -1
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +23 -0
- package/dist/op/schedule-overdue.d.ts +41 -9
- package/dist/op/schedule-overdue.d.ts.map +1 -1
- package/dist/op/schedule-overdue.js +154 -25
- package/dist/plan-summary.d.ts +25 -0
- package/dist/plan-summary.d.ts.map +1 -1
- package/dist/plan-summary.js +31 -0
- package/dist/pr-plan-note.d.ts +35 -0
- package/dist/pr-plan-note.d.ts.map +1 -1
- package/dist/pr-plan-note.js +10 -0
- package/dist/pr-post.d.ts +23 -0
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +125 -3
- package/dist/release-floors.d.ts +31 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +31 -1
- package/dist/state-migration.d.ts +24 -0
- package/dist/state-migration.d.ts.map +1 -1
- package/dist/state-migration.js +100 -5
- package/dist/wave-runtime.mjs +305 -298
- package/dist/workspace/lexicon-outputs.d.ts.map +1 -1
- package/dist/workspace/lexicon-outputs.js +21 -7
- package/dist/workspace/reason-codes.d.ts +3 -0
- package/dist/workspace/reason-codes.d.ts.map +1 -1
- package/dist/workspace/reason-codes.js +4 -0
- package/dist/workspace/ref-gate.schema.json +85 -0
- package/dist/workspace/search-contract.d.ts +1 -1
- package/dist/workspace/search-contract.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence-report.d.ts +51 -0
- package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -0
- package/dist/workspace/trust/check-evidence-report.js +102 -0
- package/dist/workspace/trust/check-evidence.d.ts +126 -0
- package/dist/workspace/trust/check-evidence.d.ts.map +1 -0
- package/dist/workspace/trust/check-evidence.js +237 -0
- package/dist/workspace/trust/local-evidence.d.ts +120 -0
- package/dist/workspace/trust/local-evidence.d.ts.map +1 -0
- package/dist/workspace/trust/local-evidence.js +259 -0
- package/dist/workspace/trust/policy.d.ts +84 -0
- package/dist/workspace/trust/policy.d.ts.map +1 -1
- package/dist/workspace/trust/policy.js +94 -1
- package/dist/workspace/trust/ref-gate-cli.d.ts +33 -0
- package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate-cli.js +234 -0
- package/dist/workspace/trust/ref-gate-fixture.d.ts +38 -0
- package/dist/workspace/trust/ref-gate-fixture.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate-fixture.js +97 -0
- package/dist/workspace/trust/ref-gate.d.ts +187 -0
- package/dist/workspace/trust/ref-gate.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate.js +430 -0
- package/dist/workspace/trust/trust-files.d.ts.map +1 -1
- package/dist/workspace/trust/trust-files.js +18 -1
- package/package.json +1 -1
- package/src/bundle-check.test.ts +140 -0
- package/src/bundle-check.ts +352 -0
- package/src/chant-install.test.ts +112 -0
- package/src/chant-install.ts +179 -0
- package/src/ci-commit.test.ts +45 -0
- package/src/ci-commit.ts +38 -4
- package/src/ci-evidence-jobs.ts +67 -0
- package/src/ci-image.test.ts +506 -0
- package/src/ci-image.ts +822 -0
- package/src/ci-login.test.ts +235 -0
- package/src/ci-login.ts +307 -0
- package/src/ci-product.ts +18 -0
- package/src/cli/commands/__fixtures__/source-dir-include/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-include/infra.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-include/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-root/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/infra.test.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/infra.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/app.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/infra/net.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/import-index.ts +2 -2
- package/src/cli/handlers/build-source-dir.test.ts +64 -0
- package/src/cli/handlers/build.ts +21 -4
- package/src/cli/handlers/ci-check.ts +56 -3
- package/src/cli/handlers/ci-evidence.ts +162 -0
- package/src/cli/handlers/components.ts +3 -3
- package/src/cli/handlers/dead-guards.ts +37 -0
- package/src/cli/handlers/graph.ts +4 -4
- package/src/cli/handlers/lifecycle.ts +5 -4
- package/src/cli/handlers/local-chant.ts +106 -0
- package/src/cli/handlers/operator.ts +2 -2
- package/src/cli/handlers/search.ts +5 -5
- package/src/cli/main.test.ts +7 -0
- package/src/cli/main.ts +38 -0
- package/src/cli/parse-args.ts +21 -0
- package/src/cli/registry.ts +16 -0
- package/src/components/check-evidence-stage.test.ts +80 -0
- package/src/components/check-hooks.ts +84 -4
- package/src/components/check-local-evidence-stage.test.ts +141 -0
- package/src/components/check-steps.ts +56 -6
- package/src/components/product-pipeline.ts +28 -3
- package/src/components/product-plan.test.ts +87 -0
- package/src/components/product-plan.ts +226 -0
- package/src/components/release-compile.ts +2 -2
- package/src/config.ts +44 -3
- package/src/dead-guards.test.ts +206 -0
- package/src/dead-guards.ts +446 -0
- package/src/discovery/files.ts +5 -3
- package/src/drift-issue-bundle.test.ts +31 -0
- package/src/drift-issue.test.ts +206 -0
- package/src/drift-issue.ts +274 -0
- package/src/fit-note.test.ts +44 -0
- package/src/floor-table.data.ts +180 -0
- package/src/floor-table.ts +77 -0
- package/src/forge-flags.test.ts +110 -0
- package/src/forge-flags.ts +208 -0
- package/src/gate-decision-bundle.test.ts +1 -0
- package/src/lexicon.ts +68 -0
- package/src/lifecycle/gated-op.ts +10 -5
- package/src/local-chant.e2e.test.ts +94 -0
- package/src/local-chant.test.ts +162 -0
- package/src/local-chant.ts +341 -0
- package/src/op/activities/predict-behaviour.ts +2 -2
- package/src/op/op-waves-evidence-spec.ts +24 -0
- package/src/op/op-waves-evidence.test.ts +130 -0
- package/src/op/op-waves-evidence.ts +57 -0
- package/src/op/op-waves-run.ts +25 -1
- package/src/op/op-waves.ts +31 -1
- package/src/op/schedule-overdue.test.ts +85 -0
- package/src/op/schedule-overdue.ts +162 -26
- package/src/plan-summary.ts +40 -0
- package/src/pr-plan-note.ts +34 -0
- package/src/pr-post-plan-note.test.ts +146 -0
- package/src/pr-post.ts +127 -3
- package/src/release-floors.ts +44 -1
- package/src/stage-hooks-bundle.test.ts +1 -0
- package/src/state-migration.test.ts +52 -1
- package/src/state-migration.ts +107 -5
- package/src/workspace/lexicon-outputs.ts +23 -6
- package/src/workspace/reason-codes.test.ts +3 -0
- package/src/workspace/reason-codes.ts +4 -0
- package/src/workspace/ref-gate.schema.json +85 -0
- package/src/workspace/trust/check-evidence-report.ts +106 -0
- package/src/workspace/trust/check-evidence.test.ts +133 -0
- package/src/workspace/trust/check-evidence.ts +257 -0
- package/src/workspace/trust/local-evidence.test.ts +127 -0
- package/src/workspace/trust/local-evidence.ts +266 -0
- package/src/workspace/trust/policy.ts +134 -1
- package/src/workspace/trust/ref-gate-cli.ts +244 -0
- package/src/workspace/trust/ref-gate-fixture.ts +125 -0
- package/src/workspace/trust/ref-gate.e2e.test.ts +76 -0
- package/src/workspace/trust/ref-gate.test.ts +247 -0
- package/src/workspace/trust/ref-gate.ts +538 -0
- package/src/workspace/trust/trust-files.test.ts +16 -0
- package/src/workspace/trust/trust-files.ts +41 -1
package/src/ci-commit.test.ts
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
COMMIT_PR_ENV,
|
|
25
25
|
CI_COMMIT_ARG_FLOOR,
|
|
26
26
|
CI_COMMIT_HARNESS_BREAK_FLOOR,
|
|
27
|
+
CI_COMMIT_REFUSAL_REPLY_FLOOR,
|
|
27
28
|
COMMIT_HARNESS_BREAK_ENV,
|
|
28
29
|
COMMIT_HARNESS_FORGE,
|
|
29
30
|
commitHarnessBreaks,
|
|
@@ -36,6 +37,7 @@ import {
|
|
|
36
37
|
} from "./ci-commit";
|
|
37
38
|
import { assertProductWords, parseProductComment } from "./ci-product-words";
|
|
38
39
|
import { PLYWOOD } from "./__fixtures__/product-words";
|
|
40
|
+
import { NEXT_RELEASE } from "./release-floors";
|
|
39
41
|
import type { OpRunRecord, OpRunRecordInput } from "./op/runtime";
|
|
40
42
|
import type { PullRequestHead } from "./pr-forge";
|
|
41
43
|
|
|
@@ -577,6 +579,49 @@ describe("the comment's argument (#4820)", () => {
|
|
|
577
579
|
});
|
|
578
580
|
});
|
|
579
581
|
|
|
582
|
+
describe("a comment refused as it is read gets a reply (#4838)", () => {
|
|
583
|
+
const named = () => settings({ commentArg: { pattern: "^[a-z0-9]+(?:[-_][a-z0-9]+)*$", position: 1 } });
|
|
584
|
+
|
|
585
|
+
test("a bad argument and a stray word are answered on the pull request, naming the comment and why, on GitHub and Forgejo", async () => {
|
|
586
|
+
// Forgejo's event has GitHub's shape, so the one path answers both.
|
|
587
|
+
for (const [s, body, why] of [
|
|
588
|
+
[named(), "/plywood fmt Bad", "`/plywood fmt` takes nothing, or one name after it matching `^[a-z0-9]+(?:[-_][a-z0-9]+)*$`"],
|
|
589
|
+
[settings(), "/plywood fmt now", "`/plywood fmt` takes nothing after it"],
|
|
590
|
+
] as const) {
|
|
591
|
+
const w = world();
|
|
592
|
+
const { out } = await cycle(w, s, { event: comment(body) });
|
|
593
|
+
expect(out).toMatchObject({ result: "refused", reason: why, requestedBy: "ana" });
|
|
594
|
+
expect(w.replies).toEqual([`plywood: \`${body}\` was refused: ${why}. plywood-fmt did not run, and nothing was pushed.`]);
|
|
595
|
+
expect(w.records[0]!.outcomes.commit).toMatchObject({ result: "refused", pr: 7, requestedBy: "ana" });
|
|
596
|
+
expect(sh(["rev-parse", "refs/heads/feature"], w.r.origin).trim()).toBe(w.r.head);
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
test("GitLab answers a bad argument from its pipeline variables", async () => {
|
|
601
|
+
const w = world();
|
|
602
|
+
const env = { GITLAB_CI: "true", CHANT_COMMIT_PR: "7", CHANT_COMMIT: "fmt", [GITLAB_COMMIT_ARG_VAR]: "Bad", GITLAB_USER_LOGIN: "ana" };
|
|
603
|
+
const { out } = await cycle(w, named(), { event: {}, env });
|
|
604
|
+
expect(out.result).toBe("refused");
|
|
605
|
+
expect(w.replies).toEqual([expect.stringMatching(/^plywood: `\/plywood fmt Bad` was refused: `\/plywood fmt` takes nothing, or one name after it/)]);
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
test("a comment for another word gets no reply from this job, and a long or many-line comment is quoted by its first line, cut short", async () => {
|
|
609
|
+
const other = world();
|
|
610
|
+
await cycle(other, settings(), { event: comment("/plywood up") });
|
|
611
|
+
expect(other.replies).toEqual([]);
|
|
612
|
+
const many = world();
|
|
613
|
+
await cycle(many, settings(), { event: comment("/plywood fmt\nand more") });
|
|
614
|
+
expect(many.replies).toEqual(["plywood: `/plywood fmt` was refused: a command is one line, and nothing else in the comment. plywood-fmt did not run, and nothing was pushed."]);
|
|
615
|
+
const long = world();
|
|
616
|
+
await cycle(long, settings(), { event: comment(`/plywood fmt ${"x".repeat(200)}`) });
|
|
617
|
+
expect(long.replies[0]).toMatch(new RegExp(`^plywood: \`/plywood fmt x{84}\\.\\.\\.\` was refused`));
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
test("the floor is the next release until it ships", () => {
|
|
621
|
+
expect(CI_COMMIT_REFUSAL_REPLY_FLOOR).toBe(NEXT_RELEASE);
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
|
|
580
625
|
describe("the harness's BREAK switch for land (#4836)", () => {
|
|
581
626
|
const harness = (checks: string) => ({ [COMMIT_HARNESS_BREAK_ENV]: checks, BREAK: "1", GITHUB_SERVER_URL: COMMIT_HARNESS_FORGE });
|
|
582
627
|
|
package/src/ci-commit.ts
CHANGED
|
@@ -29,6 +29,7 @@ import { spawn } from "node:child_process";
|
|
|
29
29
|
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
30
30
|
import { join } from "node:path";
|
|
31
31
|
import { CHANT_EXIT } from "./exit-codes";
|
|
32
|
+
import { NEXT_RELEASE } from "./release-floors";
|
|
32
33
|
import { FORGE_TOKEN_VARS } from "./ci-handover";
|
|
33
34
|
import { agentForbiddenPaths, AgentError, branchOk, errText, LOGIN, readSmall, SHA, type AgentGit } from "./ci-agent";
|
|
34
35
|
import { COMMIT_COMMENT_ARG, parseProductComment, type CiProductWords } from "./ci-product-words";
|
|
@@ -53,6 +54,8 @@ export const CI_COMMIT_REPLY_FLOOR = "0.124.77";
|
|
|
53
54
|
export const CI_COMMIT_ARG_FLOOR = "0.124.78";
|
|
54
55
|
/** The first chant whose `commit land` reads {@link COMMIT_HARNESS_BREAK_ENV} in a BREAK arm of chant's e2e harness (#4836). */
|
|
55
56
|
export const CI_COMMIT_HARNESS_BREAK_FLOOR = "0.124.78";
|
|
57
|
+
/** The first chant whose `commit land` replies to a comment refused as it is read, such as a bad argument or a stray word (#4838). */
|
|
58
|
+
export const CI_COMMIT_REFUSAL_REPLY_FLOOR = NEXT_RELEASE;
|
|
56
59
|
|
|
57
60
|
/** What starts a commit run: a person's comment, or a check job's finding. */
|
|
58
61
|
export type CommitTrigger = "comment" | "check";
|
|
@@ -442,6 +445,27 @@ export interface CommitRequest {
|
|
|
442
445
|
arg?: string;
|
|
443
446
|
}
|
|
444
447
|
|
|
448
|
+
/**
|
|
449
|
+
* A request refused (#4838). `replyOn` is set when the comment named this
|
|
450
|
+
* job's command and was refused as it was read (a bad argument, a stray
|
|
451
|
+
* word): the pull request, who asked, and the comment's first line, so land
|
|
452
|
+
* can say why on the pull request. A comment for another word has none,
|
|
453
|
+
* since that word's own job answers it.
|
|
454
|
+
*/
|
|
455
|
+
export interface CommitRequestRefusal {
|
|
456
|
+
refused: string;
|
|
457
|
+
replyOn?: { pr: number; user: string; asked: string };
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/** The most of a comment a refusal reply quotes (#4838). */
|
|
461
|
+
const ASKED_MAX = 100;
|
|
462
|
+
|
|
463
|
+
/** The comment's first line as a reply quotes it, cut at {@link ASKED_MAX}. */
|
|
464
|
+
function askedLine(body: string): string {
|
|
465
|
+
const line = body.trim().split(/\r?\n/)[0]!.trim();
|
|
466
|
+
return line.length > ASKED_MAX ? `${line.slice(0, ASKED_MAX - 3)}...` : line;
|
|
467
|
+
}
|
|
468
|
+
|
|
445
469
|
/**
|
|
446
470
|
* The request from the run. `comment`: the event's comment on GitHub and
|
|
447
471
|
* Forgejo, read against the product's grammar, which must name this job's
|
|
@@ -450,7 +474,7 @@ export interface CommitRequest {
|
|
|
450
474
|
* pull request the check ran for, from the `pull_request` event or the
|
|
451
475
|
* merge request pipeline.
|
|
452
476
|
*/
|
|
453
|
-
export function commitRequestFromRun(words: CiProductWords, s: Pick<CommitSettings, "on" | "comment"> & Partial<Pick<CommitSettings, "commentArg">>, env: Record<string, string | undefined>, event: unknown): CommitRequest |
|
|
477
|
+
export function commitRequestFromRun(words: CiProductWords, s: Pick<CommitSettings, "on" | "comment"> & Partial<Pick<CommitSettings, "commentArg">>, env: Record<string, string | undefined>, event: unknown): CommitRequest | CommitRequestRefusal {
|
|
454
478
|
const gitlab = env.GITLAB_CI === "true";
|
|
455
479
|
let pr: unknown;
|
|
456
480
|
if (s.on === "check") {
|
|
@@ -475,7 +499,12 @@ export function commitRequestFromRun(words: CiProductWords, s: Pick<CommitSettin
|
|
|
475
499
|
if (typeof pr !== "number" || !Number.isInteger(pr) || pr < 1) return { refused: "the run names no pull request" };
|
|
476
500
|
if (typeof user !== "string" || !LOGIN.test(user)) return { refused: "the run names nobody who asked" };
|
|
477
501
|
const parsed = parseProductComment(words, body, env, commentArgPatterns(s));
|
|
478
|
-
if (parsed?.kind === "refused")
|
|
502
|
+
if (parsed?.kind === "refused") {
|
|
503
|
+
// #4838: answered only when the comment's command is this job's, so two jobs never both reply.
|
|
504
|
+
const said = typeof body === "string" ? body.trim().split(/[ \t\r\n]+/) : [];
|
|
505
|
+
const ours = said[0] === `/${words.product}` && said[1] === word;
|
|
506
|
+
return { refused: parsed.reason, ...(ours ? { replyOn: { pr, user, asked: askedLine(body as string) } } : {}) };
|
|
507
|
+
}
|
|
479
508
|
if (parsed?.kind !== "commit" || parsed.word !== word) return { refused: `the comment is not ${s.comment}` };
|
|
480
509
|
return { pr, user, ...(parsed.arg !== undefined ? { arg: parsed.arg } : {}) };
|
|
481
510
|
}
|
|
@@ -518,7 +547,7 @@ export async function resolveCommitRequest(
|
|
|
518
547
|
env: Record<string, string | undefined>,
|
|
519
548
|
event: unknown,
|
|
520
549
|
forge?: Partial<Pick<PrForge, "findPullRequest">>,
|
|
521
|
-
): Promise<CommitRequest |
|
|
550
|
+
): Promise<CommitRequest | CommitRequestRefusal> {
|
|
522
551
|
const req = commitRequestFromRun(words, s, env, event);
|
|
523
552
|
if (!("refused" in req) || s.on !== "check" || env.GITLAB_CI === "true" || !forge?.findPullRequest) return req;
|
|
524
553
|
const branch = pushedBranch(env);
|
|
@@ -1014,7 +1043,12 @@ export async function landCommitChange(i: CommitLandInput): Promise<CommitLandOu
|
|
|
1014
1043
|
|
|
1015
1044
|
// Who asked and for which pull request: from the event, never from the commit job's files.
|
|
1016
1045
|
const req = await resolveCommitRequest(i.words, s, i.env, i.event, i.forge);
|
|
1017
|
-
if ("refused" in req)
|
|
1046
|
+
if ("refused" in req) {
|
|
1047
|
+
// #4838: a comment refused as it was read is answered, naming it and why.
|
|
1048
|
+
if (!req.replyOn) return finish({ result: s.on === "check" ? "skipped" : "refused", reason: req.refused });
|
|
1049
|
+
({ pr, user } = req.replyOn);
|
|
1050
|
+
return finish({ result: "refused", reason: req.refused }, `${code(req.replyOn.asked)} was refused: ${req.refused}. ${s.name} did not run, and nothing was pushed.`);
|
|
1051
|
+
}
|
|
1018
1052
|
({ pr, user } = req);
|
|
1019
1053
|
// #4836: a BREAK arm of the harness may turn a check off; anywhere else the switch fails the land.
|
|
1020
1054
|
const harness = commitHarnessBreaks(i.env);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a generated pipeline adds to sign evidence for the named checks it
|
|
3
|
+
* runs (#4870), for the forge lexicons to render. No import beyond the
|
|
4
|
+
* words' bin swap, so the generators' bundles stay small.
|
|
5
|
+
*
|
|
6
|
+
* A project switches it on by naming the secret (GitHub, Forgejo) or CI/CD
|
|
7
|
+
* variable (GitLab) that holds its runner key, the PEM key whose public half
|
|
8
|
+
* `.chant/trust.json` lists under `runners`: the same secret the green
|
|
9
|
+
* workflow takes as `--runner-key-secret`. Without it nothing is added and
|
|
10
|
+
* every generated file is as before.
|
|
11
|
+
*
|
|
12
|
+
* - The plan note job (the product plan pipeline, GitHub and Forgejo) signs
|
|
13
|
+
* `plan` and `policy` from the plan job's report, after taking it back and
|
|
14
|
+
* before posting the note, which then says which checks were signed. The
|
|
15
|
+
* key is in that one step, in a job that runs none of the change's code.
|
|
16
|
+
* GitLab posts its notes from a target-branch pipeline that reads every
|
|
17
|
+
* open merge request, so there a job of its own after each plan job
|
|
18
|
+
* (`<plan job>-evidence`) signs from the plan job's artifact.
|
|
19
|
+
* - A wave job (the waves pipeline) gets the key on its `chant run wave`
|
|
20
|
+
* step, and signs `plan:<wave>` and `policy:<wave>` once the wave is
|
|
21
|
+
* planned (../op/op-waves-evidence.ts).
|
|
22
|
+
* - A product's check job runs `chant ci check` with the key in
|
|
23
|
+
* `CHANT_RUNNER_KEY`; the check runner signs each hook (./components/check-steps.ts).
|
|
24
|
+
*
|
|
25
|
+
* The key is a stored secret today. #4869 swaps it for the job's OIDC
|
|
26
|
+
* identity: the steps stay where they are and request a token instead.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import type { ForgeKind } from "./pr-forge";
|
|
30
|
+
|
|
31
|
+
/** The variable the signing steps read the key from. */
|
|
32
|
+
export const EVIDENCE_KEY_ENV = "CHANT_RUNNER_KEY";
|
|
33
|
+
|
|
34
|
+
export { CHECK_EVIDENCE_FLOOR, LOCAL_EVIDENCE_FLOOR } from "./release-floors";
|
|
35
|
+
|
|
36
|
+
/** A pipeline's runner identity (#4870). */
|
|
37
|
+
export interface PipelineEvidence {
|
|
38
|
+
/** The secret (GitHub, Forgejo) or CI/CD variable (GitLab) holding the runner key as PEM. */
|
|
39
|
+
runnerKeySecret: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const SECRET_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
43
|
+
|
|
44
|
+
/** Refuse a secret name the forge could not hold. */
|
|
45
|
+
export function assertPipelineEvidence(evidence: PipelineEvidence | undefined): void {
|
|
46
|
+
if (evidence === undefined) return;
|
|
47
|
+
if (!SECRET_NAME.test(evidence.runnerKeySecret ?? "")) throw new Error(`evidence.runnerKeySecret ${JSON.stringify(evidence.runnerKeySecret)} is not a secret name: letters, digits and _, not starting with a digit`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The signing step's key variable, from the forge's secret. */
|
|
51
|
+
export function evidenceKeyEnv(forge: ForgeKind, evidence: PipelineEvidence): Record<string, string> {
|
|
52
|
+
return { [EVIDENCE_KEY_ENV]: forge === "gitlab" ? `$${evidence.runnerKeySecret}` : `\${{ secrets.${evidence.runnerKeySecret} }}` };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The plan job's evidence step (#4870): fetch the planned commit (the note
|
|
57
|
+
* job checks out the target branch's), then sign `plan` and `policy` from
|
|
58
|
+
* the report directory. `result` is the plan job's result as the shell
|
|
59
|
+
* reads it.
|
|
60
|
+
*/
|
|
61
|
+
export function planEvidenceLines(opts: { dir: string; at: string; base: string; result: string; bin?: string }): string[] {
|
|
62
|
+
const chant = opts.bin ?? "chant";
|
|
63
|
+
return [
|
|
64
|
+
`git fetch --quiet --no-tags --depth=1 origin ${opts.at} || true`,
|
|
65
|
+
`${chant} ci evidence sign --from-report ${opts.dir} --result ${opts.result} --at ${opts.at} --base ${opts.base}`,
|
|
66
|
+
];
|
|
67
|
+
}
|