Skip to content

Getting Started

llms.txt lists every page for an agent
Optional: hand this page to your coding agentThe steps work by hand too.
Show the whole prompt
Read https://intentius.io/chant/lexicons/prow/getting-started/.
Install `@intentius/chant-lexicon-prow`, import this repository's Prow job config with `npx chant import <file> -o src`, then run `npx chant build src --lexicon prow` and show me the diff against the file imported.
Run `npx chant lint src` and report each PROW finding with the job it names.
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`.

Install the lexicon beside chant:

Terminal window
npm install --save-dev @intentius/chant @intentius/chant-lexicon-prow

Each job is a Presubmit, a Postsubmit or a Periodic, with Prow’s own field names. A presubmit or postsubmit names its repository with repo, as owner/name. That is the key the job config lists the job under, so the built job does not carry it. A periodic has no repository of its own; name the repositories it clones with extra_refs.

src/jobs.ts
import { JobConfig, Periodic, PodSpec, Postsubmit, Presubmit, Refs } from "@intentius/chant-lexicon-prow";
const image = "golang:1.26";
export const jobs = [
new JobConfig({ header: "# Written by chant build from src/jobs.ts." }),
new Presubmit({
repo: "acme/app",
name: "pull-app-unit",
cluster: "untrusted",
always_run: true,
decorate: true,
branches: ["^main$"],
spec: new PodSpec({
automountServiceAccountToken: false,
containers: [{ name: "test", image, command: ["go"], args: ["test", "./..."] }],
}),
}),
new Postsubmit({
repo: "acme/app",
name: "post-app-publish",
cluster: "trusted",
decorate: true,
max_concurrency: 1,
branches: ["^main$"],
spec: new PodSpec({
serviceAccountName: "publisher",
containers: [{ name: "publish", image, command: ["make"], args: ["publish"] }],
}),
}),
new Periodic({
name: "periodic-app-e2e",
cluster: "trusted",
cron: "0 3 * * *",
decorate: true,
extra_refs: [new Refs({ org: "acme", repo: "app", base_ref: "main", workdir: true })],
spec: new PodSpec({
serviceAccountName: "e2e",
containers: [{ name: "e2e", image, command: ["make"], args: ["e2e"] }],
}),
}),
];

chant reads a module’s exports in name order, and an exported array’s elements in their order. Export the jobs in one array when their order in the file matters to you, as above. A job with no name takes its export’s name.

Terminal window
npx chant build src --lexicon prow -o prow/jobs.yaml

The file starts with the JobConfig header as comment lines. Below it, presubmits and postsubmits are keyed by repository, and periodics is a list. Point Prow’s job_config_path at it, or copy it into the repository that holds your installation’s job config.

Write one repository’s jobs from plain data

Section titled “Write one repository’s jobs from plain data”

A product that writes jobs as data, rather than declaring them, can still get the file chant would build. forgeJobConfig takes the forge and the repository’s owner/name, as a workspace with ci.forge: github and ci.system: prow names them. The presubmits and postsubmits go under that repository:

import { forgeJobConfig } from "@intentius/chant-lexicon-prow";
const text = forgeJobConfig(
{ forge: "github", repo: "acme/app" },
{ presubmits: [{ name: "pull-app-unit", always_run: true, spec }], periodics: [] },
{ header: "Written by acme's own generator." },
);

It writes through the same emitter as chant build. Prow runs jobs for GitHub repositories, so another forge is refused. A repository that is not owner/name is refused too.

Generate chant’s pipeline jobs as Prow jobs

Section titled “Generate chant’s pipeline jobs as Prow jobs”

chant build --components --generate prow writes the jobs chant generates for a component project as a Prow job config, as --generate github writes them as a GitHub Actions workflow. The jobs are keyed by the repository’s owner/name. It comes from --repo, or else from the checkout’s origin remote:

Terminal window
npx chant build --components --generate prow --env prod --pr-loop --apply-on-merge -o prow/chant-prod.yaml

Each job becomes the Prow job of the matching kind. A presubmit runs a pull request’s code, so no job that holds a credential is one:

GitHub jobProw job
The deploy pipeline’s job per component, and the promote jobOne postsubmit that runs the components in dependency order, then the promote
The gated-wave jobs (--wave-gate)One postsubmit that runs the waves in order
plan (--pr-loop)A presubmit with no credential. Its note and status stay in the report it keeps in its artifacts, and Prow reports its result on the pull request
check (--check-job)A presubmit with no credential
record, and apply with --apply-on-mergePostsubmits; a gate per wave runs the waves in order in the apply
stale-notes (--stale-notes)A postsubmit
A scheduled Op (chant run --generate prow)A periodic for a cron, a postsubmit for a push, and a presubmit with no credential for a pull request, all in one file

Presubmits run on the build cluster untrusted. They hold no Secret and mount no service account token. Postsubmits and periodics run on trusted. They read the GitHub token from the Secret chant-github-token (key token), and CHANT_RUNNER_KEY from chant-runner-key when it exists. The prow generator option moves the clusters and the Secrets. It also names the service accounts the cluster binds to a cloud identity. The jobs read Prow’s own variables, such as PULL_BASE_SHA and PULL_NUMBER, and each keeps its report in $ARTIFACTS. Every PROW rule passes on the output, and PROW104 and PROW105 report nothing.

A job that GitHub runs with a credential while a pull request is open has no Prow form, since on Prow it would be a presubmit that holds one. The build refuses the option that adds it by name. Generate those jobs for GitHub Actions.

Refused on ProwWhy
--apply-before-mergeThe apply would run the pull request’s head with the apply credentials
--preview-commentIts note job holds the token, and Prow starts no job after a presubmit
--action-jobA comment starts only presubmits on Prow, and the action holds a credential
ci.locks: planThe lock jobs hold the token, after the plan and on a close, and Prow has neither trigger
--pr-envenv-up applies the pull request’s own code with the environment’s credentials
--ref-gate-statusIt sets a status with the token while the pull request is open
The evidence flagsSigning takes the runner key after the pull request’s code ran
--controlThe control repo’s token is a repository secret this generator does not map yet
ci.identity.cloudA Prow job has no OIDC token to trade; name a service account in the prow option

A rerun from Deck starts a held wave’s postsubmit again from the first wave.

Terminal window
npx chant import prow/jobs.yaml -o src

The import writes one main.ts with a declaration per job. Each keeps its fields in the order the file has them, and one exported array keeps the jobs in file order. The comment lines the file starts with become a JobConfig header. Building the import writes a job config with the same data, and the same bytes for a file chant wrote.

Terminal window
npx chant lint src

Four rules flag what Prow’s config loader refuses. PROW101 is a duplicated job name and PROW102 a periodic without exactly one schedule. PROW103 is a kubernetes job without a pod spec, and PROW106 is always_run beside a change filter. PROW104 and PROW105 are warnings about credentials and pull request code: a presubmit whose pod reads a Secret, and a presubmit on a build cluster where other jobs hold a Secret or a cloud identity. PROW001 flags a credential written into a job’s environment in source.

chant