ModernCI
Sign in

Docs · Configure

Configuring checks: .ci/*.yaml

Checks live in your repo, next to the code they check, and change through pull requests like any other file. One file per target branch:

FileWhat it holds
.ci/<target>.yamlThe checks for PRs into that branch (.ci/dev.yaml, .ci/main.yaml).
.ci/repo.yamlThe few repo-level keys that live in the repo.

Your editor can validate and complete these files. Add this as the first line:

# yaml-language-server: $schema=https://modernci.dev/schema/ci.json

The schema is published as crates/mci-config/schema/ci.schema.json (branch files) and repo.schema.json (.ci/repo.yaml). The loader is stricter than any editor: it refuses unknown keys and names the file and line.

The smallest file

# .ci/dev.yaml
checks:
  test:
    run: make test

Every key under a check except run is optional. A check is a command; it passes when it exits 0.

What a file may contain

KeyMeaning
checksThe checks, by name, in the order shown to people.
setupCommands every check runs first (see below).
envEnvironment for every check. Names starting MODERNCI_ are reserved.
toolchainPinned tool versions, for example rust: "1.98.0".
promotesMarks a promotion file; see Promotion targets.

Anything else is an error: .ci/dev.yaml:4: unknown key retries``.

What is not here

Who may approve, which paths are guarded, budgets, compute, secrets, webhooks and which branches are judged are ModernCI settings, changed by a person in the repo's settings. They are never read from a file in the repo, because anyone who can push a branch could then change how your CI runs. A file that contains one (guard, budget, compute, targets, webhook, shadow, and so on) is refused with a message pointing at settings.

Check keys

KeyDefaultMeaning
runrequiredThe command line.
setupthe file's setupCommands to run first instead of the file's, or false for none.
inputswhole treeGlobs of the only files the check reads.
toolsnoneTools the check needs, name to version.
needsnoneChecks that must pass before this one starts.
shards1Split across 1 to 32 machines.
classgategate, after or release.
onfrom classpr (gate checks) or landed (after and release). on: landed alone makes a release step.
publishnoneRelease steps only: what the release publishes (see Release steps).
stage1Pre-check stage, 1 to 9 (gate checks only).
queue_onlyfalseRun only in the merge queue (gate checks only).
requiredtruefalse makes a red advisory.
timeoutnone90, 45s, 30m, 1h30m; at most 24 hours.
testsnoneTest report format: nextest, libtest or junit.
envnoneEnvironment on top of the file's env.

Check names are lowercase letters, digits, -, _ and ., up to 64 characters. @ is reserved for shards.

Shared setup

Put commands every check needs first in setup:. They run before each check's run, in the same shell, and the first one that fails fails the check. A check can run its own list instead, or none.

# .ci/dev.yaml
env:
  CARGO_HOME: ${cache}/cargo
setup:
  - cargo fetch --locked
checks:
  test:
    run: cargo test --locked
  docs:
    run: ./tools/lint-docs
    setup: false
  wasm:
    run: cargo build --target wasm32-unknown-unknown
    setup: [rustup target add wasm32-unknown-unknown]

A check's setup is part of what its result depends on: editing setup: re-runs only the checks that run it.

Narrow what a check reads: inputs

By default a check's result is reused only when the whole tree is identical. If a check only reads some files, say so:

# .ci/dev.yaml
checks:
  fmt:
    run: cargo fmt --check
    inputs: ["**/*.rs", Cargo.toml, rustfmt.toml]
  docs:
    run: ./tools/lint-docs
    inputs: ["docs/**", "tools/lint-docs"]

The check then runs in a sparse, read-only checkout of just those paths, and its result is reused on every commit where those files are unchanged. A read outside the list fails to find the file, so the check goes red; it cannot pass by accident. When a red looks like that, the log excerpt says "possibly an undeclared input". Globs are repo-relative, with no ...

Changing inputs is a gate change (below).

Order and stages: needs, stage

needs: [build] starts a check only after build passes. A gate check can only need gate checks; after and release checks can need gates and each other. Loops and unknown names are errors.

On a PR's pre-check, checks run in stages so cheap failures arrive first:

# .ci/dev.yaml
checks:
  fmt:
    run: cargo fmt --check
    stage: 1
  clippy:
    run: cargo clippy --locked -- -D warnings
    stage: 1
  test:
    run: cargo test --locked
    stage: 2
    needs: [clippy]

Everything in a stage runs, so all of that stage's reds arrive together; the next stage starts when the earlier ones pass. A check cannot need a check in a later stage. The merge queue runs every gate at once and ignores stages, to land as fast as possible.

Merge-queue-only checks: queue_only

Slow or expensive checks can skip the PR pre-check and run only when a PR is in the merge queue:

# .ci/dev.yaml
checks:
  test:
    run: cargo test --locked
  load-test:
    run: ./load-test
    queue_only: true
    timeout: 20m

A pre-check cannot wait for a queue_only check, so a check that needs one must be queue_only too.

Split a check across machines: shards

# .ci/dev.yaml
checks:
  build:
    run: make tool
  e2e:
    run: ./e2e --shard "$MODERNCI_SHARD"
    needs: [build]
    shards: 4
  • The check runs as e2e@0 to e2e@3. Each is told MODERNCI_SHARD_INDEX (from 0), MODERNCI_SHARD_COUNT and MODERNCI_SHARD (2/4).
  • Each shard is its own job: placed, retried, billed, logged (log --check e2e@2) and reused on its own. The PR passes only when every shard passes, and a red names the shard.
  • needs: [e2e] waits for every shard. needs: ["e2e@1"] and a check named e2e@1 are errors.
  • shards is 1 to 32. Long checks on the merge queue should be sharded so the queue's wall time stays short.

