Concepts
The few ideas a pipeline file is built from, and what branchd decides before a run starts.
Available in repositories branchd reads pipeline files for. It is switching repositories on one at a time: until yours is, it keeps running its
.forge-ci.yamlor.xeonr-ci.yaml. See What is available.
Pipeline file
One file in .branchd/pipelines/ is one pipeline. Its name is its name:,
or the file name without .yaml. A repository can have several; each is
compiled on its own, so a broken file does not stop the others. See
Several pipelines in one repository.
A repository uses either pipeline files or the older CI files (such as
.xeonr-ci.yaml), never both: having both is refused.
Run
A run is one execution of one pipeline for one event: a push, a pull
request, a schedule, a manual start, or a trigger from another repository.
on: decides which events start a run. Runs are numbered per repository.
By default a newer run of the same ref supersedes an older one: on an
unprotected branch the older run is cancelled, and on a protected branch
the newer run waits for it. concurrency: {cancel-in-progress: false} at
the top of a file opts out.
Job
A job is a unit of work with its own container and its own check. It has an
image and steps, or it calls a reusable pipeline (uses:), or it
starts another repository's pipeline (trigger:). Jobs run in parallel.
Step
A step is one run: (shell commands) or one uses: (a
composite step, or a typed step
such as ci/image-build@1). A job's run: steps share one shell, in
order: a cd or an export in one step is seen by the next. The shell is
bash when the image has it, else sh, with set -e. The first step that
fails stops the job, apart from steps with if: always() or
if: failure().
needs
needs: [build] makes a job wait for build and run only if it succeeded.
It also brings build's artifacts and lets the job read build's outputs.
There are no stages: needs is the only ordering.
A need on a job that does not run for this event is refused, so that a
missing job is never silently skipped. Give the two jobs the same if:, or
write the need as {job: build, optional: true}.
How a job gets its code
Every job starts in a checkout of the run's commit, with .git. Nothing to
write, and nothing needed in the image, not even git: branchd fetches the
commit before the job's container starts, with a token the job never sees.
The origin remote is the repository's URL, and git fetch origin or
git push origin (with permissions: {contents: write}) use the
job token when the image has git.
checkout: false skips it; checkout: {depth: 0, tags: true} fetches the
whole history and the tags.
Decided before the run starts
on:, every job's if:, matrix:, uses: and every ${{ }} that does
not read an output are evaluated when the run is compiled, from facts
branchd knows at that moment: the event, branch, tag, changed paths,
inputs, and the repository's settings variables. That is why:
branchd ci plancan list, for any branch or event, every job and why it runs or does not, before you push;- a pull request's checks are known as soon as it is opened;
- an
if:cannot read another job's outputs, which only exist once that job has run.
Two kinds of value are known only while a job runs: a step's outputs
(steps.<id>.outputs.<name>) and a needed job's outputs
(needs.<job>.outputs.<name>). They can be used in run:, env:,
image:, with: and a job's outputs:, never in if:.
Expressions never become shell code
${{ inputs.version }} in a run: is not pasted into the script. It
becomes an environment variable of the job, and the script reads that
variable, so a branch name or an input such as $(rm -rf /) stays a value.
It expands where the shell expands variables, so not inside single quotes.