Modules
Setup steps you'd otherwise paste into every job, as one line under modules. What a module adds and how it reaches the job's hash.
A module is setup you’d otherwise paste into every job: installing a toolchain, caching its downloads, and the inputs
that setup depends on. A job lists its modules under modules:, and cigen expands each into ordinary steps before a
provider sees the job.
The project in this page’s examples is a Rust crate:
[package]
name = "app"
version = "0.1.0"
edition = "2024"
[toolchain]
channel = "1.85.0"
Using a module
Name it, or name it with parameters:
# cigen.yml
provider: github
workflows:
ci:
jobs:
clippy:
modules:
- rust: { components: [clippy] }
inputs: ['src/**']
steps:
- run: cargo clippy --all-targets -- -D warnings
fmt:
modules:
- rust: { components: [rustfmt], cache: false }
inputs: ['src/**']
steps:
- run: cargo fmt --check
A module’s steps go after the checkout and the skip check, before the job’s own steps. A module that saves a cache
after the job (CircleCI’s save_cache) adds that step after the job’s steps. Modules run in the order listed.
An unknown module or parameter is an error that names the closest one:
# cigen.yml
# error: there's no module named `rsut`: did you mean `rust`?
provider: github
workflows:
ci:
jobs:
test:
modules: [rsut]
steps:
- run: cargo test
Modules and the job’s hash
A module changes what a job runs, so everything about it goes into the job’s hash:
- its parameters, after defaults and detection (the toolchain it found in
rust-toolchain.toml, say); - the steps it adds, for every provider the config names;
- the files it depends on. The
rustmodule addsCargo.toml, every tracked**/Cargo.toml,Cargo.lock, the toolchain files and.cargo/config.toml, so a job that uses it reruns when any of them changes, without listing them in itsinputs.
The generated hash step also passes --modules-digest, a digest of the job’s module steps when the config was
generated. cigen hash mixes it into the hash and warns when its own steps differ, so a config generated by another
version of cigen never reuses a pass recorded by this one.
Declare the job’s own sources in inputs (src/**, tests/**); the module brings its toolchain’s files.
The rust module
Installs the Rust toolchain your project pins, adds components and targets, and caches cargo’s downloads and target/.
| Parameter | Default | Meaning |
|---|---|---|
toolchain |
what rust-toolchain.toml or rust-toolchain names, else stable |
a channel or version; setting it when a toolchain file exists is an error |
components |
[] |
components to add, such as [clippy, rustfmt] |
targets |
[] |
targets to add, such as [x86_64-unknown-linux-musl] |
cache |
true |
cache the cargo registry, git dependencies and target/ |
path |
. |
the workspace root, where Cargo.toml and Cargo.lock are |
It installs with rustup, which GitHub’s runners and the Rust images ship. On GitHub Actions it caches with
Swatinem/rust-cache, pinned to a commit; on CircleCI with restore_cache and save_cache, keyed by the
architecture, the toolchain and Cargo.lock. Its full reference is
src/modules/rust/README.md.
More modules
rust is the first. Node with npm, pnpm or Yarn comes next, then Playwright, services (Postgres, an S3-compatible
store), a shared compile cache and Ruby with Bundler. The
module catalogue lists the ones that exist.