# Read CI results and logs

Once [Buildkite is connected](https://git.cafe/docs/ci/buildkite.md), GitCafe shows build results on
the repository's **CI** tab and as checks on pull requests and commits.
Workflows that GitCafe runs itself with [Actions](https://git.cafe/docs/ci/actions.md) report checks
the same way; their runs and logs are on the repository's **CI** tab
([follow runs and read logs](https://git.cafe/docs/ci/actions.md#follow-runs-and-read-logs)).

## See checks on a pull request

The checks panel on a pull request's **Conversation** tab lists every check on
its latest commit: Buildkite and GitCafe checks (including one per Actions job
and one per Actions workflow), commit statuses and checks imported from GitHub.
The badge summarizes them all, and each check links to its run. An Actions
job's check is named `<workflow name> / <job name>`, with each matrix
combination under its own name, such as `CI / test (22)`. GitHub names the
same check `test (22)`, so update required check names you carry over from
GitHub.

Required checks are set with [rulesets](https://git.cafe/docs/repositories/repository-rulesets.md);
a pull request cannot merge until they pass on the exact commit being merged.

```sh
cafe pr status 42
```

`cafe pr status` lists every check on the pull request's head commit, Actions
jobs and Buildkite builds alike, with whether it is required and, when it has
one, a link to its run. `cafe ci status --pr 42` shows the CI runs at that
commit: workflow runs and Buildkite builds.

## Browse runs

Open the repository's **CI** tab to list runs. Filter by status and page back
through older runs; active runs refresh while the page is open. Select a run to
see its jobs and logs.

```sh
cafe ci list --branch main                 # workflow runs and Buildkite builds
cafe ci list --source buildkite --pr 42    # Buildkite builds at a pull request's head
cafe ci watch <run-id>
```

`cafe ci` lists GitCafe Actions workflow runs and Buildkite builds together,
newest first, like the **CI** tab; `--source actions` or `--source buildkite`
shows one. `--branch` lists the runs on that branch, not only at its tip.
`cafe ci watch` waits until the run finishes and exits nonzero unless it
succeeded ([follow runs and read logs](https://git.cafe/docs/ci/actions.md#follow-runs-and-read-logs)).

## Read a job log

Open a run, or a check's **View jobs and logs** link. Failed jobs are listed
first, and the first failed job's log opens automatically. The job is part of
the address, so you can share a link to it.

The viewer shows the log as it appeared in the terminal, with colours and
progress lines:

- It starts with the last 256 KB. **Load 256 KB more** loads earlier output;
  **Load the whole log** loads all of it.
- The failures button steps through lines that report a failure: failed tests,
  compiler errors, panics and non-zero exit codes.
- Search finds text in the loaded output (Enter for next, Shift+Enter for
  previous). **Sections** jumps to a Buildkite section header.
- **Download** saves the whole log; **Copy** copies the loaded part.
- While a job runs, new output appears every few seconds. **Latest output**
  jumps back to the end.

Logs are available only when the repository [shares them](https://git.cafe/docs/ci/buildkite.md#share-job-logs).
A job that has not started has no log yet; a step Buildkite never ran on this
build (for example one its branch filter excludes) is listed as **Skipped**.

## Download logs from the CLI

```sh
cafe ci jobs <run-id>
cafe ci logs <run-id> <job-id> --output job.log
cafe ci logs <run-id> <job-id> --tail 200
```

`--full` prints the whole log, `--tail N` the last N lines, and, for a
Buildkite job, `--bytes FIRST-LAST` one byte range.