Classes: gate, after, release

# .ci/dev.yaml
checks:
  test:
    run: cargo test --locked
  soak:
    run: ./soak
    class: after
    timeout: 1h
  publish:
    run: ./publish
    class: release
    needs: [soak]
  • gate (default) blocks landing.
  • after runs on the newest landed tip. A red is reported as a landed red and attributed to the change that caused it; it never blocks other PRs.
  • release is a step of the release after landing.

on: says the same thing from the other side: on: pr for gate checks (pre-check and merge queue), on: landed for after and release checks. A check with on: landed and no class is a release step. on: landed on a gate check, and on: pr on an after or release check, are errors. Landed steps run only on a checked tip of the target, never on an unchecked one.

stage and queue_only apply to gate checks only.

Release steps

Release steps run after a PR lands on the release target (usually main). They build and package; ModernCI signs and publishes. A step never sees the signing key: after its run passes, ModernCI asks its separate signer process to sign the artifacts' digests, writes signed SLSA build provenance for them, and publishes the signed channel metadata (a key set, a snapshot and a short-lived timestamp) for the release.

# .ci/main.yaml
checks:
  test:
    run: cargo test --locked
  release:
    on: landed
    needs: [test]
    timeout: 1h
    run: >-
      v="$(mci release version)" &&
      for t in x86_64 aarch64; do
        cargo build --release --locked --target "$t-unknown-linux-gnu" &&
        mci release package --arch "$t-linux" --version "$v"
          --binary "target/$t-unknown-linux-gnu/release/mci" --out out || exit 1;
      done
    publish:
      channel: stable
      rollback_safe: true
      artifacts:
        - { arch: x86_64-linux, path: "out/mci-*-x86_64-linux.tar.gz" }
        - { arch: aarch64-linux, path: "out/mci-*-aarch64-linux.tar.gz" }

The artifacts a step publishes are the files it wrote in its own job. mci release package writes mci-<version>-<arch>.tar.gz (one mci binary inside) and its .sha256; an artifact path may contain *, which must match exactly one file.

publish keyDefaultMeaning
artifactsrequiredOne {arch, path} per architecture: x86_64-linux, aarch64-linux. Paths are repo-relative.
channelstableChannel name: lowercase letters, digits and -.
rollback_safetruefalse when the release cannot be rolled back to the previous one (a migration that cannot be expanded). Such a release is installed only after the owner approves it.

The version is never configured: it comes from the commit (<major.minor>.<height on main>). See Build & Release for signing and provenance.

Required and advisory

required: false runs the check and shows its result without blocking landing. A new check also starts in shadow: it runs, but does not block until it has passed once on the target. Shadow follows what the check does, not its name, so renaming a check does not reset it.

Promotion targets

.ci/qa.yaml and .ci/main.yaml usually share most checks with dev. A promotion file says promotes: and lists only what it adds; the target's checks are the source's checks plus those.

# .ci/dev.yaml
toolchain:
  rust: "1.98.0"
checks:
  test:
    run: cargo test --locked
  lint:
    run: cargo clippy --locked -- -D warnings
# .ci/qa.yaml
promotes: dev
checks:
  smoke:
    run: ./smoke
    needs: [test]
# .ci/main.yaml
promotes: qa
checks:
  release-notes:
    run: ./release-notes
    class: release
    needs: [smoke]

Re-using a source check's name, a loop of promotes, a missing source file and conflicting toolchain pins are errors. Because checks unchanged from the source have the same definition, their results are reused in the promotion.

Gate changes

Changing what blocks landing is itself reviewed. A PR that changes a gate check's run, setup, inputs or tools, adds or removes a gate check, changes required, shards or queue_only on one, or changes a toolchain pin:

  • is shown as gate changed, with the change in cost per landed PR;
  • needs a person's approval (it is a guarded change);
  • lands on its own, never batched with other PRs, so no PR lands under a gate it was not shown.

Not gate changes: renaming a check, changing timeout, stage, needs, env or tests, and anything about after or release checks, including on and publish.

A broken file never falls back

If .ci/<target>.yaml is missing or does not parse, PRs into that target report a configuration error naming the file and line. ModernCI never substitutes an older copy of the file.

.ci/repo.yaml

# .ci/repo.yaml
agents: true

agents says whether agents may take the repo's work items. Every other key is refused.

Reference

.ci/ files are YAML. The JSON Schemas are crates/mci-config/schema/ci.schema.json and crates/mci-config/schema/repo.schema.json; they are generated from the loader's own types and a test fails if they drift.

Where each kind of configuration lives

WhatWhereHow to change it
Checks, setup, env, toolchain, promotions.ci/<target>.yaml in the repo (this page)A PR. Gate changes need a person's approval.
agents.ci/repo.yamlA PR.
Budgets, approvals required, data regions, which forge and compute kinds are allowed, feature flagsModernCI settings, by level (operator, tenant, project) with a source and optional lockmci settings list <level> <scope>, mci settings get <level> <scope> <setting>, mci settings set <level> <scope> <setting> --value '{...}', or the console's settings page.
Forge and compute connectionSettings forge.plugin and compute.plugin with their configmci forges connect, mci computes connect .
SecretsA write-only secret store, never the repomci secrets put (coming).

The reasons settings never come from the repo are in security. Concepts such as class, gate change and reuse: concepts.

View this page as Markdown