# Quick start

> Write a cigen.yml, generate a GitHub Actions workflow, and see which inputs each job hashes.

This takes a Rust project from nothing to a generated GitHub Actions workflow. [Install](/docs/install/) cigen first.

## 1. Write the config

Create `cigen.yml` at the root of your repository:

```yaml
# cigen.yml
provider: github

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

workflows:
  ci:
    github:
      on:
        pull_request: {}
        push: { branches: [main] }
    jobs:
      test:
        image: rust:latest
        inputs: ['@rust', 'tests/**']
        steps:
          - run: cargo test

      clippy:
        image: rust:latest
        inputs: '@rust'
        steps:
          - run:
              name: Clippy
              command: cargo clippy --all-targets -- -D warnings
```

- `provider` says what to generate for.
- `input_groups` names sets of files that several jobs depend on.
- Each job under `workflows.ci.jobs` lists its `inputs`: globs, or `@group` references. When none of them have changed
  since the job last passed, the job skips.
- The workflow's `github:` block is passed to GitHub as it is. That's where GitHub's own keys, such as `on:`, go.

## 2. Generate

```sh
cigen generate
```

cigen finds `cigen.yml` (or `.cigen/`) in the current directory and writes `.github/workflows/ci.yml`. Run it again and
you get the same bytes. Commit `cigen.yml` and the workflow together.

If the config has a mistake, `cigen generate` stops with an error that names the file, the key and the fix
([`cigen validate`](/docs/cli/#cigen-validate) checks without generating):

```text
error: cigen.yml (at workflows.ci.jobs.test.stpes): unknown key `stpes`
  help: did you mean `steps`?

The config has 1 problem. `cigen validate --format json` lists them as data.
```

## 3. Look at a job's hash

```sh
cigen hash --job test
```

This prints the hash the generated workflow computes for `test` in CI. It covers the job's `inputs` and its definition,
and also files cigen [derives for itself](/docs/inputs/#derived-inputs): `Cargo.lock`, `rust-toolchain.toml`, and any
script a step runs. Change a file in `src/` and the hash changes. Change only `README.md` and it doesn't.

## What the workflow does

Each job with `inputs` gets a step that installs the cigen release that generated the workflow, then four extra steps:
compute its hash, look for a marker under that hash in the GitHub Actions cache, skip the remaining steps if there is
one, and record a marker when the job passes. [Skipping](/docs/skipping/) explains the rules.

> **Needs a release.** The install step downloads the release whose version generated the workflow. v0.2.0 will be
> the first release with those archives; until then a workflow generated from source fails at that step. Jobs without
> `inputs` don't run cigen and work anywhere.

## Next

- Split the config into files under `.cigen/` when it grows: see [configuration](/docs/configuration/).
- Every job key is in [jobs](/docs/jobs/).
