Files
PaperClipAI/.github
DottaandPaperclip cb39f99a39 perf(ci): parallelize Runner image checks and shrink smoke build context (#22987)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The Runner image workflow (`.github/workflows/runner-image.yml`)
builds and verifies `ghcr.io/paperclipai/paperclip-runner` for `amd64`
and `arm64` whenever Runner inputs change
> - Profiling a recent `master` run showed `Build and check (amd64)`
taking 12m 30s versus 5m 03s on `arm64`, with ~2m 25s spent serially
deleting directories in `Free runner disk`, 36s serially unpacking
`full` and `slim`, 35s serially verifying layout/pack integrity for
`full` and `slim`, and extra BuildKit transfer time streaming the entire
~1.5 GB `slim` directory to `Dockerfile.smoke` even though it only reads
`/paperclip-runnerd`
> - Because `docker.yml` waits for the published Runner image when
Runner inputs change, slow `amd64` Runner image steps sit directly on
the release critical path
> - This pull request parallelizes `Free runner disk` (with a `>= 50
GiB` skip), parallelizes `full`/`slim` unpacking and layout checks, and
stages a minimal single-file `smoke-context` containing only
`/paperclip-runnerd` for the smoke matrix build
> - The benefit is saving ~2.5 minutes on `Build and check (amd64)`
without changing any built image bytes, security boundaries, or
verification checks

## Linked Issues or Issue Description

**What existing behavior does this improve?**
Non-build overhead in the `build` job (`Build and check (amd64/arm64)`)
of `.github/workflows/runner-image.yml`.

**Subsystem affected**
Cross-cutting (multiple of the above)

**Current behavior**
In `.github/workflows/runner-image.yml`, `Free runner disk` deletes nine
large tool directories sequentially (~2m 25s on `ubuntu-latest`),
`Unpack both images` and `Check the layout contract and pack integrity`
process `full` and `slim` sequentially (~71s combined), and `Run the
daemon on every consumer base image` passes the entire ~1.5 GB
`$RUNNER_TEMP/runner-image/slim` directory as `--build-context
runner-artifacts=...` even though `Dockerfile.smoke` only copies
`/paperclip-runnerd`.

**Proposed behavior**
`Free runner disk` skips cleanup when `/` already has `>= 50 GiB`
available and otherwise runs cleanup operations concurrently. `Unpack
both images` and `Check the layout contract and pack integrity` run
`full` and `slim` concurrently while collecting exit statuses from both
processes so any failure still fails the step. `Run the daemon on every
consumer base image` copies only `/paperclip-runnerd` into
`$RUNNER_TEMP/runner-image/smoke-context` and passes that minimal
directory as `--build-context runner-artifacts=...`.

**Reason and benefit**
Cuts ~2.5 minutes off `Build and check (amd64)` while keeping every
security invariant, artifact layout check, pack integrity check, and
five-base-image daemon smoke check identical.

**Breaking changes**
None.

## What Changed

- Parallelized `Free runner disk` in
`.github/workflows/runner-image.yml` and added a `>= 50 GiB` free-space
fast-path skip.
- Parallelized `full` and `slim` inside `Unpack both images` and `Check
the layout contract and pack integrity`, preserving strict failure
propagation across both background PIDs.
- Staged a minimal single-file `$RUNNER_TEMP/runner-image/smoke-context`
containing only `/paperclip-runnerd` for `Run the daemon on every
consumer base image` instead of streaming the full ~1.5 GB `slim` tree
to BuildKit.
- Extended `server/src/__tests__/runner-image-workflow.test.ts` to pin
the minimal smoke context staging alongside the existing
`Dockerfile.smoke` copy assertion.

## Verification

- Vitest workflow security and contract suite:
`server/src/__tests__/runner-image-workflow.test.ts` (16/16 passed)
- Workflow run on this PR exercises `Runner image` (`Build and check
(amd64)` and `(arm64)`) end-to-end because
`.github/workflows/runner-image.yml` is in the PR path filter.

## Risks

- Low risk. `full` and `slim` unpack into disjoint directories and
`runner-image-layout.mjs check` creates isolated temporary directories
via `mkdtempSync`. `Dockerfile.smoke` is already pinned by
`runner-image-workflow.test.ts` to only `COPY --from=runner-artifacts
/paperclip-runnerd /usr/local/bin/paperclip-runnerd`. No job
permissions, credentials, actions, or published image bytes change.

## Model Used

- Gemini 3 Pro (Antigravity agent with tool use, shell execution, and
local test verification)

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-25 14:21:48 -06:00
..