# CI: the GitHub Action

> One step before xcodebuild on GitHub Actions, signed in with the job's OIDC token, and a README badge for public repositories.

Source: https://warmbuild.dev/docs/ci/

**What you do**

1. Give the job (or the workflow) `id-token: write`: that is the sign-in, no secret.

   ``` title=".github/workflows/build.yml"
   permissions:
     id-token: write
   ```
2. Add the step after the checkout, before the first `xcodebuild`. It starts a cache server and exports `XCODE_XCCONFIG_FILE`, so `xcodebuild` stays unchanged.

   ``` title=".github/workflows/build.yml"
   - uses: warmbuild/action@v1.14.2
   ```
3. Merge it. Pushes to the default branch write to the cache; everything else reads.

**What you get**

**1.9–3.5×** faster `xcodebuild build` on a fresh CI runner, measured on 4 public apps ([how](https://warmbuild.dev/#benchmarks))

Pull requests and fresh runners reuse what the default branch compiled. Each job's summary shows its hits, misses and where its time went.

## Details

- `id-token: write` lets the Action sign in with the job's GitHub OIDC token; there is no secret to paste.
- Optional: `select-tests: true` selects the tests a pull request can reach; pushes and other events run everything. Pass `$WARMBUILD_ONLY_TESTING` to `xcodebuild test`.
- If `actions/checkout` uses `path:`, set the Action's `workspace:` input to that folder; otherwise the Swift package cache and the CI report cannot find the checkout.
- Select the Xcode before the Action step (for example `sudo xcode-select -s /Applications/Xcode_27.2.app`, or `maxim-lobanov/setup-xcode`): the cache settings follow the Xcode in use when `xcodebuild` runs, and Xcode 26 and later are supported. Runners need Node 24 for actions (GitHub-hosted runners have it).
- A pull request from a fork gets no OIDC token from GitHub, so the Action prints one notice ("fork pull request: GitHub gives it no OIDC token, so this build runs without the cache"), the job summary says the cache was not used, and the build runs as without Warmbuild. The job stays green. A job missing `id-token: write` gets a warning that names it.
- After the job, the summary shows hits, misses and where the job's time went; the dashboard keeps the history per repository.
- On a fresh runner, the cache fetches what the last build of the same job used before Xcode asks for it, and puts back the Swift packages that build resolved (`packages: false` turns that off). Both need GitHub OIDC: a job that signs in with the `token` input gets entries only as Xcode asks. A matrix names each build with the `build` input.
- On pull requests the Action times Swift type-checking in the targets the change touches, and the CI report names the slowest functions. Those targets compile without the cache in that job; `typecheck: false` turns the timing off.
- Reading the test results takes at most `report-budget` seconds (90); run `xcrun simctl shutdown all` after the tests so a busy Simulator does not slow it down.
- Optional: the `warmbuild/action/test-cache` step between `build-for-testing` and `test-without-building` skips test targets whose built products passed before (see the Action's README).

``` title=".github/workflows/build.yml"
permissions:
  id-token: write
  contents: read
jobs:
  build:
    runs-on: macos-26
    steps:
      - uses: actions/checkout@v5
      - uses: warmbuild/action@v1.14.2
        with:
          select-tests: true   # optional
      - run: xcodebuild build -scheme App -destination 'generic/platform=iOS Simulator'
```

## README badge

A public repository can show in its README how much of its build the cache serves, such as *warmbuild | 94% cached*. Replace `owner/repo` with the repository:

``` title="README.md"
[![Warmbuild](https://warmbuild.dev/badge/owner/repo.svg)](https://warmbuild.dev/checkup/?repo=owner/repo)
```

- The figure is the share of compile tasks served from the cache over the repository’s builds in the last 14 days.
- Only builds whose GitHub OIDC token said the repository is public count. A private repository, or one without builds yet, shows *no builds yet*, and the badge says nothing more about it.
- The number is at most an hour old. The link opens the repository’s CI checkup.
