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
63 changes: 63 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Bug report
description: cigen did something wrong (a crash, a wrong error, wrong generated config, a job that skipped or ran when it shouldn't).
labels: [bug]
body:
- type: markdown
attributes:
value: |
Thanks for reporting. A job that **skipped when its inputs changed** is the worst bug cigen can have: say so in the title if that's what happened.
Please remove secrets, private hostnames and anything else you can't share from what you paste.
- type: input
id: version
attributes:
label: cigen version
description: The output of `cigen --version`.
placeholder: cigen 0.2.0
validations:
required: true
- type: dropdown
id: provider
attributes:
label: Provider
options:
- GitHub Actions
- CircleCI
- Both
- Not provider-specific (loading, validate, explain, hash)
validations:
required: true
- type: textarea
id: config
attributes:
label: Config
description: Your `cigen.yml`, or a minimal config that shows the problem. `cigen expand` prints a `.cigen/` directory as one file.
render: yaml
validations:
required: true
- type: textarea
id: command
attributes:
label: What you ran
description: The command, and its full output. For a config error, `cigen validate --format json` is the most useful.
render: shell
validations:
required: true
- type: textarea
id: generated
attributes:
label: Generated output
description: The relevant part of the generated workflow or CircleCI config, if the problem is in it.
render: yaml
- type: textarea
id: expected
attributes:
label: What you expected
validations:
required: true
- type: textarea
id: actual
attributes:
label: What happened instead
description: For a skip that went wrong, `cigen explain <job>` shows what the job's hash covers; paste it here.
validations:
required: true
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: true
contact_links:
- name: How cigen works
url: https://github.com/DocSpring/cigen#readme
about: What cigen does, the config format and the commands.
- name: Known problems
url: https://github.com/DocSpring/cigen/blob/main/internal_docs/STATUS.md#known-problems
about: What works today and what doesn't yet. Check here before reporting a gap.
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Feature request
description: A CI problem you'd like cigen to solve.
labels: [enhancement]
body:
- type: textarea
id: problem
attributes:
label: The problem
description: The CI problem in your own words. What do you do by hand today, or what does your CI waste time on?
validations:
required: true
- type: dropdown
id: provider
attributes:
label: Provider
description: Where your CI runs.
multiple: true
options:
- GitHub Actions
- GitHub Actions on another runner (Blacksmith, Depot, Namespace, ...)
- CircleCI
- Forgejo or Gitea Actions
- Other
validations:
required: true
- type: textarea
id: today
attributes:
label: How you handle it now
description: A workaround, another tool, a script, or nothing. Links welcome.
- type: textarea
id: idea
attributes:
label: What you'd like cigen to do
description: Optional. A config sketch helps.
render: yaml
60 changes: 60 additions & 0 deletions .github/ISSUE_TEMPLATE/tried_cigen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: I tried cigen on my repo
description: Tell us how it went, good or bad. This is the most useful report you can send right now.
labels: [field report]
body:
- type: markdown
attributes:
value: |
cigen is young, and reports from real repositories decide what gets built next. Short is fine.
Please remove secrets, private hostnames and anything else you can't share.
- type: input
id: version
attributes:
label: cigen version
description: The output of `cigen --version`.
validations:
required: true
- type: dropdown
id: provider
attributes:
label: Provider
multiple: true
options:
- GitHub Actions
- GitHub Actions on another runner (Blacksmith, Depot, Namespace, ...)
- CircleCI
- Other
validations:
required: true
- type: textarea
id: repo
attributes:
label: Your repository
description: Languages and toolchains, roughly how many CI jobs, how long CI takes, monorepo or not. A link if it's public.
validations:
required: true
- type: textarea
id: worked
attributes:
label: What worked
- type: textarea
id: didnt
attributes:
label: What didn't
description: Errors, missing features, confusing docs, generated config you had to fix by hand. Link or open separate bug reports for anything specific.
validations:
required: true
- type: textarea
id: config
attributes:
label: Your config
description: Optional. `cigen expand` prints it as one file.
render: yaml
- type: dropdown
id: keep
attributes:
label: Will you keep using it?
options:
- "Yes"
- Maybe, once something is fixed or added
- "No"
68 changes: 68 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Contributing to cigen

Thanks for helping. Bug reports and "I tried cigen on my repo" reports are as useful as code right now: use the issue
templates.

Before you start, read [internal_docs/STATUS.md](internal_docs/STATUS.md) for what works today and its known problems,
and [internal_docs/DIRECTION.md](internal_docs/DIRECTION.md) for where cigen is going. For anything bigger than a fix,
open an issue first so we can agree on the approach.

## Setup

- Rust: `rust-toolchain.toml` pins the version, and rustup installs it on first build.
- `protoc` (the protobuf compiler): `brew install protobuf` on macOS, `apt-get install protobuf-compiler` on Debian
and Ubuntu. The plugin protocol is generated from `proto/plugin.proto`.
- [Task](https://taskfile.dev) runs the checks.
- Node and pnpm, then `pnpm install`. It installs the git hooks (lefthook) and the formatters they run (prettier and
biome). The hooks format staged files and run the checks before each commit. Never skip them with `--no-verify`; fix
what they report.

## The dev loop

1. Write a test that fails first, then make it pass.
2. Run `task ci`, which runs `cargo fmt --all --check`, clippy with warnings as errors, and `cargo test --workspace`.
It must pass with no warnings.
3. If you changed behaviour, update `internal_docs/STATUS.md` in the same commit. It describes the code as it is; plans
go in DIRECTION.md.
4. Open a pull request against `main` with what you changed and how you tested it.

### Generated files

- **Golden fixtures.** Each fixture in `integration_tests/<fixture>/` holds a `.cigen/` config and the output cigen
generates for it. `tests/golden_fixtures.rs` compares them byte for byte. After an intended change, refresh them with
`CIGEN_UPDATE_GOLDEN=1 cargo test --test golden_fixtures` and review the diff before committing.
- **JSON schemas.** `schemas/v1/` is generated from the config types in `src/schema/`. Refresh it with
`CIGEN_UPDATE_GOLDEN=1 cargo test --test json_schema`.
- **cigen's own CI.** `.github/workflows/` is generated from `.cigen/`, so never edit it by hand. Change `.cigen/`, then
run `cargo build --workspace && cargo run -- generate --config .cigen` (the build matters: `cargo run` alone doesn't
rebuild the provider binaries) and commit both.

Generated output must be deterministic: never iterate a `HashMap` or `HashSet` to produce it.

### Testing skips with mockci

Golden files only prove the output didn't change. To prove a job skips or runs when it should, the tests in
`tests/skip_scenarios.rs` and `tests/derived_inputs.rs` generate a workflow for a throwaway repository and run it in
mockci (`crates/mockci`), a GitHub Actions simulator with a model of the cache. They change a file, run the workflow
again, and assert what ran. [internal_docs/MOCK_CI.md](internal_docs/MOCK_CI.md) explains what it models.

## The false-skip rule

A job that skips when its inputs changed is the worst bug cigen can have: it turns a real failure into a green check.
When you touch hashing, cache keys, derived inputs or skip conditions, add a test that changes an input and asserts that
the job runs. When in doubt, include more inputs: an extra input costs a rerun, a missing one hides a failure.

## This repository is public

cigen is MIT licensed and public. Don't copy private configuration into it, including fixtures, docs and examples:
no company-internal job names, hostnames, secrets or CI config from your employer or clients. Write fixtures from
scratch, with made-up names.

## Code style

- Keep files under about 300 lines; split a file into modules as it grows.
- Errors fail fast and say what to change. No silent defaults.
- Add dependencies with `cargo add`, and look up current versions rather than writing them from memory.
- Shell scripts are POSIX `sh` and run on both macOS and Linux.

[CLAUDE.md](CLAUDE.md) has the full rules. Coding agents read it, and they apply to everyone.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ they read every issue.
## Development

```sh
./scripts/setup.sh # git hooks (lefthook) and environment checks
pnpm install # git hooks (lefthook) and the formatters they run
task ci # fmt, clippy and the full test suite
```

cigen's own CI is generated by cigen from [.cigen/](.cigen/). Agents working on this repository: start with
[CLAUDE.md](CLAUDE.md).
cigen's own CI is generated by cigen from [.cigen/](.cigen/). [CONTRIBUTING.md](CONTRIBUTING.md) has the dev loop and
the rules. Agents working on this repository: start with [CLAUDE.md](CLAUDE.md).

## License

Expand Down
98 changes: 0 additions & 98 deletions scripts/setup.sh

This file was deleted.

Loading