Generated CI for Pull Requests
Show the whole prompt
Read https://intentius.io/chant/guide/pull-request-ci/.
Declare each Terraform root of this repository as a component with a `terraform-apply` step and its `dependsOn`, as the page shows.
Generate the pull-request pipeline for this repository's forge with `npx chant build --components --generate <forge> --pr-loop --env <env> --output <file>`, and open a pull request with the components and the pipeline.
List the token, branch protection and `identity.gates` entry a person must set up; do not create tokens or change branch protection yourself.
Never deploy to a real cloud account or shared environment (with `chant run`, `chant components` or a platform's own CLI), approve (a pull request review, `chant approve` or `chant run approve`), override a policy denial (`chant approve policy-override`), or merge; never cut or publish a release (`chant release cut --yes` or `chant release publish`), push or delete a `ci/*` tag (`chant ci tick` pushes them), or change the value of an existing flag; never touch `.chant/allowed_signers` or `chant/lifecycle`.Optional: hand this page to your coding agent
Read https://intentius.io/chant/guide/pull-request-ci/.Declare each Terraform root of this repository as a component with a `terraform-apply` step and its `dependsOn`, as the page shows.Generate the pull-request pipeline for this repository's forge with `npx chant build --components --generate <forge> --pr-loop --env <env> --output <file>`, and open a pull request with the components and the pipeline.List the token, branch protection and `identity.gates` entry a person must set up; do not create tokens or change branch protection yourself.Never deploy to a real cloud account or shared environment (with `chant run`, `chant components` or a platform's own CLI), approve (a pull request review, `chant approve` or `chant run approve`), override a policy denial (`chant approve policy-override`), or merge; never cut or publish a release (`chant release cut --yes` or `chant release publish`), push or delete a `ci/*` tag (`chant ci tick` pushes them), or change the value of an existing flag; never touch `.chant/allowed_signers` or `chant/lifecycle`.chant can generate a pull-request pipeline for a project whose components deploy Terraform roots, CloudFormation stacks or Kubernetes manifests, the three capabilities that can plan. A component built from other capabilities goes through the same pipeline, but its plan describes no changes. The pipeline does four things:
- On a pull request, it plans the components the change touches and the components that depend on them, and nothing else.
- It posts that plan on the pull request as one note, with a commit status.
- A reviewer may approve the plan’s digest.
- On merge, it plans the same components again and records the plan with the merge (#4168). It applies nothing. A release that carries the commit deploys the change through its own gate.
A merge never deploys unless you opt in. Apply on merge replaces the record job with an apply that runs the approved plan, as every pull-request pipeline did before #4168.
The pipeline runs two commands, chant components pr-plan and pr-record. Each job runs its command through chant ci run plan or chant ci run record in the job’s own checkout, which records the run (#4156). This page sets it up on each forge.
A project to run it on
Section titled “A project to run it on”Each Terraform root is a component with one terraform-apply step. A root that reads another root’s output names that component in dependsOn and reads the output through stackOutput().
{ "lexicons": ["terraform"], "terraform": { "binary": "tofu", "roots": { "net": { "dir": "roots/net" }, "a": { "dir": "roots/a" }, "app": { "dir": "roots/app" } } }}import { phase, stackOutput, type Component } from "@intentius/chant/components";
export const net: Component = { name: "net", dependsOn: [], deploy: [phase("Apply", [{ kind: "terraform-apply", root: "net" }])],};
export const a: Component = { name: "a", dependsOn: ["net"], deploy: [phase("Apply", [{ kind: "terraform-apply", root: "a", vars: { cidr: stackOutput("net", "cidr") } }])],};
export const app: Component = { name: "app", dependsOn: ["a"], deploy: [phase("Apply", [{ kind: "terraform-apply", root: "app", vars: { subnet: stackOutput("a", "id") } }])],};A root is changed when a changed file sits in its directory, in a local module it calls, or is one of its var files. A pull request that edits roots/a plans a and app. It does not plan net.
a is still planned against net’s outputs. A dependency the change did not select is read from the deployed estate, through the outputs of its terraform-apply, cfn-deploy or kubectl-apply step, and the apply plans against the same values. So a pull request that changes one cluster of examples/fan-out-estate plans and applies it with network’s outputs, and the workflow needs no seed step. The report’s deployedOutputs and a line of the note name each dependency read and the outputs it gave. --seed-outputs <file> supplies a component’s outputs instead, and wins over a read. A dependency whose steps can’t report outputs leaves its dependents’ references unresolved, and their plans say so.
A dependent of a member the change plans
Section titled “A dependent of a member the change plans”app reads a’s id, and the pull request changes a. The id a has now is not the one app will get, so app is planned against what a’s plan says a will expose. For terraform-apply that is the plan’s planned_values.outputs, less each output output_changes marks unknown after apply. These upstreams are listed under plannedOutputs in the report, with the output names each plan knows.
An output the plan cannot say is known only after apply. A root whose output reads a resource the plan creates or replaces is one. So is every output of a stack that does not exist yet. The dependent is planned without that value. A terraform-apply dependent creates no plan then: its member gets a hole naming the upstream, with ? for its counts. A cfn-deploy dependent is previewed with a stand-in and keeps its changes in the plan. The member lists the reference under unknownInputs, and the note says Known only after apply: app reads a.id, so the reviewer sees which inputs the preview lacked. The apply plans the member again once the upstream applied. When that plan does only what the note showed, with only those inputs filled in, the approval covers it; anything else waits for an approval of its own. A pull request that adds a and app together plans both this way.
Two outcomes for the same pull request, with app previewed as one create:
pr-apply-round-2: covered app plans one create (Queue), as the note showed; a.id was filled in approved digest: jcs1-sha256:9204... no second approval askedpr-apply-round-2: waiting app now plans to create Extra, which the first plan did not new digest: jcs1-sha256:51c7... approve it, then run pr-apply againThe first round is covered: the only difference from the note is the value that was unknown. The second adds a resource the reviewer never saw, so it stops waiting at pr-apply-round-2 and pr-apply exits 3. A member whose first plan was a hole with no preview, for example a stack CloudFormation would not preview, is never covered: the approval did not see what it would do.
pr-apply --resume and --wave-gate make the same decision. A failure part way leaves what applied, applied. pr-apply does not undo finished members when a later one fails, and the report lists each member as applied, failed or blocked.
The record job plans the same way on the merged commit and keeps that plan with the merge. With apply on merge, an apply holds back a member whose upstream applied as another value and asks for a second approval; a dependent that reads an upstream output has the details.
An artifact a build in the same pull request publishes is the exception. A deploy that reads @web-image.publish.digest, or a stackOutput() under publish, from a component the change also builds plans with the digest unknown. The member lists it under buildInputs, and the note says the image digest comes from this pull request’s build. The apply runs that deploy once the build ran, with the digest it produced, and asks for no second approval: the build’s provenance and attestation bind the digest. A deploy that also reads another output known only after apply is still held back for it.
For cfn-deploy, a stack keeps an output when its template Value reads only resources the change set modifies in place. An output whose Value is a plain string is known at that string, whether the string changed or the output is new. An output that is a Ref to a parameter is known at the value the plan gave that parameter, so a port that one stack passes to the next shows as its new value all the way down. An output is known only after apply when it reads a resource the change set adds or replaces, an import or a condition, or a parameter the plan has no value for. A kubectl-apply step has outputs only when it names them, each a field of an object its manifest declares: outputs: { host: { object: "Service/prod/web", field: "status.loadBalancer.ingress.0.hostname" } }. Such a field is known before apply when the manifest sets it, or when the dry run leaves its object unchanged.
Components applied as one
Section titled “Components applied as one”A capability that plans and applies a group (ws-107) takes a and app above in one plan and one apply. terraform-apply declares one with #4447. app reads a.id inside that apply, so it is not held for a round and lists no unknownInputs. The report’s groups names the group, its wave and its digest, and the note says it in one line:
`a` and `app` plan and apply as one (`terraform-apply`, wave 1); `app` reads `a.id`, known when the group applies.A component that could have joined and did not is listed under fallbacks with the reason, and plans wave by wave as above. One approval covers the group. A change set that looks empty while the group has reads it does not know yet waits for a person.
If the group’s apply fails on app after a applied, a stays applied. The report lists a with groupOutcome applied and app with failed, and the note says `a` applied and stays applied; `app` failed. Running the apply job again with the same --resume record plans only app, against the outputs a applied with. When its new plan does only what the approved plan showed, it applies under the first approval. When it does more, the apply plans everything again and waits for an approval of that plan. Groups planned and applied as one lists the report’s fields, and Composed runs says what a capability without a group or a preview gets.
CloudFormation stacks
Section titled “CloudFormation stacks”A component whose step is cfn-deploy is planned with a CloudFormation change set. The plan creates one for the stack’s template and resolved parameters, reads the changes it proposes and deletes it without executing it. The member is named after the stack. An Add counts as a create, a Modify as an update, or as a replace when CloudFormation says Replacement: True or Conditional, and a Remove as a delete. A change set with nothing to apply gives the member no changes. The proposed changes are part of the digest the gate binds, as every planner’s are, so a change set that proposes something else at merge moves the digest and the apply refuses.
An apply plans again before it runs, and each cfn-deploy step then creates the change set it executes. It executes it only when that change set proposes the same changes as the plan the approval covers. When they differ, something moved after the plan was made. The step then deletes the change set without executing it and fails the member with refusing to apply. pr-apply exits 4 for it, as it does when the digest moved. A change set that replaces a resource (Replacement: True) fails the member’s plan when onReplace is "block", which is the default. The refusal names the resources and shows in the pull request’s note. Conditional counts as a replace but is not blocked, which is also the apply’s rule.
A template that declares an AWS::CloudFormation::Stack gets a change set with its nested stacks included, and each change inside a child is an entry of its own, addressed as <child>/<logical id>.
A stack that does not exist yet gets a CREATE change set, so every resource counts as a create. CloudFormation holds that change set in an empty stack in REVIEW_IN_PROGRESS, and the plan deletes that empty stack too. It never deletes a stack in any other status. A dependent reads the outputs the upstream’s plan says it will have, as the section above describes. When one is known only after apply, the plan creates the dependent’s change set with a stand-in for each parameter that reads it, an id-shaped value of the parameter’s type, and deletes it with the empty stack it may have made. The note shows the dependent’s changes, and the properties a stand-in drives are marked known after apply; no stand-in appears as a value. The preview’s digest is part of the member’s digest, so the approval binds what the reviewer saw. Once the upstream applied, the apply makes the real change set. If it matches the preview, the first approval covers it. If it adds, drops or replaces a resource the preview did not show, it is not executed: the round waits at <gate>-round-<n> with the difference named. A template CloudFormation will not preview with stand-ins (a parameter with AllowedValues, for instance) stays a hole: its row says inputs from network; re-checked on apply; no preview: <why>, with ? for its counts, and needs its own approval.
The plan and record jobs need AWS credentials and the region. The credentials must be allowed to create, describe and delete change sets. Deleting a stack needs its own permission. Build the templates before pr-plan and pr-record. Generate the pipeline with --pr-build and both jobs do it for you, as the next section shows.
Kubernetes manifests
Section titled “Kubernetes manifests”For a kubectl-apply step, the plan is a server-side dry run. It reads the manifest, sets the release attributes the apply would set, and sends each document as the apply does, with the same field manager chant:<stack>, but with dryRun=All, so the API server persists nothing. It reads each live object and compares it with what the dry run returned. A step without a stack gives its component’s name to the member; otherwise the member takes the stack’s name.
An object with no live counterpart counts as a create, with the fields the manifest declares. An object whose dry run equals the live object is a no-op, and one that differs is an update naming each changed field with its value before and after. Before comparing, the plan drops what the server writes on every request: managedFields, resourceVersion, uid, creationTimestamp, generation and status. A field the server defaults has the same value on both sides, so it does not show. A Secret’s data and stringData are marked sensitive, and their values are left out of the note and the change set. An update under spec.template of a workload whose pods roll on such a change shows as a rolling change. Every other update shows as in place.
With delete: "owned-only" the plan also lists what the apply’s prune would delete: objects carrying chant’s marker and the step’s stack label, in the namespaces the manifest touches, that the manifest no longer declares. Generated-once Secrets and effect receipts are never in that list, as the prune never deletes them. With the default delete: "never" the plan lists no deletes.
The apply never deletes and recreates an object. A change to an immutable field, such as a Deployment’s spec.selector, is refused by the API server in the dry run as it would be in the apply. The plan shows that object as an update with unknown disruption, and a hole carrying the server’s message, so the note says the apply would fail until someone deletes the object.
The gate’s digest binds the documents sent. For each object it also binds the action and the new value of every changed field. A kubectl-apply step that receives the approved plan dry-runs those documents again before it applies them. If the digest moved, the step fails before the cluster changes, and its message names the approved digest beside the new one. pr-apply exits 4 for it, as for a cfn-deploy change set that moved. A live value that moved under a field the apply sets to the same value does not move the digest.
The plan job needs credentials that can read, list and dry-run apply the manifest’s kinds in the cluster, and resolves the context the same way the apply does: the step’s context, or k8s.profiles.<env>.context.
Other capabilities
Section titled “Other capabilities”cfn-deploy, kubectl-apply, terraform-apply and pulumi-up are the capabilities with plan. pulumi-up plans and applies a Pulumi or plunge stack, and needs no flag of its own in the generated pipeline (#4541). A component whose steps include none of them, such as one that runs helm-upgrade, is a member under its own name with a count of 0 in every column. Its digest covers the component’s declaration and the files its steps deploy from (#4155). Plan previews lists every capability and what the note shows for each, and says what to check for a component that cannot plan.
Generate the pipeline
Section titled “Generate the pipeline”# GitHubchant build --components --generate github --pr-loop --env prod --output .github/workflows/chant-pr.yml# Forgejochant build --components --generate forgejo --pr-loop --env prod --output .forgejo/workflows/chant-pr.yml# GitLabchant build --components --generate gitlab --pr-loop --env prod --output .gitlab-ci.ymlAdd --apply-on-merge for a pipeline whose merge applies the approved plan; apply on merge sets that up. Without it, the job on merge is record.
--gate <name> renames the gate from pr-apply. --branch <name> names the branch pull requests target, main by default on GitHub and Forgejo and the project’s default branch on GitLab.
--pr-build adds two steps to both jobs, before pr-plan and before pr-record: chant build --env <env>, then chant lint. Either one failing fails the job. A project with a cfn-deploy step needs it, because the plan and the apply read the built template and an unbuilt one fails the member. When the templates come from several builds, --pr-build-command '<line>' names the line to run in place of chant build. The estate in examples/fan-out-estate builds one template per stack with npm run build:
chant build --components --generate forgejo --pr-loop --env local \ --pr-build-command 'npm run build' \ --output .forgejo/workflows/chant-pr.ymlThe jobs need chant and the lexicons installed first, through --image or --before-script as below. Without --pr-build the output is unchanged.
Both commands measure the change with git, so the pipeline checks out the full history. The default image is node:22, which has git. The jobs install OpenTofu into it, but not chant. Pick an image that has git, chant and your Terraform binary with --image, or install them with --before-script, which every job runs before its command. With a package.json that pins @intentius/chant and the lexicons the project lists:
chant build --components --generate forgejo --pr-loop --env prod \ --before-script 'npm ci --no-audit --no-fund' \ --before-script 'echo "$PWD/node_modules/.bin" >> "$GITHUB_PATH"' \ --output .forgejo/workflows/chant-pr.ymlOn GitLab, put the node_modules/.bin directory on the path with export PATH="$PWD/node_modules/.bin:$PATH" instead, since a GitLab job’s lines share one shell.
GitHub
Section titled “GitHub”The workflow runs on pull_request and on push to the target branch.
- The
planjob measures fromgithub.event.pull_request.base.sha. It runs the pull request’s code, so its token may only read, and no step that runs that code holds it (keep the forge token from the plan). - After it,
plan-noteruns at the target branch’s commit. Withchant components pr-postit posts the note and thechant/planstatus from the plan’s report, and it keeps the report as thechant-pr-planartifact. Only this job may comment and set statuses. - The
recordjob measures fromgithub.event.before, the commit the push replaced. That works for merge commits, squash merges and rebase merges. On a branch’s first push GitHub sets it to forty zeros, so the job measures from the merge base of the target branch and the pushed commit, or from the pushed commit’s parent when that merge base is the commit itself. A root commit is measured from the empty tree. It may push, to write the merge record and the change set onchant/lifecycle. When another job pushedchant/lifecyclefirst, the record job replays its own commits on the fetched tip and pushes again, up to three pushes in all, as the snapshot store does. The job fails withLifecyclePushLostErrorwhen the last push is refused or when its commits change a file the other job changed. The merge record then stays in the job’s checkout only. One record runs at a time per environment, through the concurrency groupchant-record-<env>.
The note job and the record job use the job’s own github.token. On a pull request from a fork that token is read-only, so the note and the status are not posted. The run says so and its outcome stands.
Forgejo
Section titled “Forgejo”The workflow is the GitHub one with the Forgejo dialect applied: the runner label, action references by URL, and no permissions block, which the Forgejo runner ignores. Its commands pass --forge forgejo, and Forgejo Actions supplies GITHUB_SERVER_URL, GITHUB_API_URL and GITHUB_TOKEN.
GitLab
Section titled “GitLab”The pipeline runs plan in each merge request pipeline, measured from CI_MERGE_REQUEST_DIFF_BASE_SHA. It runs record on each push to the target branch, measured from CI_COMMIT_BEFORE_SHA, which a first push settles as on GitHub, one at a time per environment through resource_group. GIT_DEPTH is 0.
A CI job token cannot write merge request notes. Create a project access token with the api scope and set it as a masked CI/CD variable named CHANT_FORGE_TOKEN. The plan job’s script unsets it before its first line, and the plan-note job posts the note from the plan’s artifact (#4295).
Your own commands around the plan and the apply
Section titled “Your own commands around the plan and the apply”The jobs run the stage hooks in ci.hooks of the workspace declaration at base, before and after the plan and the apply (Hooks on Pull-Request Jobs, #4288).
Approve a plan
Section titled “Approve a plan”The note on the pull request lists each member with its creates, updates, replaces and deletes. The plan digest and the grouped plan summary follow, with every destroy named. The last block is the command that approves this plan:
chant approve pr-12 pr-apply --plan jcs1-sha256:3e43... --approver github:alice --signchant approve records it on chant/lifecycle under the op pr-12, so it answers this pull request and no other. The approval names one digest. A push that changes the plan changes the digest, and the note shows the new one. The merge record later says whether the merged plan is this one. The approval deploys nothing by itself: the release gate decides what a release deploys.
Review rules are opt-in (#4168). The record job keeps any approval by someone who wrote the change under authorApproved in the merge record and refuses nothing. With apply on merge and --require-review on chant build --pr-loop, the generator option requireReview: true, or "security": ["review-rules"] in chant.workspace.json, the apply also asks the forge who approved the pull request. It counts a ledger record only when the person it names has a standing approving review there, named the way the workspace names a forge identity: github:<login>, gitlab:<login>, or forgejo@<host>:<login>. Without one of those the apply counts any approval recorded for the digest. Regenerate the pipeline after turning it on, since the flag is baked into the apply job.
Under the same check, a person who wrote the change never counts. That is the pull request’s author and the author and committer of each of its commits. When the ledger record names one of them, the apply refuses with author-approved and applies nothing. The note names the person. Their review on the forge does not help either. GitHub and Forgejo link each commit to the account its email belongs to. GitLab gives commits by email only, so chant looks each email up among the GitLab users, which finds an account by its public email. A committer whose email no GitLab account shows publicly is not found, so on GitLab also turn on “Prevent approvals by users who add commits” in the project’s merge request approval settings.
To count only signed approvals, list the gate in the workspace declaration. An approval then has to be sealed with --sign by a key the signers file at base lists for its approver:
"identity": { "gates": { "pr-apply": { "class": "human" } }}When the plan changed after review
Section titled “When the plan changed after review”The record job plans every member on the merged commit before it writes anything. When an approval stands for another digest, something moved between review and merge: a later commit, a merge that touched the same root, or a change in the live state. The record job still writes the merge record, with plan: "changed" and the approved digest beside the new one, and exits 0. Nothing applies, so the merge stands. The chant/record commit status fails, and the note names both digests (#4168, decision 1).
Read the new plan in .chant/pr/pr-record.json, which the job keeps as an artifact. The release gate reads the change set a release deploys and decides on it, so a moved plan is caught again before anything ships.
A component whose steps have no plan, such as a helm-upgrade, is bound by the files it deploys from as well as its declaration (#4155). A chart edited after the approval moves the digest the same way, and so does a function’s source beside a cfn-deploy. Plan previews lists the fields read and the steps the digest can’t bind.
What each run keeps
Section titled “What each run keeps”Each job keeps .chant/pr as an artifact. On GitHub and Forgejo the plan job hands it to the plan-note job as job outputs, and the note job keeps it, since no step may follow the plan’s (#4295):
| File | Holds |
|---|---|
pr-plan.json, pr-record.json | The report: the selection, every member’s plan digest and counts, the digest the gate binds, where the approval stands and how the run ended. It follows the pr-report schema in the workspace read contract. |
change-set.json | The change-set document over every member. chant change-set summary prints its grouped summary. |
pr-note.md | The note as the plan rendered it. The note job renders it again from the report before it posts. |
run-events/<run id>.jsonl | With --events-json: the stage’s run events, the lines it printed on stdout. |
The merge record goes to _merges/<commit>.json on chant/lifecycle, keyed by the merged commit. Its fields follow the merge-record schema, and chant components pr-record lists them. The change set itself is stored under _change-sets/.
Each job also records its run as Op pr-plan or pr-record in <env>/runs__<op>.jsonl on chant/lifecycle. The record’s runOrigin names the forge’s run, job and attempt. The record job pushes it with the merge record. The plan runs the pull request’s code, so it passes --no-push and its record stays in the job. chant ci list --source runs and chant ci tick --source runs read the records, and with --report-url each job is added to the run index as well.
Who ran a job
Section titled “Who ran a job”A run record is unsigned by default, and an unsigned record counts. To verify who ran a job, add a runner key. Each record is then signed with it, and ci list shows the signer.
-
Make an Ed25519 key, and list its public half under
runnersin.chant/trust.jsonwith therunnerrole:Terminal window openssl genpkey -algorithm ed25519 -out runner.pemchant workspace trust runner add ci:acme/estate --key runner.pem --by github:alexgit commit -am "trust: the CI runner key"Merge that commit through review. A record is checked against
.chant/trust.jsonat the commit the job runs. -
Store the contents of
runner.pemon the forge asCHANT_RUNNER_KEY, then delete the file. On GitHub and Forgejo it is a repository secret, which the generated jobs pass tochant ci run. On GitLab it is a CI/CD variable, which GitLab gives every job. Mark it protected, so only the job on the target branch gets it. GitLab can’t mask a value that spans lines.
Without the secret, or with a key .chant/trust.json does not list, the job runs as before and its record is unsigned, with no warning. chant ci run withholds the key from the command’s environment. The plan job still runs the pull request’s code with the key in its own job, so on GitHub a pull request from a fork gets no secret, and a signed plan record says only that a job holding the key ran.
To require signatures, set ci.green.signedSince. An unsigned run on that commit or after it then doesn’t count, and chant ci run warns when it leaves a run unsigned.
Run a job without a forge runner
Section titled “Run a job without a forge runner”chant ci run plan and chant ci run record run the same two jobs on your own machine, each in a fresh worktree of the commit with a clean environment (#4094). Give them the generation flags and the values the forge would supply: --base for the base commit, --pr for the pull request and --commit for the commit to run. Each run is recorded as Op pr-plan or pr-record on chant/lifecycle, as a forge job’s is, and signed when you pass a runner key, so chant ci tick --source runs can tag the commit green. chant ci run lists the flags and the variables a job gets.
chant ci serve runs both jobs from the forge’s state, with no workflow file and no forge runner (#4095). It polls the forge for open pull requests and the target branch’s head, plans each new pull request head and records each new commit on the branch. After each job settles it runs chant ci tick from the runs its jobs recorded, when the workspace declares ci.green, so a merged commit can go green with no other workflow. --apply-on-merge has it apply each new commit instead (apply on merge). Jobs run on its host as its user, so serve only repositories whose pull request authors you trust. chant ci serve lists its flags and what it keeps.
Both commands take the values a forge job reads from repository secrets from a file on the host, --secrets <file> or the file CHANT_CI_SECRETS names, which must be readable by its owner alone (#4096). Its values read *** wherever chant writes about the run, in the events and the signed record as much as in the copied report and the console. See Secrets for the format and the allowlist.
Follow a run
Section titled “Follow a run”Generate the pipeline with --events-json to have both jobs print the run-event stream on stdout. The jobs also set CHANT_RUN_EVENTS_DIR to .chant/pr/run-events, so the report artifact carries the stream too.
Add --report-url <url> to have each job copy its report and change set to <url>/<pr>/<commit>/. The events go there as well. A viewer such as behold reads the run from there after the job is gone. The generator options are events: true and reportUrl.
chant build --components --generate github --pr-loop --env prod \ --events-json --report-url 's3://acme-chant-reports/prod' \ --output .github/workflows/chant-pr.ymlA workspace can declare the URL once as ci.reportUrl instead (#4160). chant build --pr-loop then writes it into the jobs without --report-url, and chant ci run, ci serve and ci runs use it too. A reader finds it in chant workspace ls --json. --report-url still wins when given.
The AWS CLI uploads to an s3:// URL with the credentials in the job’s environment. Give the jobs an identity that can write only that prefix. The URL is passed in double quotes, so $CHANT_REPORT_URL names a CI variable the job expands. Pull request reports gives the layout.
Inside a workspace member
Section titled “Inside a workspace member”Run the same command in a member of a workspace and the pipeline belongs to that member. Each member that wants the loop generates its own, and each runs on the same pull request without touching the others:
cd infra/networkchant build --components --generate github --pr-loop --env prod# wrote .github/workflows/chant-pr.network.prod.yml for member networkThe jobs run in the member’s directory, so .chant/pr and every path in chant.config.ts read from there. The report artifact is kept from <member dir>/.chant/pr. On GitLab the file is .gitlab/ci/chant-pr.<member>.<env>.gitlab-ci.yml, its jobs are <member>-plan and <member>-record, and each script starts with cd <member dir>.
A member’s record is serialized per environment by the concurrency group (GitLab: resource group) chant-record.<member>.<env>. A member name has no ., so no two members’ groups meet: member a in environment b-c and member a-b in environment c record side by side. The merge record goes under _members/<member>/_merges/.
chant ci run finds the member from the directory it runs in and passes --member <name> to pr-plan and pr-record. The member’s gate is recorded under pr-<number>-<member>, its note carries the member’s name, and its statuses are chant/plan/<member> and chant/record/<member>. A reviewer approves each member’s plan on its own:
chant approve pr-42-network pr-apply --plan <digest> --approver github:<login> --signThe gate name stays pr-apply, so one identity.gates entry covers every member.
The pipeline has no path filter. The plan measures the whole change, not only the files under the member, so a change outside the member that reaches one of its units selects it. A Terraform root that calls ../../modules/vpc, a module another member keeps, is planned when that module changes. A member the change does not reach reports nothing.