diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..bf58cae --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -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 ` shows what the job's hash covers; paste it here. + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..cb3abe0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -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. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..02715ec --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -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 diff --git a/.github/ISSUE_TEMPLATE/tried_cigen.yml b/.github/ISSUE_TEMPLATE/tried_cigen.yml new file mode 100644 index 0000000..9d18dc7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/tried_cigen.yml @@ -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" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..a9e1cec --- /dev/null +++ b/CONTRIBUTING.md @@ -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//` 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. diff --git a/README.md b/README.md index f9fc214..59397e3 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/scripts/setup.sh b/scripts/setup.sh deleted file mode 100755 index a74a719..0000000 --- a/scripts/setup.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env bash -# Setup script for cigen development environment - -set -e - -echo "๐Ÿš€ Setting up cigen development environment..." - -# Check if Rust is installed -if ! command -v rustc &> /dev/null; then - echo "โŒ Rust is not installed. Installing:" - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -fi - -echo "โœ… Rust is installed ($(rustc --version))" - -# Install Lefthook -if ! command -v lefthook &> /dev/null; then - echo "๐Ÿ“ฆ Installing Lefthook..." - - # Check if homebrew is available - if command -v brew &> /dev/null; then - echo " Using Homebrew..." - brew install lefthook - else - echo "โŒ Homebrew is not installed. Please install Homebrew first:" - echo " /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"" - echo "" - echo "Or install Lefthook manually:" - echo " npm install -g lefthook" - echo " or" - echo " curl -sSfL https://raw.githubusercontent.com/evilmartians/lefthook/master/install.sh | sh" - exit 1 - fi - - echo "โœ… Lefthook installed successfully" -else - echo "โœ… Lefthook is already installed ($(lefthook version))" -fi - -# Install actionlint -if ! command -v actionlint &> /dev/null; then - echo "๐Ÿ“ฆ Installing actionlint (GitHub Actions linter)..." - - # Check if homebrew is available - if command -v brew &> /dev/null; then - echo " Using Homebrew..." - brew install actionlint - elif command -v go &> /dev/null; then - echo " Using Go..." - go install github.com/rhysd/actionlint/cmd/actionlint@latest - else - echo "โŒ Neither Homebrew nor Go is available. Please install actionlint manually:" - echo " brew install actionlint" - echo " or" - echo " go install github.com/rhysd/actionlint/cmd/actionlint@latest" - echo "" - echo "Note: actionlint is optional but recommended for linting GitHub Actions workflows" - fi - - if command -v actionlint &> /dev/null; then - echo "โœ… actionlint installed successfully" - fi -else - echo "โœ… actionlint is already installed ($(actionlint -version 2>&1 | head -n1))" -fi - -# Install Lefthook git hooks -echo "๐Ÿ”— Installing git hooks..." -lefthook install - -# Run initial checks -echo "๐Ÿงช Running initial checks..." -echo " Checking code format..." -if ! cargo fmt --all -- --check; then - echo "โŒ Code formatting issues found. Run 'cargo fmt' to fix." - exit 1 -fi - -echo " Running clippy..." -if ! cargo clippy; then - echo "โŒ Clippy found issues." - exit 1 -fi - -echo " Running tests..." -if ! cargo test; then - echo "โŒ Tests failed." - exit 1 -fi - -echo "" -echo "โœจ Setup complete! You're ready to start developing." -echo "" -echo "๐Ÿ“ Git hooks are now active:" -echo " - pre-commit: Runs fmt, clippy, and tests" -echo " - pre-push: Runs full checks" -echo "" -echo "๐Ÿ’ก To skip hooks temporarily, use: git commit --no-verify"