Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This file records changes to what chant prints or writes for a plain project, th
## Unreleased

- [#5167](https://github.com/INTENTIUS/chant/issues/5167) Two publish targets. `pypi` uploads wheels and sdists (a file, a directory, or `artifact:<name>`) to PyPI, TestPyPI or another index with PyPI's upload API, with a token or PyPI's trusted publishing, and uploads the PEP 740 attestations beside each file; with Sigstore signing on and trusted publishing, the stage signs a publish attestation for each file. `cargo` runs `cargo publish --no-verify --allow-dirty` per crate of a workspace in dependency order, to crates.io or a named registry, with a token or crates.io's trusted publishing. Neither registry has a draft, so each stage only checks what the index already holds and each reveal uploads; a reveal run again sends nothing the index has. Under `supply-chain` a wheel without an SBOM in `.dist-info/sboms/`, and any cargo target, is refused unless `sbom: false`. `chant release doctor` checks both. A `PublishTarget` may say `uploadsAtReveal`, which the marketplace target now does. Floors `PUBLISH_PYPI_FLOOR` and `PUBLISH_CARGO_FLOOR`.
- [#5189](https://github.com/INTENTIUS/chant/issues/5189) `chant build --components --generate prow` writes the jobs chant generates for a component project as a Prow job config, and `chant run --generate prow` writes the scheduled Ops to one. The jobs are keyed by the GitHub repository's `owner/name`. It comes from `--repo`, or else from the checkout's origin remote. Each job is the Prow job of the matching kind. The pull request plan and the check job are presubmits with no credential on the build cluster `untrusted`. The record and the apply on merge are postsubmits on `trusted` that read the GitHub token from the Secret `chant-github-token`. So are the stale-notes job and the deploy and gated-wave pipelines. A scheduled Op on a cron is a periodic, and one on a push or a pull request is a postsubmit or a presubmit. No job that holds a credential is a presubmit, so the output has no PROW104 or PROW105 finding. The options that would add such a job are refused by name, `--apply-before-merge` and `ci.identity.cloud` among them. The generator's `prow` option moves the clusters and the Secrets and names the service accounts. Prow's strict config loader takes what it writes. The floors are the prow lexicon's `PROW_LEXICON_FLOOR` and core's `FORGE_CI_FLOOR`. Level 0 is unaffected: no other generator's output changes.
- [#5170](https://github.com/INTENTIUS/chant/issues/5170) The forge and the CI system are named apart. `chant.workspace.json` takes `ci.forge` and `ci.system`, and an environment's executor in `chant.config.ts` takes `ci`. The CI system defaults to the forge's own. So `github` still means GitHub with GitHub Actions, and a config that names only the forge builds what it built before. `prow` pairs with `github` only. A Prow job's forge reads take the GitHub repository and pull request from Prow's own variables when the job sets no `GITHUB_*` ones. With `ci.system` set, `chant build --components --generate` refuses another CI system's lexicon. The types and `resolveForgeCi` are in `@intentius/chant/ci-system`, whose `FORGE_CI_FLOOR` marks the release. The prow lexicon's `forgeJobConfig` keys one repository's jobs by its `owner/name`. Level 0 is unaffected: a config without the new fields reads and builds as before.
- [#5153](https://github.com/INTENTIUS/chant/issues/5153) A `forge` publish target's `notes` take `generate: "forge" | "commits"` and `types`. `commits` lists the conventional commits in the member's directory since its previous release, grouped under breaking changes, features, fixes and other changes, filtered by `types` (default `feat`, `fix`, `perf`; a breaking change always, `*` for every commit). `forge` asks GitHub's `generate-notes` or GitLab's changelog API, and Forgejo refuses it with `publish-forge-notes-unsupported`. Generated notes follow the file's section and sit between `before` and `after`, and `file` with `heading` is now optional when `generate` is set. The stage decides the notes and keeps them in the publish record: a draft is created with them or edited to them, and the reveal publishes the recorded notes. A shallow checkout is refused with `publish-forge-notes-history`. A declaration without `generate` publishes the same notes as before. Floor `PUBLISH_FORGE_GENERATED_NOTES_FLOOR`.
- [#5169](https://github.com/INTENTIUS/chant/issues/5169) A new `prow` lexicon, `@intentius/chant-lexicon-prow`, declares Prow presubmits, postsubmits and periodics. `chant build` writes the job config Prow loads, and `chant import` reads one into declarations that build the same file. Its types come from sigs.k8s.io/prow at a pinned commit. Four of its rules catch what Prow's config loader refuses (PROW101 to PROW103 and PROW106). PROW104 and PROW105 warn when a presubmit reads a Secret or runs on a build cluster where jobs hold credentials. PROW001 flags a credential written into a job's environment.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/ci/your-forge.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ diataxis: reference

Each forge above runs its jobs on its own CI: GitHub Actions, GitLab CI or Forgejo Actions. A GitHub repository can run its jobs on Prow instead ([#5170](https://github.com/INTENTIUS/chant/issues/5170)). Name the two apart with `"ci": { "forge": "github", "system": "prow" }` in `chant.workspace.json` ([forge and CI system](/chant/reference/workspace-declaration/#forge-and-ci-system)). An environment's executor in `chant.config.ts` takes `ci` the same way ([the workflow that deploys an environment](/chant/configuration/config-file/#the-workflow-that-deploys-an-environment)).

GitHub is still the forge, so the plan note and the commit status go to GitHub with the job's token, a Secret the job mounts as `GITHUB_TOKEN`. In a Prow job chant takes the pull request from Prow's own variables when the job sets no `GITHUB_*` ones. The jobs themselves are the [prow lexicon's](/chant/lexicons/prow/getting-started/), declared or written with `forgeJobConfig`. `chant build --components --generate prow` does not generate them from components yet.
GitHub is still the forge, so the plan note and the commit status go to GitHub with the job's token, a Secret the job mounts as `GITHUB_TOKEN`. In a Prow job chant takes the pull request from Prow's own variables when the job sets no `GITHUB_*` ones. The jobs themselves are the [prow lexicon's](/chant/lexicons/prow/getting-started/). Declare them, or write them from plain data with `forgeJobConfig`. `chant build --components --generate prow` generates them from components ([Prow job config](/chant/cli/build/#prow-job-config), [#5189](https://github.com/INTENTIUS/chant/issues/5189)).

## The chant runner on your own host

Expand Down
39 changes: 38 additions & 1 deletion docs/src/content/docs/cli/build.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ It reaches no network. Every schema it needs is generated into the lexicon packa
| `--params-file <path>` | `string` | — | JSON file of `{ "name": value }` build-time parameter values; second precedence, after `--param` |
| `--env <name>` | `string` | — | Active environment. Sets `CHANT_ENV` so env-aware source re-evaluates for that environment, and selects the organizational policy that applies. Must be declared under `environments` in `chant.config.ts` when that list exists |
| `--components --generate <lexicon>` | `string` | — | Generate mode. Synthesize a CI pipeline from the discovered `*.component.ts` declarations instead of running a lexicon build. See [Generate mode](#generate-mode-ci-pipelines-from-components) |
| `--repo <owner/name>` | `string` | origin remote | With `--generate prow`. The GitHub repository the Prow jobs are keyed by. Without it, the `owner/name` the checkout's origin remote names. See [Prow job config](#prow-job-config) |
| `--allow-skip` | `boolean` | `false` | With `--promote-to`. Let the promote job skip a step of the member's [promotion order](/chant/cli/components/#the-promotion-order). The generated job runs `promote` with `--allow-skip`. |
| `--promote-to <env>` | `string` | — | Generate mode only. Add a job that promotes the deployed releases to `<env>` after every component job succeeds. Without `--components --generate <lexicon>` the command fails rather than ignoring the flag. See [Promote job](#promote-job) |
| `--merge auto --merge-token-env <VAR>` | `string` | `manual` | With `--pr-loop --apply-before-merge`. The generated apply job runs `pr-apply --before-merge --merge auto --merge-token-env <VAR>` and merges the pull request once its update applied, with the token in `<VAR>` alone. `--merge-method merge\|squash\|rebase` picks the merge. See [Pull-request pipeline](#pull-request-pipeline) |
Expand Down Expand Up @@ -145,7 +146,7 @@ The `--sandbox` flag always wins over `build.sandbox` when both are present.

## Generate mode: CI pipelines from components

`--components --generate <lexicon>` switches the build to the component discovery path. It reads every `*.component.ts` under the path, orders them by `dependsOn` into waves, and asks the named lexicon's `generateComponentPipeline` to render those waves as CI stages and jobs. The github, gitlab and forgejo lexicons implement it; naming any other lexicon fails with a message saying so.
`--components --generate <lexicon>` switches the build to the component discovery path. It reads every `*.component.ts` under the path and orders them by `dependsOn` into waves. Then the named lexicon's `generateComponentPipeline` renders those waves as CI stages and jobs. The forge lexicons implement it for GitHub Actions, GitLab CI and Forgejo Actions. The prow lexicon implements it too, and writes a [Prow job config](#prow-job-config). Naming any other lexicon fails with a message saying so.

A component whose `enabled` is `false` under the bound parameters gets no job, and no other job needs it. These are the components [`chant run --components all`](/chant/cli/run/#run---components-nameallabc) runs, and a component that depends on a disabled one keeps its job with that dependency dropped.

Expand Down Expand Up @@ -224,6 +225,7 @@ Without `--output` the pipeline is written to the forge's directory at the repos
| `github` | `.github/workflows/chant-<member>-<env>.yml` |
| `forgejo` | `.forgejo/workflows/chant-<member>-<env>.yml` |
| `gitlab` | `.gitlab/ci/chant-<member>-<env>.gitlab-ci.yml`, which the root `.gitlab-ci.yml` includes with `include: local: .gitlab/ci/*.gitlab-ci.yml` |
| `prow` | `prow/chant-<member>-<env>.yaml`, a job config for the installation's `job_config_path` |

Its first line is chant's generated-file marker. The marker names the command that rewrites the file, which runs in the member's directory. The member lists the file in `.chant/generated.json` in its own directory, and each entry holds that command and the environment. This list is interim, and moves into the member's `generated` list in `chant.workspace.json` with [#2541](https://github.com/INTENTIUS/chant/issues/2541). Forge files at the repository root are the one kind of generated file a member may own outside its own directory, and only one member may own each of them.

Expand All @@ -242,6 +244,41 @@ chant build --components --generate github --env staging --output .github/workfl
chant run --generate github
```

### Prow job config

`--generate prow` writes the same jobs as a Prow job config for a GitHub repository whose CI is Prow ([#5189](https://github.com/INTENTIUS/chant/issues/5189)). A workspace names one with `ci.forge: github` and `ci.system: prow` ([forge and CI system](/chant/reference/workspace-declaration/#forge-and-ci-system)). The presubmits and postsubmits are keyed by the repository's `owner/name`. `--repo` names it, and without the flag chant reads the checkout's origin remote. Each job is the Prow job of the matching kind:

| Generated for GitHub | On Prow |
|---|---|
| One job per component, and the promote job | One postsubmit that runs the components in dependency order, each seeding from its dependencies' outputs, then the promote with each recorded digest |
| One job per wave (`--wave-gate`) | One postsubmit that runs the waves in order. A held wave stops it; rerun it from Deck once the wave is approved |
| `plan` (`--pr-loop`) | A presubmit with no credential. It writes its note and status into its report, which it keeps in `$ARTIFACTS`, and Prow reports its result on the pull request |
| `check` (`--check-job`) | A presubmit with no credential |
| `record`, and `apply` with `--apply-on-merge` | Postsubmits. With `--wave-gate` the apply runs the waves in order on the commit wave 1 took |
| `stale-notes` (`--stale-notes`) | A postsubmit |

A presubmit runs the pull request's code. So it runs on the build cluster `untrusted` and holds no Secret. It mounts no service account token either. Postsubmits run on `trusted`. They read `GITHUB_TOKEN` from the Secret `chant-github-token` (key `token`), and `CHANT_RUNNER_KEY` from `chant-runner-key` when that Secret exists. The generator's `prow` option moves the clusters and the Secrets. It also names the service accounts the record and the apply run as. The jobs read Prow's own variables, such as `PULL_BASE_SHA` and `PULL_NUMBER`. The output passes the [prow lexicon's](/chant/lexicons/prow/getting-started/) PROW rules with no PROW104 or PROW105 finding.

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

| Refused on Prow | Why |
|---|---|
| `--apply-before-merge` | The apply would run the pull request's head with the apply credentials |
| `--preview-comment` | Its note job holds the token, and Prow starts no job after a presubmit |
| `--action-job` | A comment starts only presubmits on Prow, and the action holds a credential |
| `ci.locks: plan` | The lock jobs hold the token, after the plan and on a close, and Prow has neither trigger |
| `--pr-env` | `env-up` applies the pull request's own code with the environment's credentials |
| `--ref-gate-status` | It sets a status with the token while the pull request is open |
| The evidence flags | Signing takes the runner key after the pull request's code ran |
| `--control` | The control repo's token is a repository secret this generator does not map yet |
| `ci.identity.cloud` | A Prow job has no OIDC token to trade; name a service account in the `prow` option |

```bash
chant build --components --generate prow --env prod --pr-loop --apply-on-merge --repo acme/app --output prow/chant-prod.yaml
```

`chant run --generate prow` writes the scheduled Ops to one job config, `prow/chant-ops.yaml`. A cron is a periodic and a push a postsubmit. An Op on a pull request is a presubmit with no credential.

## Build-time parameters

## One file per lexicon
Expand Down
6 changes: 3 additions & 3 deletions docs/src/content/docs/cli/run.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ On a successful run, `chant run --components` auto-emits one immutable release r

### `run --generate <provider>`

Writes one CI pipeline file per scheduled Op for `github`, `gitlab` or `forgejo`. A `--spec` file that holds an Op waves spec (a `waves` key) renders one pipeline of gated waves instead; see [Op Waves](/chant/guide/op-waves/). It is the Op counterpart to [`chant build --components --generate`](/chant/cli/build/#generate-mode-ci-pipelines-from-components), and the command-line form of `generateOpsPipeline` from `@intentius/chant/op`. The [Ops guide](/chant/guide/ops/#scheduling-an-op) covers what each provider's generator emits.
Writes one CI pipeline file per scheduled Op for `github`, `gitlab` or `forgejo`. For `prow` it writes one job config. A `--spec` file that holds an Op waves spec (a `waves` key) renders one pipeline of gated waves instead; see [Op Waves](/chant/guide/op-waves/). It is the Op counterpart to [`chant build --components --generate`](/chant/cli/build/#generate-mode-ci-pipelines-from-components), and the command-line form of `generateOpsPipeline` from `@intentius/chant/op`. The [Ops guide](/chant/guide/ops/#scheduling-an-op) covers what each provider's generator emits.

```bash
chant run --generate github
Expand All @@ -413,7 +413,7 @@ Each file is written exactly as `generateOpsPipeline` returns it, with one line
# Generated by chant — do not edit directly. Regenerate with: chant run --generate github
```

That line is the generated-file marker chant uses elsewhere, and it names the command, `--spec` included, that rewrites the file. Run the command from the repository root. GitHub files go to `.github/workflows/` and Forgejo files to `.forgejo/workflows/`, each with a `name:` that is its Op's name, so the Actions tab lists workflows by Op. GitLab's single `ops.gitlab-ci.yml` (one job per Op) to the root, where the project's `.gitlab-ci.yml` includes it. `--output <dir>` writes somewhere else. `--format json` prints `{ files: [{ name, path, content }], jobs }` and writes nothing. An unknown Op name, a provider with no Op generator, or no scheduled Op and no `--spec` exits 1.
That line is the generated-file marker chant uses elsewhere, and it names the command, `--spec` included, that rewrites the file. Run the command from the repository root. GitHub files go to `.github/workflows/` and Forgejo files to `.forgejo/workflows/`, each with a `name:` that is its Op's name, so the Actions tab lists workflows by Op. GitLab's single `ops.gitlab-ci.yml` (one job per Op) to the root, where the project's `.gitlab-ci.yml` includes it. Prow's single `prow/chant-ops.yaml` holds a job per Op ([Prow job config](/chant/cli/build/#prow-job-config), [#5189](https://github.com/INTENTIUS/chant/issues/5189)). It is keyed by the GitHub repository's `owner/name`. That comes from the spec's `forgeRepo` option or `--repo`, and else from the checkout's origin remote. A cron is a periodic and a push a postsubmit. An Op on a pull request is a presubmit with no credential. An Op that needs what a Prow job cannot carry is refused by name, such as one with an agent or a cloud trade. `--output <dir>` writes somewhere else. `--format json` prints `{ files: [{ name, path, content }], jobs }` and writes nothing. An unknown Op name, a provider with no Op generator, or no scheduled Op and no `--spec` exits 1.

#### Inside a workspace member

Expand Down Expand Up @@ -485,7 +485,7 @@ A run without `--release` writes records with no `releaseDigest`, even when `HEA
| `--local` | Run with the local in-process executor — the default (`run <name>`, `run --components`) |
| `--on <lexicon>` | Which runtime hosts the run: a configured lexicon with an `opRuntime`, or `local`. When omitted, `run.on` in `chant.config.ts` decides, and the built-in local runtime runs the Op when that is unset too (every `run` subcommand) |
| `--components` | Target a component instead of an Op (`run --components`) |
| `--generate <provider>` | Write one CI pipeline file per scheduled Op for `github`, `gitlab` or `forgejo` (`run --generate`) |
| `--generate <provider>` | Write one CI pipeline file per scheduled Op for `github`, `gitlab` or `forgejo` (`run --generate`). For `prow`, one job config |
| `--spec <file>` | JSON Op specs to generate instead of every Op with a `schedule` (`run --generate`), or the Op waves spec (`run --generate`, `run wave`) |
| `--wave <k>` | The wave to run, from 1 (`run wave`) |
| `--decide` | Plan the wave and decide its gate without applying it (`run wave`) |
Expand Down
Loading
Loading