Skip to content
Merged
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
138 changes: 107 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,75 @@
# cigen

cigen compiles one small CI config into native GitHub Actions workflows or CircleCI config, and skips jobs whose inputs
have already passed.
**CI that skips the jobs that already passed.**

Each job lists the files its result depends on. cigen adds what it can find for itself: lockfiles, toolchain pins,
scripts the steps run, the commands the job uses and the job's own definition. When none of that has changed since the
job last passed, CI skips it.
Most pushes touch a handful of files, and CI runs every job anyway: the full test suite after a typo fix in the README,
or the docs build after a change that never went near the docs. cigen compiles one config into native GitHub
Actions workflows or CircleCI config. Every job knows which files its result depends on. On GitHub Actions, when none
of them has changed since the job last passed, the job skips its steps in seconds and reports success.

```yaml
# cigen.yml
provider: github

input_groups:
rust: ['src/**/*.rs', 'Cargo.toml', 'Cargo.lock']

workflows:
ci:
jobs:
build:
image: rust:latest
inputs: ['@rust']
steps:
- run: cargo build --locked
test:
image: rust:latest
needs: [build]
inputs: ['@rust', 'tests/**']
inputs: ['src/**', 'tests/**']
steps:
- run: cargo test --locked
```

```sh
cigen generate # writes .github/workflows/ci.yml
cigen hash --job test # the hash CI compares to decide whether test can skip
`cigen generate` writes `.github/workflows/ci.yml`, a plain workflow you commit next to the config. Before the job's own
steps, it hashes the job's inputs and looks that hash up in GitHub's cache:

```yaml
# generated: .github/workflows/ci.yml (an excerpt)
- name: Compute source hash
id: compute_hash
run: |
set -euo pipefail
mkdir -p .cigen/skip-cache
mkdir -p .cigen/cache
cigen hash \
--job test \
--base-dir . \
--output job_hash \
--cache .cigen/cache/file-hashes.json
- name: Restore skip cache
id: job_skip_cache
uses: actions/cache@v4
with:
path: .cigen/skip-cache/test
key: job-skip-${{ runner.os }}-test-${{ steps.compute_hash.outputs.job_hash }}
if: ${{ env.ACT != 'true' }}
- run: cargo test --locked
if: steps.job_skip_cache.outputs.cache-hit != 'true'
```

The same config can be split into a `.cigen/` directory, one file per job. The config is strict, which suits coding
agents: an unknown key is an error that names the file and says what to write instead.
The first push runs `cargo test` and records a pass under that hash. Push a commit that only changes the README, and
the hash comes out the same: the lookup hits, `cargo test` never starts, and the check stays green. Change a file under
`src/` and the job runs again.

## What goes into the hash

You list the files a job reads under `inputs`, as globs or named groups. cigen adds everything else it can find:

- the job's own definition, its workflow's settings and cigen's version;
- the hashes of the jobs it `needs`, so a change that reruns `build` reruns the tests after it too;
- the commands and services the job uses;
- scripts and local actions its steps name (`sh scripts/check.sh`, `uses: ./.github/actions/setup`);
- every tracked `package.json`, since its scripts are what `npm run` runs;
- lockfiles and toolchain pins (`rust-toolchain.toml`, `.nvmrc`).

A job that skips when its inputs changed would turn a real failure into a green check, so every rule errs towards
including too much. In a git repository only tracked files count, so build output never changes a hash.

## Built for coding agents

cigen is designed for coding agents to write and fix, so its config is strict. An unknown key is an error that names
the file and the key, and says what to write instead:

```yaml
# cigen.yml
Expand All @@ -52,14 +85,43 @@ workflows:
- run: cargo test
```

## Status
- `cigen validate --format json` reports every problem at once as data: file, line, key path, message and fix.
- JSON Schemas for every config file are in [schemas/v1/](schemas/v1/), for editors and agents that validate as they
write.
- The docs are Markdown for agents too: [llms.txt](https://docspring.github.io/cigen/llms.txt),
[llms-full.txt](https://docspring.github.io/cigen/llms-full.txt), and
[install.md](https://docspring.github.io/cigen/install.md), a setup guide an agent can follow from start to finish.
- Generated files say so in their header, with the command that regenerates them.

## Modules

A module is the setup you paste into every job: installing a toolchain, caching its downloads, and the files that setup
depends on. One line replaces it. In a Rust crate:

```toml title="Cargo.toml"
[package]
name = "app"
version = "0.1.0"
edition = "2024"
```

```yaml
# cigen.yml
provider: github

workflows:
ci:
jobs:
clippy:
modules:
- rust: { components: [clippy] }
inputs: ['src/**']
steps:
- run: cargo clippy --all-targets -- -D warnings
```

cigen is early. Generating workflows works for both providers, and the GitHub Actions skip flow is tested end to end.
Generated workflows install the cigen release that generated them and check its checksum. CircleCI skipping is coming.
Modules (shared job setups you'd otherwise paste into every repository) have started: the `rust` module is built (a job
lists it under `modules:`), and `node` and others are coming.
[internal_docs/STATUS.md](internal_docs/STATUS.md) lists what works and every known problem, and
[internal_docs/DIRECTION.md](internal_docs/DIRECTION.md) says where it's going.
The `rust` module installs the toolchain your project pins, caches cargo's downloads and build output, and adds
`Cargo.toml`, `Cargo.lock` and the toolchain file to the job's hash. `node`, Playwright and services are next.

## Install

Expand All @@ -70,15 +132,29 @@ cargo install --locked --git https://github.com/DocSpring/cigen \
cigen cigen-provider-github cigen-provider-circleci
```

The providers are separate binaries that cigen finds beside its own. Prebuilt binaries come with v0.2.0.
The providers are separate binaries that cigen finds beside its own. Prebuilt binaries and a one-line installer come
with v0.2.0. Then follow the [quick start](https://docspring.github.io/cigen/docs/quick-start/).

## Status

cigen is early, and being rebuilt in the open. Today it loads one config in two layouts (a `cigen.yml`, or a `.cigen/`
directory with a file per job), generates GitHub Actions and CircleCI config byte for byte the same on every run, and
has `cigen validate`, `cigen hash` and the `rust` module.

Skipping on GitHub Actions is tested end to end in a simulator of GitHub's runner. The generated workflows download the
cigen release that generated them, so they need v0.2.0, the first release with those archives. Skipping on CircleCI
comes next, with more modules and a command that replays a project's git history to estimate what cigen would skip.

[internal_docs/STATUS.md](internal_docs/STATUS.md) lists what works and every known problem.
[internal_docs/DIRECTION.md](internal_docs/DIRECTION.md) says where cigen is going, and in what order.

## Help wanted

Try cigen on your own CI and tell us where it falls short. Open an issue for:
Run cigen against your own CI and tell us where it falls short. Open an issue for:

- a bug, or a config that should load and doesn't;
- a feature you need before you could switch;
- a CI pattern you paste into every repository, which cigen could generate for you.
- something you'd need before you could switch;
- setup you paste into every repository, which a module could generate.

[Open an issue](https://github.com/DocSpring/cigen/issues/new/choose). cigen is maintained with AI coding agents, and
they read every issue.
Expand Down
Loading