@intentius/chant 0.124.109 → 0.124.110
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__/wave-loop/fan-out-applied.json +12 -6
- package/dist/__golden__/wave-loop/fan-out-apply-fails.json +8 -4
- package/dist/__golden__/wave-loop/fan-out-gated.json +4 -2
- package/dist/__golden__/wave-loop/fan-out-no-members.json +16 -8
- package/dist/__golden__/wave-loop/fan-out-plan-fails.json +8 -4
- package/dist/__golden__/wave-loop/fan-out-same-root.json +4 -2
- package/dist/agent-facts.d.ts +130 -0
- package/dist/agent-facts.js +196 -0
- package/dist/change-risk.d.ts +216 -0
- package/dist/change-risk.js +304 -0
- package/dist/change-set.d.ts +8 -0
- package/dist/ci-agent-alert.d.ts +139 -0
- package/dist/ci-agent-alert.js +342 -0
- package/dist/ci-agent-triggers.d.ts +152 -0
- package/dist/ci-agent-triggers.js +232 -0
- package/dist/ci-agent-verify-failed.d.ts +149 -0
- package/dist/ci-agent-verify-failed.js +191 -0
- package/dist/ci-agent.d.ts +136 -8
- package/dist/ci-agent.js +353 -26
- package/dist/ci-comment-commands.d.ts +8 -0
- package/dist/ci-comment-commands.js +17 -1
- package/dist/ci-comment-reject.d.ts +70 -0
- package/dist/ci-comment-reject.js +135 -0
- package/dist/ci-comment-replies.d.ts +3 -1
- package/dist/ci-comment-replies.js +6 -0
- package/dist/ci-estate/delivery.d.ts +25 -3
- package/dist/ci-estate/delivery.js +28 -9
- package/dist/ci-estate/page.d.ts +7 -3
- package/dist/ci-estate/page.js +19 -4
- package/dist/ci-estate/rows.d.ts +14 -2
- package/dist/ci-estate/rows.js +9 -1
- package/dist/ci-estate.d.ts +5 -2
- package/dist/ci-estate.js +3 -2
- package/dist/ci-handover.d.ts +2 -7
- package/dist/ci-handover.js +3 -20
- package/dist/ci-jobs.d.ts +6 -0
- package/dist/ci-jobs.js +17 -0
- package/dist/ci-note-commands.d.ts +2 -0
- package/dist/ci-note-commands.js +12 -1
- package/dist/ci-product-words.d.ts +151 -1
- package/dist/ci-product-words.js +1390 -3
- package/dist/ci-product.d.ts +100 -4
- package/dist/ci-product.js +99 -3
- package/dist/ci-respond-run.d.ts +9 -0
- package/dist/ci-respond-run.js +35 -4
- package/dist/ci-respond-summary-env.d.ts +56 -0
- package/dist/ci-respond-summary-env.js +81 -0
- package/dist/ci-respond-summary.d.ts +103 -0
- package/dist/ci-respond-summary.js +243 -0
- package/dist/ci-respond.d.ts +4 -2
- package/dist/ci-respond.js +4 -2
- package/dist/cli/command-group.js +1 -1
- package/dist/cli/commands/lint.js +21 -3
- package/dist/cli/handlers/agent.js +49 -4
- package/dist/cli/handlers/approve.js +3 -1
- package/dist/cli/handlers/build.d.ts +97 -1
- package/dist/cli/handlers/build.js +251 -3
- package/dist/cli/handlers/fan-out.js +55 -0
- package/dist/cli/handlers/graph.d.ts +14 -0
- package/dist/cli/handlers/graph.js +58 -3
- package/dist/cli/handlers/lifecycle-health.d.ts +7 -0
- package/dist/cli/handlers/lifecycle-health.js +47 -9
- package/dist/cli/handlers/lifecycle.js +4 -1
- package/dist/cli/handlers/notify-relay.d.ts +2 -2
- package/dist/cli/handlers/notify-relay.js +67 -7
- package/dist/cli/handlers/pipeline-agent.d.ts +30 -0
- package/dist/cli/handlers/pipeline-agent.js +255 -0
- package/dist/cli/handlers/pipeline-artifacts.d.ts +39 -0
- package/dist/cli/handlers/pipeline-artifacts.js +203 -0
- package/dist/cli/handlers/pipeline.d.ts +16 -0
- package/dist/cli/handlers/pipeline.js +112 -0
- package/dist/cli/handlers/pr-comment.js +4 -0
- package/dist/cli/handlers/pr-notes.js +4 -1
- package/dist/cli/handlers/pr.d.ts +20 -0
- package/dist/cli/handlers/pr.js +114 -11
- package/dist/cli/handlers/promote.js +792 -47
- package/dist/cli/handlers/reject.d.ts +84 -0
- package/dist/cli/handlers/reject.js +216 -0
- package/dist/cli/handlers/replan.d.ts +54 -0
- package/dist/cli/handlers/replan.js +177 -0
- package/dist/cli/handlers/run-generate.d.ts +5 -0
- package/dist/cli/handlers/run-generate.js +31 -4
- package/dist/cli/handlers/run-wave.js +15 -2
- package/dist/cli/handlers/run.js +4 -2
- package/dist/cli/handlers/stage.d.ts +35 -0
- package/dist/cli/handlers/stage.js +90 -0
- package/dist/cli/lsp/server.js +4 -0
- package/dist/cli/main.js +88 -8
- package/dist/cli/parse-args.js +35 -2
- package/dist/cli/registry.d.ts +12 -0
- package/dist/components/auto-release.d.ts +2 -0
- package/dist/components/auto-release.js +1 -0
- package/dist/components/capability.d.ts +40 -0
- package/dist/components/cli-support.d.ts +21 -1
- package/dist/components/cli-support.js +28 -6
- package/dist/components/component.d.ts +23 -4
- package/dist/components/component.schema.json +28 -0
- package/dist/components/declared-reads.d.ts +44 -4
- package/dist/components/declared-reads.js +80 -3
- package/dist/components/discover.d.ts +8 -0
- package/dist/components/discover.js +1 -1
- package/dist/components/driver.d.ts +13 -0
- package/dist/components/driver.js +23 -2
- package/dist/components/environment-sets.d.ts +229 -0
- package/dist/components/environment-sets.js +338 -0
- package/dist/components/fan-out-canary.d.ts +47 -0
- package/dist/components/fan-out-canary.js +58 -0
- package/dist/components/fan-out-run.d.ts +17 -0
- package/dist/components/fan-out-run.js +14 -1
- package/dist/components/fan-out-support.d.ts +7 -0
- package/dist/components/fan-out-support.js +1 -1
- package/dist/components/groups.d.ts +8 -1
- package/dist/components/groups.js +19 -1
- package/dist/components/index.d.ts +5 -2
- package/dist/components/index.js +4 -1
- package/dist/components/pr-cost.d.ts +28 -0
- package/dist/components/pr-cost.js +53 -0
- package/dist/components/pr-pipeline.d.ts +33 -0
- package/dist/components/pr-pipeline.js +32 -5
- package/dist/components/pr-policy.d.ts +33 -2
- package/dist/components/pr-policy.js +5 -2
- package/dist/components/pr-risk.d.ts +42 -0
- package/dist/components/pr-risk.js +74 -0
- package/dist/components/product-pipeline.d.ts +43 -0
- package/dist/components/product-pipeline.js +67 -1
- package/dist/components/promote.d.ts +6 -0
- package/dist/components/promote.js +13 -0
- package/dist/components/release-compile.js +3 -1
- package/dist/components/release-gate.d.ts +6 -1
- package/dist/components/release-gate.js +10 -2
- package/dist/components/step-environments.d.ts +236 -0
- package/dist/components/step-environments.js +392 -0
- package/dist/components/upstream-replan.d.ts +201 -0
- package/dist/components/upstream-replan.js +249 -0
- package/dist/components/verify-step.d.ts +30 -0
- package/dist/components/verify-step.js +27 -0
- package/dist/components/wave-plan.js +6 -2
- package/dist/config-environments.d.ts +4 -2
- package/dist/control/dispatch.d.ts +15 -0
- package/dist/control/dispatch.js +28 -4
- package/dist/cost-estimate.d.ts +188 -0
- package/dist/cost-estimate.js +363 -0
- package/dist/drift-record.d.ts +36 -0
- package/dist/drift-record.js +44 -0
- package/dist/engine-facts.d.ts +105 -0
- package/dist/engine-facts.js +111 -0
- package/dist/exit-codes.d.ts +4 -3
- package/dist/exit-codes.js +4 -3
- package/dist/flag-params.d.ts +2 -2
- package/dist/flag-params.js +9 -4
- package/dist/floor-table.data.js +53 -0
- package/dist/forge-token-vars.d.ts +12 -0
- package/dist/forge-token-vars.js +25 -0
- package/dist/gate-decision.d.ts +3 -1
- package/dist/gate-decision.js +3 -1
- package/dist/gated-waves.d.ts +2 -0
- package/dist/gated-waves.js +1 -0
- package/dist/graph-ir.d.ts +30 -0
- package/dist/graph-ir.js +33 -1
- package/dist/graph-refs.d.ts +26 -0
- package/dist/graph-refs.js +34 -3
- package/dist/graph-schema/graph.schema.json +136 -0
- package/dist/health.d.ts +65 -0
- package/dist/health.js +62 -0
- package/dist/lexicon.d.ts +188 -1
- package/dist/lifecycle/disruption.d.ts +14 -1
- package/dist/lifecycle/disruption.js +5 -1
- package/dist/lifecycle/gate-change-set.d.ts +8 -0
- package/dist/lifecycle/gate-change-set.js +2 -1
- package/dist/lifecycle/gate-ledger.d.ts +26 -0
- package/dist/lifecycle/gate-rejection.d.ts +82 -0
- package/dist/lifecycle/gate-rejection.js +93 -0
- package/dist/lifecycle/gate-seal.d.ts +3 -3
- package/dist/lifecycle/gate-seal.js +5 -5
- package/dist/lifecycle/observe.d.ts +17 -0
- package/dist/lifecycle/observe.js +10 -1
- package/dist/lifecycle/release-cut.js +4 -0
- package/dist/lifecycle/release-ledger.d.ts +8 -0
- package/dist/lifecycle/release-risk.d.ts +137 -0
- package/dist/lifecycle/release-risk.js +214 -0
- package/dist/lifecycle/release-store.d.ts +9 -0
- package/dist/lifecycle/release-store.js +4 -0
- package/dist/lifecycle/stage-log.d.ts +85 -0
- package/dist/lifecycle/stage-log.js +141 -0
- package/dist/lint/canary-checks.d.ts +31 -0
- package/dist/lint/canary-checks.js +45 -0
- package/dist/lint/rule.d.ts +1 -0
- package/dist/lint/rules/evl012-pipeline-fold.d.ts +14 -0
- package/dist/lint/rules/evl012-pipeline-fold.js +30 -0
- package/dist/lint/rules/index.d.ts +1 -0
- package/dist/lint/rules/index.js +3 -0
- package/dist/notify-relay-repo.d.ts +54 -0
- package/dist/notify-relay-repo.js +84 -0
- package/dist/notify-relay.d.ts +53 -3
- package/dist/notify-relay.js +96 -3
- package/dist/notify.d.ts +57 -1
- package/dist/notify.js +7 -1
- package/dist/notify.schema.json +61 -3
- package/dist/observation.d.ts +34 -0
- package/dist/observation.js +14 -1
- package/dist/op/activities/review-agent.d.ts +39 -2
- package/dist/op/activities/review-agent.js +88 -5
- package/dist/op/agent-permit.d.ts +88 -0
- package/dist/op/agent-permit.js +97 -0
- package/dist/op/gate-approval-base.d.ts +8 -0
- package/dist/op/gate-approval-base.js +9 -0
- package/dist/op/gate-approval.d.ts +30 -1
- package/dist/op/gate-approval.js +23 -2
- package/dist/op/gate-quorum.d.ts +114 -8
- package/dist/op/gate-quorum.js +198 -21
- package/dist/op/gate-reject.d.ts +79 -0
- package/dist/op/gate-reject.js +96 -0
- package/dist/op/gate-summary.js +1 -1
- package/dist/op/gate.d.ts +28 -3
- package/dist/op/gate.js +55 -13
- package/dist/op/generate-pipeline.d.ts +15 -1
- package/dist/op/generate-pipeline.js +32 -5
- package/dist/op/index.d.ts +11 -6
- package/dist/op/index.js +10 -5
- package/dist/op/local-executor.d.ts +2 -0
- package/dist/op/local-executor.js +23 -4
- package/dist/op/op-waves-after-plan.d.ts +23 -0
- package/dist/op/op-waves-after-plan.js +12 -1
- package/dist/op/op-waves-capability-spec.d.ts +14 -0
- package/dist/op/op-waves-capability-spec.js +46 -6
- package/dist/op/op-waves-capability.d.ts +21 -13
- package/dist/op/op-waves-capability.js +22 -59
- package/dist/op/op-waves-environment-sets.d.ts +41 -0
- package/dist/op/op-waves-environment-sets.js +82 -0
- package/dist/op/op-waves-quorum-warnings.d.ts +53 -0
- package/dist/op/op-waves-quorum-warnings.js +90 -0
- package/dist/op/op-waves-release-port.d.ts +7 -0
- package/dist/op/op-waves-release-port.js +15 -3
- package/dist/op/op-waves-release.d.ts +15 -0
- package/dist/op/op-waves-release.js +15 -0
- package/dist/op/op-waves-run.d.ts +37 -3
- package/dist/op/op-waves-run.js +141 -18
- package/dist/op/op-waves-soak.d.ts +57 -0
- package/dist/op/op-waves-soak.js +111 -0
- package/dist/op/op-waves-split.d.ts +4 -0
- package/dist/op/op-waves-split.js +4 -0
- package/dist/op/op-waves.d.ts +67 -4
- package/dist/op/op-waves.js +71 -3
- package/dist/pipeline/agent-ajv.d.ts +4 -0
- package/dist/pipeline/agent-ajv.js +14 -0
- package/dist/pipeline/agent-steps.d.ts +329 -0
- package/dist/pipeline/agent-steps.js +602 -0
- package/dist/pipeline/artifacts.d.ts +264 -0
- package/dist/pipeline/artifacts.js +425 -0
- package/dist/pipeline/diff.d.ts +45 -0
- package/dist/pipeline/diff.js +177 -0
- package/dist/pipeline/fold.d.ts +43 -0
- package/dist/pipeline/fold.js +140 -0
- package/dist/pipeline/generate.d.ts +52 -0
- package/dist/pipeline/generate.js +120 -0
- package/dist/pipeline/product.d.ts +225 -0
- package/dist/pipeline/product.js +257 -0
- package/dist/pipeline/promote.d.ts +404 -0
- package/dist/pipeline/promote.js +694 -0
- package/dist/pipeline/read.d.ts +37 -0
- package/dist/pipeline/read.js +58 -0
- package/dist/pipeline/rendered.d.ts +25 -0
- package/dist/pipeline/rendered.js +53 -0
- package/dist/pipeline/soak-checks.d.ts +80 -0
- package/dist/pipeline/soak-checks.js +254 -0
- package/dist/pipeline/soak-gate.d.ts +97 -0
- package/dist/pipeline/soak-gate.js +176 -0
- package/dist/pipeline/soak-sources.d.ts +17 -0
- package/dist/pipeline/soak-sources.js +42 -0
- package/dist/pipeline/soak.d.ts +260 -0
- package/dist/pipeline/soak.js +378 -0
- package/dist/pipeline/spec.d.ts +724 -0
- package/dist/pipeline/spec.js +567 -0
- package/dist/pipeline/stage-ledger.d.ts +187 -0
- package/dist/pipeline/stage-ledger.js +185 -0
- package/dist/pipeline/stage-waves.d.ts +114 -0
- package/dist/pipeline/stage-waves.js +161 -0
- package/dist/pipeline/stages.d.ts +64 -0
- package/dist/pipeline/stages.js +174 -0
- package/dist/pipeline/verify-rollback.d.ts +277 -0
- package/dist/pipeline/verify-rollback.js +393 -0
- package/dist/pipeline.d.ts +142 -0
- package/dist/pipeline.js +143 -0
- package/dist/pr-loop.d.ts +22 -0
- package/dist/pr-loop.js +8 -0
- package/dist/pr-plan-note.d.ts +15 -1
- package/dist/pr-plan-note.js +8 -0
- package/dist/pr-post.d.ts +31 -0
- package/dist/pr-post.js +89 -0
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/report-store/audit.schema.json +50 -0
- package/dist/report-store/dora.schema.json +331 -0
- package/dist/report-store/estate.schema.json +96 -0
- package/dist/report-store/run.schema.json +14 -0
- package/dist/report-store.d.ts +151 -0
- package/dist/report-store.js +344 -0
- package/dist/run-event.d.ts +7 -2
- package/dist/wave-runtime.mjs +458 -404
- package/dist/workspace/catalog-edges.js +3 -3
- package/dist/workspace/change-set.schema.json +4 -0
- package/dist/workspace/ci-cloud-identity.d.ts +4 -0
- package/dist/workspace/ci-cloud-identity.js +30 -0
- package/dist/workspace/ci-run.js +17 -2
- package/dist/workspace/ci-secrets.d.ts +3 -1
- package/dist/workspace/ci-secrets.js +7 -1
- package/dist/workspace/compose-graph.d.ts +1 -1
- package/dist/workspace/compose-graph.js +3 -1
- package/dist/workspace/declaration.d.ts +27 -0
- package/dist/workspace/declaration.js +35 -0
- package/dist/workspace/declaration.schema.json +56 -0
- package/dist/workspace/graph-cli.js +26 -0
- package/dist/workspace/graph.schema.json +5 -1
- package/dist/workspace/identity-gate-rule.d.ts +4 -0
- package/dist/workspace/identity-gate-rule.js +2 -2
- package/dist/workspace/identity-reject-rule.d.ts +14 -0
- package/dist/workspace/identity-reject-rule.js +24 -0
- package/dist/workspace/identity.d.ts +3 -0
- package/dist/workspace/identity.js +2 -1
- package/dist/workspace/nested-graph.js +2 -0
- package/dist/workspace/pr-report.schema.json +65 -0
- package/dist/workspace/promotion-order.d.ts +19 -4
- package/dist/workspace/promotion-order.js +26 -4
- package/dist/workspace/release-train.d.ts +14 -0
- package/dist/workspace/release-train.js +32 -0
- package/dist/workspace/run-event.schema.json +2 -2
- package/dist/workspace/stack-read-edges.d.ts +19 -0
- package/dist/workspace/stack-read-edges.js +54 -0
- package/dist/workspace/status-gates.d.ts +51 -1
- package/dist/workspace/status-gates.js +60 -0
- package/dist/workspace/status-stages.d.ts +223 -0
- package/dist/workspace/status-stages.js +279 -0
- package/dist/workspace/status.d.ts +45 -1
- package/dist/workspace/status.js +109 -5
- package/dist/workspace/status.schema.json +283 -2
- package/dist/workspace/trust/seal.d.ts +7 -0
- package/dist/workspace/trust/seal.js +9 -0
- package/package.json +5 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fold a pipeline declaration to its spec without running it (#5324).
|
|
3
|
+
*
|
|
4
|
+
* `.chant/pipeline.ts` is written inside the TypeScript-as-data subset: an
|
|
5
|
+
* `import { pipeline } from "@intentius/chant/pipeline"`, top-level `const`s
|
|
6
|
+
* of literals, and `export default pipeline({ ... })`. The fold reads the
|
|
7
|
+
* file's text and reduces the argument with the same `fold()` a resource
|
|
8
|
+
* file goes through (`../fold/fold.ts`). Nothing is imported and nothing
|
|
9
|
+
* runs, so the gates can fold the file as it stood at the base commit.
|
|
10
|
+
*
|
|
11
|
+
* Unlike a resource file, a pipeline file outside the subset never falls
|
|
12
|
+
* back to running. The fold refuses it with a finding: the evaluability
|
|
13
|
+
* rule's id (EVL001 or EVL003 from the subset classifier, or EVL012 for a
|
|
14
|
+
* file whose shape is not a pipeline declaration), the line and column, and
|
|
15
|
+
* the reason. `chant build`, `chant lint` and the LSP report that finding.
|
|
16
|
+
*/
|
|
17
|
+
import { type PipelineSpec } from "./spec.js";
|
|
18
|
+
/** The evaluability rule a pipeline file whose shape is not a declaration breaks. */
|
|
19
|
+
export declare const PIPELINE_FOLD_RULE = "EVL012";
|
|
20
|
+
/** The module a pipeline file imports its helper from. */
|
|
21
|
+
export declare const PIPELINE_MODULE = "@intentius/chant/pipeline";
|
|
22
|
+
/** Why a pipeline file did not fold, located in the file. */
|
|
23
|
+
export interface PipelineFinding {
|
|
24
|
+
ruleId: string;
|
|
25
|
+
line: number;
|
|
26
|
+
column: number;
|
|
27
|
+
message: string;
|
|
28
|
+
}
|
|
29
|
+
/** The fold's outcome: the spec, or the first finding. */
|
|
30
|
+
export type PipelineFold = {
|
|
31
|
+
spec: PipelineSpec;
|
|
32
|
+
} | {
|
|
33
|
+
finding: PipelineFinding;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Fold a pipeline file's text. `file` names it in the messages. Returns the
|
|
37
|
+
* checked spec, or the first finding: a subset violation with the EVL rule
|
|
38
|
+
* the classifier names, a shape that is not a declaration (EVL012), or a
|
|
39
|
+
* declaration the spec check refuses (EVL012, at the export).
|
|
40
|
+
*/
|
|
41
|
+
export declare function foldPipelineSource(text: string, file?: string): PipelineFold;
|
|
42
|
+
/** The one-line form of a finding: `<file>:<line>:<column> [<rule>] <message>`. */
|
|
43
|
+
export declare function pipelineFindingLine(file: string, finding: PipelineFinding): string;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fold a pipeline declaration to its spec without running it (#5324).
|
|
3
|
+
*
|
|
4
|
+
* `.chant/pipeline.ts` is written inside the TypeScript-as-data subset: an
|
|
5
|
+
* `import { pipeline } from "@intentius/chant/pipeline"`, top-level `const`s
|
|
6
|
+
* of literals, and `export default pipeline({ ... })`. The fold reads the
|
|
7
|
+
* file's text and reduces the argument with the same `fold()` a resource
|
|
8
|
+
* file goes through (`../fold/fold.ts`). Nothing is imported and nothing
|
|
9
|
+
* runs, so the gates can fold the file as it stood at the base commit.
|
|
10
|
+
*
|
|
11
|
+
* Unlike a resource file, a pipeline file outside the subset never falls
|
|
12
|
+
* back to running. The fold refuses it with a finding: the evaluability
|
|
13
|
+
* rule's id (EVL001 or EVL003 from the subset classifier, or EVL012 for a
|
|
14
|
+
* file whose shape is not a pipeline declaration), the line and column, and
|
|
15
|
+
* the reason. `chant build`, `chant lint` and the LSP report that finding.
|
|
16
|
+
*/
|
|
17
|
+
import * as ts from "typescript";
|
|
18
|
+
import { collectConsts, fold, FoldError } from "../fold/fold.js";
|
|
19
|
+
import { asPipelineSpec } from "./spec.js";
|
|
20
|
+
/** The evaluability rule a pipeline file whose shape is not a declaration breaks. */
|
|
21
|
+
export const PIPELINE_FOLD_RULE = "EVL012";
|
|
22
|
+
/** The module a pipeline file imports its helper from. */
|
|
23
|
+
export const PIPELINE_MODULE = "@intentius/chant/pipeline";
|
|
24
|
+
class Refused extends Error {
|
|
25
|
+
constructor(message, node, ruleId = PIPELINE_FOLD_RULE) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.node = node;
|
|
28
|
+
this.ruleId = ruleId;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function at(source, node) {
|
|
32
|
+
const { line, character } = source.getLineAndCharacterOfPosition(node.getStart(source));
|
|
33
|
+
return { line: line + 1, column: character + 1 };
|
|
34
|
+
}
|
|
35
|
+
function unwrap(node) {
|
|
36
|
+
let current = node;
|
|
37
|
+
while (ts.isParenthesizedExpression(current) || ts.isAsExpression(current) || ts.isSatisfiesExpression(current) || ts.isNonNullExpression(current))
|
|
38
|
+
current = current.expression;
|
|
39
|
+
return current;
|
|
40
|
+
}
|
|
41
|
+
const isExported = (node) => (ts.canHaveModifiers(node) && ts.getModifiers(node)?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword)) ?? false;
|
|
42
|
+
/** The local names the file binds to the pipeline helper. */
|
|
43
|
+
function helperNames(source) {
|
|
44
|
+
const names = new Set();
|
|
45
|
+
for (const statement of source.statements) {
|
|
46
|
+
if (!ts.isImportDeclaration(statement))
|
|
47
|
+
continue;
|
|
48
|
+
const from = statement.moduleSpecifier.text;
|
|
49
|
+
const clause = statement.importClause;
|
|
50
|
+
if (from !== PIPELINE_MODULE) {
|
|
51
|
+
// A type-only import adds no value, so it cannot carry one in.
|
|
52
|
+
if (clause?.isTypeOnly)
|
|
53
|
+
continue;
|
|
54
|
+
throw new Refused(`a pipeline file imports only from ${PIPELINE_MODULE}; "${from}" would bring in a value the fold cannot read`, statement);
|
|
55
|
+
}
|
|
56
|
+
if (!clause || clause.isTypeOnly)
|
|
57
|
+
continue;
|
|
58
|
+
if (clause.name)
|
|
59
|
+
throw new Refused(`${PIPELINE_MODULE} has no default export; import { pipeline }`, clause.name);
|
|
60
|
+
const bindings = clause.namedBindings;
|
|
61
|
+
if (bindings && ts.isNamespaceImport(bindings))
|
|
62
|
+
throw new Refused(`import { pipeline } from "${PIPELINE_MODULE}" by name, not as a namespace`, bindings);
|
|
63
|
+
for (const el of bindings && ts.isNamedImports(bindings) ? bindings.elements : []) {
|
|
64
|
+
if (el.isTypeOnly)
|
|
65
|
+
continue;
|
|
66
|
+
if ((el.propertyName ?? el.name).text === "pipeline")
|
|
67
|
+
names.add(el.name.text);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return names;
|
|
71
|
+
}
|
|
72
|
+
function declarationOf(source, helpers) {
|
|
73
|
+
let found;
|
|
74
|
+
for (const statement of source.statements) {
|
|
75
|
+
if (ts.isImportDeclaration(statement) || ts.isTypeAliasDeclaration(statement) || ts.isInterfaceDeclaration(statement) || ts.isEmptyStatement(statement))
|
|
76
|
+
continue;
|
|
77
|
+
if (ts.isExportAssignment(statement)) {
|
|
78
|
+
if (statement.isExportEquals)
|
|
79
|
+
throw new Refused("a pipeline file exports its declaration with `export default`", statement);
|
|
80
|
+
found = statement.expression;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (ts.isVariableStatement(statement)) {
|
|
84
|
+
if ((statement.declarationList.flags & ts.NodeFlags.Const) === 0)
|
|
85
|
+
throw new Refused("a pipeline file declares only `const`s; a `let` or `var` can change before it is read", statement);
|
|
86
|
+
if (isExported(statement))
|
|
87
|
+
throw new Refused("a pipeline file exports one thing, `export default pipeline({ ... })`", statement);
|
|
88
|
+
for (const d of statement.declarationList.declarations) {
|
|
89
|
+
if (!ts.isIdentifier(d.name))
|
|
90
|
+
throw new Refused("a destructured `const` is not read in a pipeline file", d);
|
|
91
|
+
if (!d.initializer)
|
|
92
|
+
throw new Refused(`\`const ${d.name.text}\` has no value`, d);
|
|
93
|
+
}
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
throw new Refused(`a pipeline file holds imports, \`const\`s and \`export default pipeline({ ... })\`; this ${ts.SyntaxKind[statement.kind]} is outside the subset`, statement);
|
|
97
|
+
}
|
|
98
|
+
if (!found)
|
|
99
|
+
throw new Refused("a pipeline file ends with `export default pipeline({ ... })`", source);
|
|
100
|
+
const call = unwrap(found);
|
|
101
|
+
if (ts.isCallExpression(call)) {
|
|
102
|
+
const callee = unwrap(call.expression);
|
|
103
|
+
if (!ts.isIdentifier(callee) || !helpers.has(callee.text))
|
|
104
|
+
throw new Refused(`the declaration is \`pipeline({ ... })\` with pipeline imported from ${PIPELINE_MODULE}`, call.expression);
|
|
105
|
+
if (call.arguments.length !== 1)
|
|
106
|
+
throw new Refused("`pipeline()` takes one object, the declaration", call);
|
|
107
|
+
return call.arguments[0];
|
|
108
|
+
}
|
|
109
|
+
// A plain object literal folds as well: the helper only types it.
|
|
110
|
+
return found;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Fold a pipeline file's text. `file` names it in the messages. Returns the
|
|
114
|
+
* checked spec, or the first finding: a subset violation with the EVL rule
|
|
115
|
+
* the classifier names, a shape that is not a declaration (EVL012), or a
|
|
116
|
+
* declaration the spec check refuses (EVL012, at the export).
|
|
117
|
+
*/
|
|
118
|
+
export function foldPipelineSource(text, file = ".chant/pipeline.ts") {
|
|
119
|
+
const source = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
120
|
+
let exportNode = source;
|
|
121
|
+
try {
|
|
122
|
+
const helpers = helperNames(source);
|
|
123
|
+
const expr = declarationOf(source, helpers);
|
|
124
|
+
exportNode = expr;
|
|
125
|
+
const value = fold(expr, collectConsts(source));
|
|
126
|
+
const plain = JSON.parse(JSON.stringify(value));
|
|
127
|
+
return { spec: asPipelineSpec(plain, file) };
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
if (err instanceof FoldError)
|
|
131
|
+
return { finding: { ruleId: err.ruleId, line: err.line, column: err.column, message: err.message.replace(/^\d+:\d+ - /, "") } };
|
|
132
|
+
if (err instanceof Refused)
|
|
133
|
+
return { finding: { ruleId: err.ruleId, ...at(source, err.node), message: err.message } };
|
|
134
|
+
return { finding: { ruleId: PIPELINE_FOLD_RULE, ...at(source, exportNode), message: err instanceof Error ? err.message : String(err) } };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** The one-line form of a finding: `<file>:<line>:<column> [<rule>] <message>`. */
|
|
138
|
+
export function pipelineFindingLine(file, finding) {
|
|
139
|
+
return `${file}:${finding.line}:${finding.column} [${finding.ruleId}] ${finding.message}`;
|
|
140
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pipeline's jobs for a forge, from the folded spec (#5324).
|
|
3
|
+
*
|
|
4
|
+
* Two files:
|
|
5
|
+
*
|
|
6
|
+
* - the merge's waves: the first stage's op-waves spec, rendered by the
|
|
7
|
+
* lexicon's `generateOpWavesPipeline` with `renderSpec`, so every wave
|
|
8
|
+
* job runs `chant run wave --render-spec` and reads its spec, and its gate
|
|
9
|
+
* at the base commit, from `chant pipeline spec --stage <first>`, which
|
|
10
|
+
* folds `.chant/pipeline.ts` at the commit it is handed. The release cut
|
|
11
|
+
* and the control dispatch come with that stage's spec;
|
|
12
|
+
* - the promote jobs: one manual job per later stage, from the lexicon's
|
|
13
|
+
* `generatePipelinePromote`, each running `components promote --to
|
|
14
|
+
* <stage> --release <release>`. A stage with agent steps (#5358) gets a
|
|
15
|
+
* job before its promote that holds a read token only and runs them.
|
|
16
|
+
*
|
|
17
|
+
* Each stage's jobs log in as that stage alone and take that stage's config
|
|
18
|
+
* and secret set (#5348): the first stage's waves trade for the apply
|
|
19
|
+
* identity `ci.identity.cloud` gives the first stage, and each promote job
|
|
20
|
+
* for its own stage's, with its stage's set as variables and the read of
|
|
21
|
+
* its store secrets.
|
|
22
|
+
*/
|
|
23
|
+
import { type LexiconPlugin, type OpPipelineFile, type OpWavesPipelineOptions } from "../lexicon.js";
|
|
24
|
+
import { type CloudIdentityDeclaration } from "../ci-identity.js";
|
|
25
|
+
import { type OpWaveJob } from "../op/op-waves.js";
|
|
26
|
+
import type { PipelineSpec } from "./spec.js";
|
|
27
|
+
/**
|
|
28
|
+
* Options for {@link generatePipeline}: the op-waves generator's, without
|
|
29
|
+
* the spec file and the render, which the pipeline sets, and the cloud
|
|
30
|
+
* identities (#5348): `ci.identity.cloud`, which gives each stage's jobs
|
|
31
|
+
* that stage's apply identity, resolved for the stage and `member`. With
|
|
32
|
+
* `environmentSets`, each stage's jobs take that stage's config and secret
|
|
33
|
+
* set: the first stage's wave jobs through the op-waves generator, and each
|
|
34
|
+
* later stage's promote job here.
|
|
35
|
+
*/
|
|
36
|
+
export type PipelineGenerateOptions = Omit<OpWavesPipelineOptions, "specFile" | "renderSpec"> & {
|
|
37
|
+
identity?: CloudIdentityDeclaration;
|
|
38
|
+
member?: string;
|
|
39
|
+
};
|
|
40
|
+
/** What {@link generatePipeline} rendered. */
|
|
41
|
+
export interface PipelineGenerateResult {
|
|
42
|
+
success: boolean;
|
|
43
|
+
files?: OpPipelineFile[];
|
|
44
|
+
jobs?: OpWaveJob[];
|
|
45
|
+
error?: string;
|
|
46
|
+
}
|
|
47
|
+
/** The command a wave job renders its stage's spec with: `<bin> pipeline spec --stage <stage>`. */
|
|
48
|
+
export declare function pipelineSpecCommand(stage: string, bin?: string): string[];
|
|
49
|
+
/** The file the first stage's wave jobs write their rendered spec over. */
|
|
50
|
+
export declare function pipelineStageSpecFile(spec: Pick<PipelineSpec, "name">, stage: string): string;
|
|
51
|
+
/** Render the pipeline's files for `lexicon`. `plugin` is injected in tests. */
|
|
52
|
+
export declare function generatePipeline(spec: PipelineSpec, lexicon: string, options?: PipelineGenerateOptions, plugin?: LexiconPlugin | null): Promise<PipelineGenerateResult>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pipeline's jobs for a forge, from the folded spec (#5324).
|
|
3
|
+
*
|
|
4
|
+
* Two files:
|
|
5
|
+
*
|
|
6
|
+
* - the merge's waves: the first stage's op-waves spec, rendered by the
|
|
7
|
+
* lexicon's `generateOpWavesPipeline` with `renderSpec`, so every wave
|
|
8
|
+
* job runs `chant run wave --render-spec` and reads its spec, and its gate
|
|
9
|
+
* at the base commit, from `chant pipeline spec --stage <first>`, which
|
|
10
|
+
* folds `.chant/pipeline.ts` at the commit it is handed. The release cut
|
|
11
|
+
* and the control dispatch come with that stage's spec;
|
|
12
|
+
* - the promote jobs: one manual job per later stage, from the lexicon's
|
|
13
|
+
* `generatePipelinePromote`, each running `components promote --to
|
|
14
|
+
* <stage> --release <release>`. A stage with agent steps (#5358) gets a
|
|
15
|
+
* job before its promote that holds a read token only and runs them.
|
|
16
|
+
*
|
|
17
|
+
* Each stage's jobs log in as that stage alone and take that stage's config
|
|
18
|
+
* and secret set (#5348): the first stage's waves trade for the apply
|
|
19
|
+
* identity `ci.identity.cloud` gives the first stage, and each promote job
|
|
20
|
+
* for its own stage's, with its stage's set as variables and the read of
|
|
21
|
+
* its store secrets.
|
|
22
|
+
*/
|
|
23
|
+
import { importLexiconPackage, lexiconModulePath } from "../lexicon-module.js";
|
|
24
|
+
import { isLexiconPlugin } from "../lexicon.js";
|
|
25
|
+
import { resolveCloudIdentity } from "../ci-identity.js";
|
|
26
|
+
import { environmentSetJobInputs, resolveEnvironmentSet } from "../components/environment-sets.js";
|
|
27
|
+
import { environmentSetForgeVariables } from "../op/op-waves-environment-sets.js";
|
|
28
|
+
import { activeProductWords } from "../ci-product-words.js";
|
|
29
|
+
import { opWaveBinArgv } from "../op/op-waves.js";
|
|
30
|
+
import { stageWavesSpec } from "./stages.js";
|
|
31
|
+
import { stageAgentKeyEnvs, stageAgentSteps } from "./agent-steps.js";
|
|
32
|
+
/** The forges a pipeline renders for, as the set's forge words spell them. */
|
|
33
|
+
const SET_FORGES = new Set(["github", "gitlab", "forgejo"]);
|
|
34
|
+
/**
|
|
35
|
+
* The first stage's op-waves spec with each wave's cloud identity, from
|
|
36
|
+
* `identity` for the stage, on every wave that names none of its own.
|
|
37
|
+
*/
|
|
38
|
+
function withStageIdentity(shape, stage, identity, member) {
|
|
39
|
+
const cloud = identity ? resolveCloudIdentity(identity, stage, member)?.apply : undefined;
|
|
40
|
+
if (!cloud)
|
|
41
|
+
return shape;
|
|
42
|
+
return { ...shape, waves: shape.waves.map((w) => (w.cloud ? w : { ...w, cloud })) };
|
|
43
|
+
}
|
|
44
|
+
/** What one later stage's promote job adds: its identity and its set. */
|
|
45
|
+
function promoteStageInputs(stage, lexicon, options) {
|
|
46
|
+
const cloud = options.identity ? resolveCloudIdentity(options.identity, stage, options.member)?.apply : undefined;
|
|
47
|
+
const out = cloud ? { cloud } : {};
|
|
48
|
+
if (options.environmentSets && SET_FORGES.has(lexicon)) {
|
|
49
|
+
const forge = lexicon;
|
|
50
|
+
const set = resolveEnvironmentSet(options.environmentSets, stage);
|
|
51
|
+
out.variables = environmentSetForgeVariables(set, forge);
|
|
52
|
+
const setup = environmentSetJobInputs(set, forge).setup;
|
|
53
|
+
if (setup.length > 0)
|
|
54
|
+
out.setup = setup;
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
async function pluginOf(name) {
|
|
59
|
+
try {
|
|
60
|
+
const mod = (await importLexiconPackage(lexiconModulePath(name) ?? `@intentius/chant-lexicon-${name}`));
|
|
61
|
+
return Object.values(mod).find((v) => isLexiconPlugin(v)) ?? null;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** The command a wave job renders its stage's spec with: `<bin> pipeline spec --stage <stage>`. */
|
|
68
|
+
export function pipelineSpecCommand(stage, bin) {
|
|
69
|
+
return [...opWaveBinArgv(bin), "pipeline", "spec", "--stage", stage];
|
|
70
|
+
}
|
|
71
|
+
/** The file the first stage's wave jobs write their rendered spec over. */
|
|
72
|
+
export function pipelineStageSpecFile(spec, stage) {
|
|
73
|
+
return `.chant/op-waves/${spec.name}-${stage}.spec.json`;
|
|
74
|
+
}
|
|
75
|
+
/** Render the pipeline's files for `lexicon`. `plugin` is injected in tests. */
|
|
76
|
+
export async function generatePipeline(spec, lexicon, options = {}, plugin) {
|
|
77
|
+
const found = plugin === undefined ? await pluginOf(lexicon) : plugin;
|
|
78
|
+
if (!found?.generateOpWavesPipeline || !found.generatePipelinePromote) {
|
|
79
|
+
return { success: false, error: `Lexicon "${lexicon}" does not render a pipeline. GitHub, GitLab and Forgejo do.` };
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const first = spec.stages[0].name;
|
|
83
|
+
const bin = options.bin ?? activeProductWords().bin;
|
|
84
|
+
const { identity, member, ...waveOptions } = options;
|
|
85
|
+
const shape = withStageIdentity(stageWavesSpec(spec, first), first, identity, member);
|
|
86
|
+
const waves = found.generateOpWavesPipeline(shape, {
|
|
87
|
+
...waveOptions,
|
|
88
|
+
...(bin ? { bin } : {}),
|
|
89
|
+
specFile: pipelineStageSpecFile(spec, first),
|
|
90
|
+
renderSpec: { command: pipelineSpecCommand(first, bin) },
|
|
91
|
+
});
|
|
92
|
+
const later = spec.stages.slice(1);
|
|
93
|
+
const promote = later.length === 0
|
|
94
|
+
? []
|
|
95
|
+
: found.generatePipelinePromote({
|
|
96
|
+
pipeline: spec.name,
|
|
97
|
+
stages: later.map((s) => ({
|
|
98
|
+
name: s.name,
|
|
99
|
+
...(s.forgeEnvironment ? { environment: s.forgeEnvironment } : {}),
|
|
100
|
+
...promoteStageInputs(s.name, lexicon, options),
|
|
101
|
+
// #5358: the stage's agent steps run in a job of their own before the promote.
|
|
102
|
+
...(stageAgentSteps(spec, s.name).length > 0 ? { agentSteps: { keyEnvs: stageAgentKeyEnvs(spec, s.name) } } : {}),
|
|
103
|
+
})),
|
|
104
|
+
...(bin ? { bin } : {}),
|
|
105
|
+
...(spec.defaults?.runner ? { runner: spec.defaults.runner } : {}),
|
|
106
|
+
// #5425: the product's image and install lines, as the wave jobs take them.
|
|
107
|
+
...(options.image ? { image: options.image } : {}),
|
|
108
|
+
...(options.beforeScript && options.beforeScript.length > 0 ? { beforeScript: [...options.beforeScript] } : {}),
|
|
109
|
+
...(options.jobTimeoutMinutes ? { jobTimeoutMinutes: options.jobTimeoutMinutes } : {}),
|
|
110
|
+
// #5326: the scheduled re-run of the promotions a soak holds.
|
|
111
|
+
...(spec.recheck ? { recheck: { schedule: spec.recheck.schedule } } : {}),
|
|
112
|
+
// #5339: with verify-failed among agentFacts' triggers, the promote jobs record failed verifies and soaks for the agent.
|
|
113
|
+
...(options.agentFacts?.triggers?.includes("verify-failed") ? { agentFacts: { ...(options.agentFacts.relayKeyEnv ? { relayKeyEnv: options.agentFacts.relayKeyEnv } : {}) } } : {}),
|
|
114
|
+
});
|
|
115
|
+
return { success: true, files: [...waves.files, ...promote], jobs: waves.jobs };
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
return { success: false, error: err instanceof Error ? err.message : String(err) };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The helpers a product writes `.chant/pipeline.ts` with (#5324).
|
|
3
|
+
*
|
|
4
|
+
* A committed TypeScript file cannot read `terragucci.yml`, `plywood.yml` or
|
|
5
|
+
* `yodel.config.ts` itself, so the product writes the file from its config,
|
|
6
|
+
* the way it renders its workflows: {@link pipelineFromConfig} maps the
|
|
7
|
+
* vocabulary's keys (`promotion`, `environments.<name>.gate`, `.hold`,
|
|
8
|
+
* `.freeze`, `.failure_tolerance`, `.risk`, `.replan_dependents`, `.publish`, `.reads`, `.after`, `.queue`,
|
|
9
|
+
* `.urgent`, `.pause_after_rollback`, `.hooks.<when>`, `.agent_steps`, `.on_verify_fail`,
|
|
10
|
+
* `approval_rules`, `release.cut`) onto a
|
|
11
|
+
* declaration, {@link pipelineSource} writes the file's text, and
|
|
12
|
+
* {@link checkPipelineFile} is what `<product> ci --check` runs: it fails
|
|
13
|
+
* when the committed file is not the one the config writes now.
|
|
14
|
+
*
|
|
15
|
+
* The file is generated output. Hand edits are overwritten the next time the
|
|
16
|
+
* product writes it, and fail the check until then.
|
|
17
|
+
*/
|
|
18
|
+
import { OP_WAVE_HOOK_MOMENTS, type OpWaveHook } from "../op/op-waves.js";
|
|
19
|
+
import type { OpEnvironment } from "../lexicon.js";
|
|
20
|
+
import { type PipelineDeclaration, type PipelineDefaults, type PipelineFailureTolerance, type PipelineFreezeWindow, type PipelineGate, type PipelineRecheck, type PipelineRelease, type PipelineStage, type PipelineWave } from "./spec.js";
|
|
21
|
+
/**
|
|
22
|
+
* The first chant whose `pipelineFromConfig` maps a stage's hooks (#5421):
|
|
23
|
+
* `environments.<name>.hooks.<when>` in a product's config onto a stage's
|
|
24
|
+
* `hooks` in `.chant/pipeline.ts`, with `<when>` one of `before-observe`,
|
|
25
|
+
* `before-plan`, `after-plan`, `after-gate`, `before-apply` and
|
|
26
|
+
* `after-apply`. A product feature-detects the key on this name before it
|
|
27
|
+
* writes it.
|
|
28
|
+
*/
|
|
29
|
+
export declare const STAGE_HOOKS_KEY_FLOOR = "0.124.110";
|
|
30
|
+
/** One stage hook as a product's config spells it: the keys of {@link OpWaveHook}, snake_case or camelCase. */
|
|
31
|
+
export interface StageHookConfig {
|
|
32
|
+
name?: string;
|
|
33
|
+
command: string[];
|
|
34
|
+
on_failure?: OpWaveHook["onFailure"];
|
|
35
|
+
onFailure?: OpWaveHook["onFailure"];
|
|
36
|
+
per_run?: boolean;
|
|
37
|
+
perRun?: boolean;
|
|
38
|
+
targets?: string[];
|
|
39
|
+
}
|
|
40
|
+
/** One environment's settings, as a product's config spells them under `environments.<name>`, snake_case or camelCase. */
|
|
41
|
+
export interface PipelineEnvironmentConfig {
|
|
42
|
+
gate?: PipelineGate["policy"];
|
|
43
|
+
approval?: PipelineGate["approval"] | {
|
|
44
|
+
mode?: PipelineGate["approval"];
|
|
45
|
+
};
|
|
46
|
+
approval_rules?: ApprovalRulesConfig;
|
|
47
|
+
approvalRules?: ApprovalRulesConfig;
|
|
48
|
+
hold?: boolean | {
|
|
49
|
+
reason?: string;
|
|
50
|
+
until?: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
};
|
|
53
|
+
freeze?: PipelineFreezeWindow[];
|
|
54
|
+
failure_tolerance?: PipelineFailureTolerance;
|
|
55
|
+
failureTolerance?: PipelineFailureTolerance;
|
|
56
|
+
/** A name, or `{ name, url }`. */
|
|
57
|
+
forge_environment?: string | OpEnvironment;
|
|
58
|
+
forgeEnvironment?: string | OpEnvironment;
|
|
59
|
+
canary?: boolean;
|
|
60
|
+
/** `publish.<artifact>`: `{ member, output }`, or `{ secret }` in a set's secret words, snake_case or camelCase (#5356). */
|
|
61
|
+
publish?: Record<string, {
|
|
62
|
+
member?: string;
|
|
63
|
+
output?: string;
|
|
64
|
+
secret?: unknown;
|
|
65
|
+
}>;
|
|
66
|
+
/** `reads.<variable>`: `{ stage, artifact }` (#5356). */
|
|
67
|
+
reads?: Record<string, {
|
|
68
|
+
stage: string;
|
|
69
|
+
artifact: string;
|
|
70
|
+
}>;
|
|
71
|
+
/** The stages a release applies in before this one opens (#5353). */
|
|
72
|
+
after?: string[];
|
|
73
|
+
/** `replace`: one release at a time, a newer one waiting replacing an older (#5353). */
|
|
74
|
+
queue?: PipelineStage["queue"];
|
|
75
|
+
/** `urgent.role` (#5355): the role whose one proven approval passes the stage's gate on `promote --urgent`. */
|
|
76
|
+
urgent?: {
|
|
77
|
+
role: string;
|
|
78
|
+
};
|
|
79
|
+
/** `pause_after_rollback` (#5355): a rollback of the stage pauses it. */
|
|
80
|
+
pause_after_rollback?: boolean;
|
|
81
|
+
pauseAfterRollback?: boolean;
|
|
82
|
+
/** `risk.approve_above` and `risk.approval_rules` (#5325): the score over which the stage's waves wait, and the rules they take on top of the gate's own. Land on the gate's `holds.risk`. */
|
|
83
|
+
risk?: RiskConfig;
|
|
84
|
+
/** `replan_dependents`: the members whose dependents are planned again when an output they read changes after an apply (#5345). Replaces `defaults.replanDependents` for the stage. */
|
|
85
|
+
replan_dependents?: string[];
|
|
86
|
+
replanDependents?: string[];
|
|
87
|
+
/** `soak`: `{ duration, checks, overrides }`; a check's `on_fail` and `timeout_seconds` in snake_case or camelCase (#5326). */
|
|
88
|
+
soak?: SoakConfig;
|
|
89
|
+
/** `hooks.<when>` (#5421): the commands a stage runs at `before-observe`, `before-plan`, `after-plan`, `after-gate`, `before-apply` or `after-apply`, each a list of hooks. */
|
|
90
|
+
hooks?: Partial<Record<(typeof OP_WAVE_HOOK_MOMENTS)[number], StageHookConfig[]>>;
|
|
91
|
+
/** `agent_steps.<step>`: `prompt`, `reads`, `schema`, `command`, `key_secret`, `timeout`, `max_runs`, `max_cost_usd` (#5358), snake_case or camelCase. */
|
|
92
|
+
agent_steps?: Record<string, AgentStepConfig>;
|
|
93
|
+
agentSteps?: Record<string, AgentStepConfig>;
|
|
94
|
+
/** `on_verify_fail` (#5328): `hold`, or `rollback` to request the rollback to the stage's previous release when its verify or soak fails. */
|
|
95
|
+
on_verify_fail?: PipelineStage["onVerifyFail"];
|
|
96
|
+
onVerifyFail?: PipelineStage["onVerifyFail"];
|
|
97
|
+
[key: string]: unknown;
|
|
98
|
+
}
|
|
99
|
+
/** `environments.<name>.risk` as a product's config spells it, snake_case or camelCase (#5325). */
|
|
100
|
+
export interface RiskConfig {
|
|
101
|
+
approve_above?: number;
|
|
102
|
+
approveAbove?: number;
|
|
103
|
+
/** Rules only; a group (`all`, `any`) is refused, since a risk hold takes plain rules. */
|
|
104
|
+
approval_rules?: ApprovalRulesConfig;
|
|
105
|
+
approvalRules?: ApprovalRulesConfig;
|
|
106
|
+
}
|
|
107
|
+
/** A soak as a product's config spells it (#5326): the keys of {@link Soak}, snake_case or camelCase. */
|
|
108
|
+
export interface SoakConfig {
|
|
109
|
+
duration: string;
|
|
110
|
+
checks?: Record<string, unknown>[];
|
|
111
|
+
overrides?: {
|
|
112
|
+
members: string[];
|
|
113
|
+
duration?: string;
|
|
114
|
+
checks?: Record<string, unknown>[];
|
|
115
|
+
}[];
|
|
116
|
+
}
|
|
117
|
+
/** One agent step as a config spells it (#5358). */
|
|
118
|
+
export interface AgentStepConfig {
|
|
119
|
+
prompt: string;
|
|
120
|
+
reads?: Record<string, {
|
|
121
|
+
stage: string;
|
|
122
|
+
artifact: string;
|
|
123
|
+
} | {
|
|
124
|
+
step: string;
|
|
125
|
+
}>;
|
|
126
|
+
schema: Record<string, unknown>;
|
|
127
|
+
command?: string;
|
|
128
|
+
key_secret?: string;
|
|
129
|
+
keySecret?: string;
|
|
130
|
+
timeout?: number;
|
|
131
|
+
max_runs?: number;
|
|
132
|
+
maxRuns?: number;
|
|
133
|
+
max_cost_usd?: number;
|
|
134
|
+
maxCostUsd?: number;
|
|
135
|
+
}
|
|
136
|
+
/** One approval rule as a config spells it: `count`, `roles`, `not_author`, `targets`, `proven`, `name`. */
|
|
137
|
+
export interface ApprovalRuleConfig {
|
|
138
|
+
count: number;
|
|
139
|
+
roles?: string[];
|
|
140
|
+
not_author?: boolean;
|
|
141
|
+
notAuthor?: boolean;
|
|
142
|
+
targets?: string[];
|
|
143
|
+
proven?: boolean;
|
|
144
|
+
/** The rule's name (#5354). */
|
|
145
|
+
name?: string;
|
|
146
|
+
}
|
|
147
|
+
/** A group of rules (#5354): met when all of them are, or when any one is. Each holds a list or a map of rules and groups. */
|
|
148
|
+
export type ApprovalGroupConfig = {
|
|
149
|
+
name?: string;
|
|
150
|
+
all: ApprovalRulesConfig;
|
|
151
|
+
} | {
|
|
152
|
+
name?: string;
|
|
153
|
+
any: ApprovalRulesConfig;
|
|
154
|
+
};
|
|
155
|
+
/** `approval_rules`: a list (terragucci) or a map of named rules (plywood), of rules and `all`/`any` groups (#5354). */
|
|
156
|
+
export type ApprovalRulesConfig = Array<ApprovalRuleConfig | ApprovalGroupConfig> | Record<string, ApprovalRuleConfig | ApprovalGroupConfig>;
|
|
157
|
+
/** What {@link pipelineFromConfig} reads. */
|
|
158
|
+
export interface PipelineConfigInput {
|
|
159
|
+
/** The pipeline's name: the op its stage gates are recorded under. */
|
|
160
|
+
name: string;
|
|
161
|
+
/** `promotion`: the stages in order. */
|
|
162
|
+
promotion: readonly string[];
|
|
163
|
+
/** `environments`: each stage's settings by name. A stage with none takes the defaults. */
|
|
164
|
+
environments?: Record<string, PipelineEnvironmentConfig | undefined>;
|
|
165
|
+
/** `approval_rules` for every stage; an environment's own replace them. */
|
|
166
|
+
approvalRules?: ApprovalRulesConfig;
|
|
167
|
+
/** `gate` for every stage; an environment's own wins. */
|
|
168
|
+
gate?: PipelineGate["policy"];
|
|
169
|
+
/** `approval` for every stage; an environment's own wins. */
|
|
170
|
+
approval?: PipelineGate["approval"];
|
|
171
|
+
/** The waves each stage applies, by stage name, as the product works them out from its config (its members, stacks or databases). */
|
|
172
|
+
waves: Record<string, PipelineWave[]>;
|
|
173
|
+
/** Op-waves settings every stage shares: the Op, the step, the runner. */
|
|
174
|
+
defaults?: PipelineDefaults;
|
|
175
|
+
/** `release`: `{ cut, label }`, and the product's bin the cut runs as. */
|
|
176
|
+
release?: PipelineRelease;
|
|
177
|
+
/** `control`: the control repo told after the first stage. */
|
|
178
|
+
control?: PipelineDeclaration["control"];
|
|
179
|
+
/** `recheck`: `{ schedule }`, the cron line pending promotions are tried again on (#5326). */
|
|
180
|
+
recheck?: PipelineRecheck;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* A declaration from a product's config, in the vocabulary's keys. Throws
|
|
184
|
+
* when `promotion` names a stage `waves` has none for, or the declaration
|
|
185
|
+
* does not check.
|
|
186
|
+
*/
|
|
187
|
+
export declare function pipelineFromConfig(input: PipelineConfigInput): PipelineDeclaration;
|
|
188
|
+
/** What {@link pipelineSource} puts at the top of the file. */
|
|
189
|
+
export interface PipelineSourceOptions {
|
|
190
|
+
/** The product that writes the file, such as `terragucci`. */
|
|
191
|
+
product: string;
|
|
192
|
+
/** The config file it is written from, such as `terragucci.yml`. */
|
|
193
|
+
config: string;
|
|
194
|
+
/** The command that writes it again, such as `terragucci ci`. */
|
|
195
|
+
command: string;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* The text of `.chant/pipeline.ts` for a declaration: a header naming the
|
|
199
|
+
* product and the command that writes it, the helper's import, and the
|
|
200
|
+
* declaration as one object literal. Folds to the declaration. Throws on a
|
|
201
|
+
* declaration that does not check.
|
|
202
|
+
*/
|
|
203
|
+
export declare function pipelineSource(declaration: PipelineDeclaration, options: PipelineSourceOptions): string;
|
|
204
|
+
/** What {@link checkPipelineFile} found. */
|
|
205
|
+
export type PipelineFileCheck = {
|
|
206
|
+
status: "current";
|
|
207
|
+
file: string;
|
|
208
|
+
} | {
|
|
209
|
+
status: "missing";
|
|
210
|
+
file: string;
|
|
211
|
+
message: string;
|
|
212
|
+
} | {
|
|
213
|
+
status: "stale";
|
|
214
|
+
file: string;
|
|
215
|
+
message: string;
|
|
216
|
+
diff: string[];
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Whether the committed `.chant/pipeline.ts` in `dir` is `expected`, the
|
|
220
|
+
* text {@link pipelineSource} writes from the config now. A stale file's
|
|
221
|
+
* result carries the line diff and a message naming the command.
|
|
222
|
+
*/
|
|
223
|
+
export declare function checkPipelineFile(dir: string, expected: string, options: Pick<PipelineSourceOptions, "command">): PipelineFileCheck;
|
|
224
|
+
/** Write `text` to `.chant/pipeline.ts` in `dir`, creating `.chant`. Returns whether the file changed. */
|
|
225
|
+
export declare function writePipelineFile(dir: string, text: string): boolean;
|