Configuration

One schema in two layouts, strict keys, JSON schemas for editors, top-level keys, workflow settings and provider blocks.

View as MarkdownEdit on GitHub

A cigen config is one document. You can keep it in a single cigen.yml file, or split the same document into files under .cigen/. Both layouts load to the same config and generate the same files.

The single-file layout

# cigen.yml
provider: github

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

workflows:
  ci:
    jobs:
      test:
        image: rust:latest
        inputs: '@rust'
        steps:
          - run: cargo test

The split layout

The same config, as files under .cigen/:

# .cigen/config.yml
provider: github

input_groups:
  rust: ['src/**/*.rs', 'Cargo.toml', 'Cargo.lock']
# .cigen/workflows/ci/jobs/test.yml
image: rust:latest
inputs: '@rust'
steps:
  - run: cargo test

Where each part of the document goes:

File Holds
.cigen/config.yml Top-level keys. Required, with at least provider.
.cigen/config/*.yml More top-level keys, merged into config.yml.
.cigen/commands/<name>.yml commands.<name>
.cigen/workflows/<name>.yml or workflows/<name>/config.yml workflows.<name>: the workflow’s settings
.cigen/workflows/<name>/jobs/<job>.yml workflows.<name>.jobs.<job>

Jobs in subdirectories get ids with a slash: workflows/ci/jobs/build/compile.yml is the job build/compile.

Two rules keep the layouts equivalent:

  • A repository with both cigen.yml and .cigen/ is an error. Keep one. A .cigen/ beside cigen.yml counts only if it holds config (config.yml, config/, commands/ or workflows/): the generated skip steps keep files of their own there (bin/, cache/, skip-cache/).
  • Every key is defined in one place. Setting the same key in two files is an error that names both files.

Strict keys

The top level, workflow settings and jobs only accept the keys on these pages. Anything else is an error that names the file and the key, and says what to write instead:

# cigen.yml
# error: did you mean `steps`?
provider: github
workflows:
  ci:
    jobs:
      test:
        stpes:
          - run: cargo test

Keys from older cigen versions say what they’re called now (requires is needs, source_files is inputs). Keys that only one provider understands say which provider block to move them into:

# cigen.yml
# error: it's CircleCI-only: move it into a `circleci:` block.
provider: circleci
workflows:
  ci:
    jobs:
      test:
        resource_class: large
        steps:
          - run: cargo test

Commands and package specs still accept keys cigen doesn’t know. Steps keep every key they’re given and pass it to the provider: see other step keys.

JSON schemas

cigen publishes JSON schemas generated from the same types the loader uses, so they’re as strict as cigen is: an unknown key is a schema error everywhere except inside provider blocks, commands, steps and package specs. Point your editor at one for completion and errors as you type.

Schema For
cigen.schema.json cigen.yml, .cigen/config.yml and .cigen/config/*.yml
workflow.schema.json .cigen/workflows/<name>.yml and .cigen/workflows/<name>/config.yml
job.schema.json .cigen/workflows/<name>/jobs/**/*.yml
command.schema.json .cigen/commands/<name>.yml

The top level of a config accepts a $schema key:

# cigen.yml
$schema: https://raw.githubusercontent.com/DocSpring/cigen/main/schemas/v1/cigen.schema.json
provider: github

workflows:
  ci:
    jobs:
      test:
        image: rust:latest
        steps:
          - run: cargo test

The other files don’t, so name their schema in a comment that editors using the YAML language server read:

# .cigen/config.yml
provider: github
# .cigen/workflows/ci/jobs/test.yml
# yaml-language-server: $schema=https://raw.githubusercontent.com/DocSpring/cigen/main/schemas/v1/job.schema.json
image: rust:latest
steps:
  - run: cargo test

Top-level keys

Key What it is
provider Required. github, circleci, or a list of both.
input_groups Named lists of globs that jobs reference as @name. See inputs.
services Service containers jobs can name. See jobs.
commands Reusable steps. See steps and commands.
cigen_install How jobs that skip get cigen. See skipping.
workflows Workflows by name. Each holds its settings and its jobs.
github Passed to the GitHub provider untouched.
circleci Passed to the CircleCI provider untouched.
$schema Ignored by cigen, so an editor can find the JSON schema.

A config with no provider is an error:

# cigen.yml
# error: no CI provider configured
workflows:
  ci:
    jobs:
      test:
        steps:
          - run: cargo test

Workflow settings

Everything under workflows.<name> other than jobs:

Key What it is
github GitHub workflow keys, such as on, permissions and concurrency.
circleci CircleCI workflow keys.
run_when CircleCI only: conditions on pipeline parameters (parameter, equals) that decide whether the workflow runs.
stage_prefix true to name generated jobs after their full id: build/compile becomes build_compile. By default it’s compile.
stage_prefix_separator What replaces the slash when stage_prefix is on. Default _.

A GitHub workflow without an on: runs on pull requests and on pushes to main.

Provider blocks

Anything only one provider understands goes in a github: or circleci: block: at the top level, in a workflow, or in a job. When cigen generates for that provider, it merges the block in as if its keys were written beside it, unchanged. Other providers never see it. On GitHub, the top-level github: block is merged into every workflow, and a key the workflow’s own github: block sets wins, as a whole value (not merged key by key).

# cigen.yml
provider: github
workflows:
  release:
    github:
      on:
        push: { tags: ['v*'] }
      permissions:
        contents: write
      concurrency:
        group: release
    jobs:
      publish:
        image: ubuntu-latest
        github:
          timeout-minutes: 30
          environment:
            name: release
        steps:
          - run: ./scripts/publish.sh

GitHub’s on, permissions, concurrency, timeout-minutes, if and outputs, and CircleCI’s resource_class, parallelism, parameters and orbs, all live in provider blocks.

Job ids

Job ids are unique across all workflows: two workflows can’t both have a test job. A job in a subdirectory can name a sibling without its directory: in build/test, needs: [compile] means build/compile when that job exists.