# Quick start

> In five minutes, add a pipeline to a repository, check it locally, push it, and read its checks.
> **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.yaml` or `.xeonr-ci.yaml`. See [What is available](https://docs.branchd.run/branchd/pipelines#what-is-available).

## 1. Install the CLI (one minute)

```bash
curl -fsSL https://updater.xeonr.io/96/install.sh | sh   # or, if you have it: branchd upgrade
branchd auth login
```

`branchd ci lint` and `branchd ci plan` compile your pipeline files on your
machine with the same compiler branchd runs. They need no sign-in for a
repository's own files.

> **Not yet available** (cli 0.39.0): `branchd ci lint` checking every event a file lists, as the push check does, comes in the next CLI release. Releases from 0.33.0 read pipeline files and check the usual situations.

## 2. Add the file

Create `.branchd/pipelines/ci.yaml` in the root of your repository:

```yaml title=".branchd/pipelines/ci.yaml"
# .branchd/pipelines/ci.yaml
# The smallest useful pipeline: test every push to main and every pull request.
name: CI
on:
  push:
    branches: [main]
  pull_request:
jobs:
  test:
    image: golang:1.26
    steps:
      - run: go vet ./...
      - run: go test ./...
```

- `on:` says when the pipeline runs: pushes to `main`, and every pull request.
- `jobs:` holds one job, `test`. It runs in the `golang:1.26` image.
- `steps:` run in order, in one shell, in a checkout of the commit. You do
  not write a checkout step, and the image does not need git: every job
  starts with the repository's files, and `.git`, in its working directory.

A file must end in `.yaml`. A file ending in `.yml` is refused. A repository
uses pipeline files or the old `.forge-ci.yaml` / `.xeonr-ci.yaml`, never
both: delete the old file in the same commit.

## 3. Check it before you push

From the repository's root:

```bash
branchd ci lint
```

`lint` compiles every file in `.branchd/pipelines/` from your working tree
(uncommitted edits included) as branchd will: for a push to the default
branch, to `stage` and to a feature branch, a `v` tag, a pull request, a
scheduled run and a manual run of each manual pipeline, and then each file
for every event its `on:` lists. It prints one line per case and exits 1 if
any is refused. A refusal is `file:line:column: message`, and the message
says what to write instead.

To see what one push would run, and why:

```bash
branchd ci plan                        # a push of the current branch
branchd ci plan --event pull_request   # this branch as a pull request
```

```
pipeline CI (.branchd/pipelines/ci.yaml)
  read: .branchd/pipelines/ci.yaml
  1 of 1 jobs run (1 nodes)
  + test  no if
      platform/script as node test
  note: on: push to main (branches main)
```

A `+` job runs and a `-` job does not, each with the reason. On a branch the
file does not match, the plan says `nothing runs` and why, for example
`on: push: branch dev matches none of branches main`.

## 4. Push

```bash
git add .branchd/pipelines/ci.yaml
git commit -m "ci: add a pipeline"
git push
```

**branchd checks the push.** When a push changes `.branchd/pipelines/`,
`.branchd/steps/` or `.branchd/packages.yaml`, branchd compiles each changed
pipeline file for every event its `on:` lists before it accepts the push,
and answers in the push itself:

- a file that compiles: one line per pipeline saying which jobs run for this
  push, or when the pipeline runs if not for it;
- a file this push breaks: **the push is refused**, with
  `file:line:column: message` for each problem, as `branchd ci lint` prints
  it. Only the pushed branch's tip is checked, and only for what the push
  changed: a file that was already broken in the same way is a warning, not
  a refusal, so a revert or an old branch can always be pushed.
- If the check cannot run in time, the push goes through with a line saying
  so; the run's checks then report the problem.

Someone who may bypass the branch's rules can push a broken file anyway,
with `git push -o ci.allow-invalid`. The push is recorded as bypassed, and
the refusal shows that option only to people who may use it.

On the push, branchd reads `.branchd/pipelines/` at the pushed commit and
starts one run for each pipeline whose `on:` matches.

## 5. Read the checks

Each job reports a check on the commit, named `<pipeline> / <job>`, the job
as the file names it: here `CI / test`. A matrix cell is
`CI / test (1.26)`, a job of a called pipeline `CI / deploy / plan`. The
pipeline named exactly `ci` (lower case) is the exception: its checks are the bare job names
(`test`), as the old files' always were, unless the job's name itself holds
`/` (`ci / lib / prep`). A pull request shows the same checks; a branch
rule requires them by these names.

- In the browser: the repository's **Pipelines** tab,
  `https://branchd.run/<team>/<repository>/-/pipelines`, and one run at
  `…/-/pipelines/<number>`.
- From a terminal, inside the clone:

```bash
branchd run list                 # newest first; --pipeline CI for one pipeline
branchd run watch 12             # follow run 12 until it is over
branchd run log 12 test          # one job's log
branchd run failure 12           # why it failed: the failed job and its log's end
branchd pr checks                # the checks of the current branch's pull request
```

A newer push of the same branch or pull request **supersedes** the older
run: on a pull request or an unprotected branch the older run is cancelled,
on a protected branch the newer one waits for it. See
[Superseding](https://docs.branchd.run/branchd/pipelines/reference#superseding).

## Next

- [Run tests on a pull request](https://docs.branchd.run/branchd/pipelines/test-on-pull-request), with the checks to require.
- [Concepts](https://docs.branchd.run/branchd/pipelines/concepts): what a run, a job and a step are, and what is decided before a run starts.
- [Reference](https://docs.branchd.run/branchd/pipelines/reference): every key, on one page.

Source: https://docs.branchd.run/branchd/pipelines/quickstart
