Jobs

Every key a job accepts, what each provider does with it, and services.

View as MarkdownEdit on GitHub

A job lives under workflows.<workflow>.jobs.<id>, or in its own file at .cigen/workflows/<workflow>/jobs/<id>.yml.

# cigen.yml
provider: github

services:
  postgres:
    image: postgres:17
    environment:
      POSTGRES_PASSWORD: postgres

workflows:
  ci:
    jobs:
      build:
        image: rust:latest
        inputs: ['src/**', 'Cargo.toml', 'Cargo.lock']
        steps:
          - run: cargo build --locked

      test:
        image: rust:latest
        needs: build
        inputs: ['src/**', 'tests/**', 'Cargo.toml', 'Cargo.lock']
        services: [postgres]
        env:
          DATABASE_URL: postgres://postgres:postgres@postgres:5432/test
        steps:
          - run: cargo test --locked

Keys

Key What it is
image Where the job runs. Default ubuntu-latest. See below.
steps What the job does. See steps and commands.
needs Jobs that must finish first: one id or a list.
inputs What the job’s result depends on: globs, or @group references. See inputs.
env Environment variables for every step.
services Names from the top-level services.
matrix Run the job once per combination of values. See below.
packages GitHub only: rust or node adds a dependency cache restore step.
checkout GitHub only: options for the actions/checkout step cigen adds, such as fetch-depth.
artifacts Accepted, but neither provider generates anything from it yet.
github Job keys passed to GitHub untouched: timeout-minutes, if, outputs, strategy, environment.
circleci Job keys passed to CircleCI untouched: resource_class, parallelism, parameters.

Any other key is an error that says what to write instead.

image

  • GitHub Actions: a runner label such as ubuntu-latest, macos-15 or windows-latest becomes runs-on. Anything else is a container image, and the job runs in it on ubuntu-latest.
  • CircleCI: a Docker image for the job’s executor.

To choose a GitHub runner for a container job, set runs-on in the job’s github: block.

needs

needs takes one job id or a list. Every id must be a job in the config, and a job can’t need itself. Generated jobs keep the dependencies. A job’s hash includes the hashes of the jobs it needs, so it runs again whenever one of them would (see inputs). A job that a matrix runs in several stages (- { stage: us }, - { stage: eu }, with stage_prefix on) is needed stage by stage: a job in the us stage needs us_build, and a job in a stage build has no instance in (an approval in review) needs every instance.

Services

Define each service once at the top level with an image (and optionally environment), then name it in the jobs that use it.

# cigen.yml
provider: github

services:
  postgres:
    image: postgres:17
    environment:
      POSTGRES_PASSWORD: postgres

workflows:
  ci:
    jobs:
      test:
        image: ruby:3.4
        services: [postgres]
        steps:
          - run: bundle exec rspec
  • GitHub Actions: each service becomes a service container. environment becomes env, and ports, volumes, options and credentials pass through. A container job (like test above) reaches the service by its name (postgres); a job that runs on the runner itself needs ports, and reaches it on localhost.
  • CircleCI: each service becomes an extra Docker image in the job’s executor.

A service a job names is part of that job’s hash, so changing its image reruns the job.

matrix

# cigen.yml
provider: github
workflows:
  ci:
    jobs:
      test:
        image: rust:latest
        matrix:
          toolchain: [stable, beta]
        steps:
          - run: cargo test

Each combination becomes its own job, named after the job and its values: test-stable and test-beta. A job name keeps only letters, digits, - and _, the characters both GitHub and CircleCI accept, so any other character in a value becomes _: toolchain: ["1.90"] gives test-1_90. Two combinations that would get the same name are an error, and so is a name that doesn’t start with a letter. Today the values aren’t passed into the job’s steps, and a matrix job with inputs fails at its hash step.

GitHub’s own matrix also works, passed through the github: block (github: { strategy: { matrix: … } }), with ${{ matrix.x }} in the steps. Every entry runs the same job definition, so the generated hash step passes the entry to cigen hash --matrix, and each entry gets its own hash and pass marker: an entry that failed never reuses another entry’s pass.