Providers

What cigen generates for GitHub Actions and CircleCI, and what each provider doesn't do yet.

View as MarkdownEdit on GitHub

Set provider: github, provider: circleci, or provider: [github, circleci] to generate both. Each provider runs as its own binary (cigen-provider-github, cigen-provider-circleci) and returns files that cigen writes.

GitHub Actions

cigen generate writes one file per workflow: workflows.ci becomes .github/workflows/ci.yml. Its header names the config it came from and the command that regenerates it (cigen generate, with --config for any other config name).

  • The workflow’s github: block supplies the workflow keys (on, permissions, concurrency). Without on:, the workflow runs on pull requests and on pushes to main.
  • Each job gets runs-on from its image, or runs in a container on ubuntu-latest (see jobs).
  • Every job starts with an actions/checkout step. Its options come from the job’s checkout:.
  • Jobs with inputs get the skip steps, after a step that installs cigen.
  • A job’s github: block is merged into the generated job unchanged. The top-level github: block is merged into every workflow’s top level; a key the workflow’s own github: block sets wins, as a whole value.
  • A step that names a command is replaced by the command’s steps, with << parameters.x >> filled in (see commands).
  • A job’s services become GitHub service containers (see services).
  • A step GitHub can’t run, such as CircleCI’s restore_cache, is an error that names the job and the step.
  • Steps keep every key they’re given; a key a GitHub step can’t have is an error (see other step keys).

CircleCI

cigen generate writes two files:

  • .circleci/config.yml: a setup workflow that hashes each job and continues with the jobs that need to run, using the circleci/continuation orb. This setup job can’t run yet.
  • .circleci/main.yml: the jobs and workflows, with a shallow-checkout command, your commands, and each job’s services as extra Docker images.

A job’s circleci: block is merged into the generated job, and the top-level circleci: block into the config.

When the circleci CLI is on your PATH, the provider runs circleci config validate on what it generates and fails if CircleCI rejects it. Without the CLI it skips that check, so a config can generate on one machine and fail on another.

The plugin protocol

cigen talks to providers over stdin and stdout with length-prefixed Protocol Buffers messages (proto/plugin.proto in the repository). cigen looks for provider binaries in CIGEN_PLUGIN_DIR if it’s set, then /usr/local/lib/cigen/plugins, then next to its own binary.