Files
PaperClipAI/server/src/__tests__/runner-image-workflow.test.ts
T
Nicky LeachandClaude Fable 5.2 503a736195 feat(ci): read a registry build cache in the Runner image build (#21310)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The Runner is the part that executes agent work: a daemon
(`paperclip-runnerd`) and a provider pack of agent tools
> - `.github/workflows/runner-image.yml` builds the Runner alone and
publishes it from `master` as `ghcr.io/paperclipai/paperclip-runner`,
one time for each set of inputs
> - The build used no cache, so every run compiled the daemon again. The
first publication took 25m46s from push to tag
> - The toolchain and the daemon change only with the Rust sources. Most
commits that change the Runner's inputs do not touch them
> - This pull request lets the build legs read a registry build cache
for those stages. Only a new job can write the cache, and only for a
`master` push
> - A weekly run builds with no cache, so the cache cannot hide a broken
build for long
> - The benefit is about 3 minutes less on each build leg when the Rust
sources did not change, with no change to the published image

## Linked Issues or Issue Description

Refs #21230 (publication of the Runner image), #21229 and #21204 (the
build this change makes faster). No issue exists for this change.

**What existing behavior does this improve?**

The Runner image build in `.github/workflows/runner-image.yml`. It
builds the same image in less time.

**Current behavior**

Each build leg starts from an empty builder. It installs the Rust
toolchain and compiles the daemon in every run. In the first `master`
publication (run 43365670428) the amd64 leg spent 7m22s in the build
step. The toolchain and the cargo build took 3m26s of that.

**Proposed behavior**

The build legs read
`ghcr.io/paperclipai/paperclip-runner-buildcache:<arch>` for the stages
up to the compiled daemon. A new `cache` job writes that cache after a
publication. A scheduled run builds with no cache one time each week.

**Reason and benefit**

The stages before the last one read the Rust sources, the protocol files
and the toolchain pin. In the last 30 days, 438 `master` commits changed
an input of the image, and at most 181 of them changed a file those
stages read. For the other commits, and for each pull request that does
not touch those files, the build step is about 3 minutes shorter on each
leg.

**Breaking changes**

None. The `Dockerfile` and each file in the image identity are
unchanged. The published digest for a set of inputs does not change.

This is part 4 of 4 of a stack ([stack
#21309](https://github.com/paperclipai/paperclip/stack/21309)). Merge
the parts in order:

1. #21306: the resolver and the no-rebuild mode
2. #21307: the report-only job in `docker.yml` and the pull-request
check of the application image's Runner path
3. #21308: reading a retained provider pack from its Runner image
4. #21310: a registry build cache for the Runner image build (this pull
request)

This pull request uses no code from parts 1 to 3. It is stacked on them
because all four parts edit `doc/runner-image-contract.md`.

## What Changed

- The build legs pass `--cache-from
type=registry,ref=ghcr.io/paperclipai/paperclip-runner-buildcache:<arch>`
to the first build command. They do not log in. Their permissions stay
`contents: read` and `packages: read`.
- A new `cache` job writes the cache with `--cache-to
type=registry,...,mode=max` and `--output type=cacheonly`. It runs only
for a `master` push in the canonical repository, for inputs that had no
image. Its permissions are `contents: read` and `packages: write`. It
has no `id-token` and no `attestations` permission.
- The `cache` job needs the `publish` job, and no job needs the `cache`
job. A cache write cannot delay or fail a publication.
- The `cache` job builds the target `runner-artifacts-runnerd` and no
later stage. The last stage takes the commit as a build argument, so no
other commit can reuse it. The install and its dependency lifecycle
scripts are in that stage, so the job with the write token does not run
them.
- The `cache` job has one concurrency group for each architecture, a job
time limit and a step time limit.
- A `schedule` trigger starts a weekly build. It passes `--no-cache` to
the first command and reads no cache. It runs all checks and publishes
nothing. A fork's schedule runs nothing.
- `server/src/__tests__/runner-image-workflow.test.ts` pins the new
security properties: which jobs hold `packages: write`, that the build
legs have no credential and cannot write the cache, the conditions of
the `cache` job, that the `publish` job does not depend on it, and that
a scheduled run cannot publish or write the cache.
- `doc/runner-image-contract.md` has a "Build cache" section.

## Verification

Tests, on macOS (Node 26.12.0) and in a `node:24.22.3-bookworm`
container (Linux arm64, Node 24.22.3):

- `pnpm exec vitest run src/__tests__/runner-image-workflow.test.ts
src/__tests__/runner-image-identity.test.ts` in `server/`: 55 of 55
tests pass on both.
- `node --test .github/scripts/tests/*.test.mjs`: 807 of 807 tests pass
on both. The container needs `jq`.
- `pnpm verify` exits 2 for this change, because a workflow file is a
global CI input. Required CI supplies the broad coverage.
- Each new assertion fails when the workflow breaks its rule. I checked
seven such edits, for example: the `publish` job needs the `cache` job,
the `cache` job gets `id-token: write`, a build leg gets `--cache-to`.

Cache mechanics, on linux/arm64 with a local registry, BuildKit v0.34.2
(the version the hosted runners use), and an empty builder for each
build:

| Build of both variants | Time | Result |
| --- | --- | --- |
| No cache, cache ref does not exist | 260 s | An importer error in the
log, exit 0 |
| One changed TypeScript file, with the cache | 149 s | Toolchain and
cargo steps cached |
| Unchanged inputs and a new commit, with the cache | 129 s | Toolchain
and cargo steps cached |
| Each stage in the cache (a whole-build cache, which this change does
not write) | 16 s | Both OCI archives complete |
| `--no-cache` on the first command | 272 s | No cached step in the
first command. The second command reuses all of it |

- The images built from the cache pass `runner-image-layout.mjs check`
and `runner-image-oci.mjs check-layers`. The daemon has the same SHA-256
as the daemon of a cold build.
- A cache ref that does not exist, a host that refuses the connection, a
name that does not resolve, and the real
`ghcr.io/paperclipai/paperclip-runner-buildcache:arm64` (which does not
exist yet) each give an importer error in the log and a complete build
with exit 0.
- The `cache` job command on an empty builder with the cache present
takes 6 s. It downloads no layer.

Not tested before merge:

- The `cache` job. It runs only on `master`.
- The scheduled run. It starts only from the default branch.
- The cache package. It does not exist. I did not test a private
package, which answers an anonymous read with an authorization error. I
expect the same importer error and a cold build.
- A fully cached build on the hosted runners. The local test used the
same BuildKit version and a different buildx version (0.37.0, and the
runners have 0.38.1).

## Risks

- **A second job can write packages.** Before this change, only the
`publish` job held `packages: write`, and it runs no build. Now the
`cache` job holds it too, and it runs BuildKit on the repository's
`Dockerfile`. GitHub cannot limit that token to one package, so it can
also write to `ghcr.io/paperclipai/paperclip-runner`. The limits are:
the job runs only for a `master` push in the canonical repository, the
token goes only to the registry login, the build steps run inside
BuildKit without it, the job does not run the install, and the job
cannot sign. An image that it wrote has no attestation.
- **Part of a published image can come from an earlier run.** The daemon
in a published image can come from a step that an earlier `master` run
compiled and cached. The attestation names the run that published, not
the run that compiled. BuildKit reuses a step only for the same
instruction and the same file content, but a party that can write the
cache package can replace what a later build reuses. Write access to the
cache package must stay as narrow as write access to the image package.
- **A cached download is not repeated.** The toolchain installer, the
toolchain and the crates are not downloaded again until the inputs of
their step change. The weekly cold build finds a download that is gone.
It does not compare its output with the cache.
- **A registry failure after the cache import fails the leg.** A cache
that cannot be read at the start is not a failure. A layer download that
fails later is a failure. Run the job again.
- **The cache package starts private.** GitHub creates it on the first
write. A maintainer must make it public one time. Until then each build
runs cold and nothing fails.
- **The first cache write waits for an input change.** The merge of this
pull request changes no input of the image, so its `master` run builds
nothing and writes no cache.
- **A cancelled cache job marks its run as cancelled.** When three cache
writes for one architecture wait at the same time, GitHub cancels the
middle one. The image of that run is published.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

Claude Fable 5.2 (`claude-fable-5-2`), Anthropic, through Claude Code.
Tool use and shell execution. It wrote the change, ran the local builds
and tests, and wrote this description.

## 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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 23:46:15 -08:00

262 lines
16 KiB
TypeScript

import { spawnSync } from "node:child_process";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
import { RUNNER_IMAGE_CONTEXT_INPUTS } from "../../../scripts/runner-image-identity.mjs";
/**
* Security properties of the Runner image workflow. The build runs dependency
* lifecycle scripts and the workflow publishes a signed image, so what each
* job may do matters more than how its steps are worded: these tests pin
* permissions, credentials and gating, not step names or order.
*/
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "..");
const workflow = readFileSync(path.join(repoRoot, ".github", "workflows", "runner-image.yml"), "utf8");
const mergeReview = readFileSync(path.join(repoRoot, ".github", "workflows", "pr-merge-review.yml"), "utf8");
const smoke = readFileSync(path.join(repoRoot, "docker", "runner-image", "Dockerfile.smoke"), "utf8");
/** Each job's text, by name. */
const jobs = Object.fromEntries(workflow.slice(workflow.indexOf("\njobs:\n")).split(/\n(?= {2}[a-z_-]+:\n)/).slice(1)
.map((text) => [/^ {2}([a-z_-]+):/.exec(text)![1], text]));
const permissions = (job: string) =>
[.../\n {4}permissions:\n((?: {6}.+\n)+)/.exec(job)![1].matchAll(/^ {6}([a-z-]+): (\w+)/gm)].map((match) => `${match[1]}: ${match[2]}`);
/** The shell of every `run:`, block or single line. */
const scripts = [...workflow.matchAll(/^( +)run: (\|\n((?:\1 {2,}.*\n|\n)+)|.+\n)/gm)].map((match) => match[3] ?? match[2]);
describe("Runner image workflow", () => {
const repository = "github.repository == 'paperclipai/paperclip' && github.repository_id == '1170821064'";
const canonical = `${repository} && github.event_name == 'push' && github.ref == 'refs/heads/master'`;
const jobCondition = (job: string) => /^ {4}if: (.+)$/m.exec(job)?.[1] ?? "";
/** The steps of a job, without the job's own header. */
const steps = (job: string) => job.slice(job.indexOf("\n steps:\n")).split(/\n(?= {6}- )/).slice(1);
const credential = /github\.token|secrets\.|GITHUB_TOKEN|REGISTRY_PASSWORD/;
it("lets only the publish job write images or sign, and only the cache job write the build cache, never the Actions cache", () => {
expect(workflow).toMatch(/^permissions: \{\}$/m);
expect(Object.keys(jobs)).toEqual(["identity", "build", "publish", "cache"]);
expect(permissions(jobs.identity)).toEqual(["contents: read", "packages: read"]);
expect(permissions(jobs.build)).toEqual(["contents: read", "packages: read"]);
expect(permissions(jobs.publish)).toEqual(["contents: read", "packages: write", "id-token: write", "attestations: write"]);
expect(permissions(jobs.cache)).toEqual(["contents: read", "packages: write"]);
for (const job of [jobs.identity, jobs.build]) {
expect(job).not.toMatch(/docker\/login-action|skopeo|imagetools create|actions\/attest|secrets\.|--push|push=true|cache-to/);
}
expect(Object.keys(jobs).filter((name) => jobs[name].includes("cache-to"))).toEqual(["cache"]);
expect(jobs.cache).not.toMatch(/skopeo|imagetools|actions\/attest|--push|push=true|type=image|type=oci|upload-artifact/);
expect(workflow).not.toMatch(/type=gha|actions\/cache/);
expect(workflow).not.toMatch(/pull_request_target|workflow_run/);
});
it("writes the build cache only for a master push in the canonical repository, never on the way to publication, with the token in the login step alone and no stage past the daemon", () => {
for (const job of [jobs.publish, jobs.cache]) {
expect(jobCondition(job).startsWith(`${canonical} && `)).toBe(true);
expect(jobCondition(job)).not.toContain("||");
}
expect(jobCondition(jobs.cache)).toContain("needs.identity.outputs.lock == 'current'");
for (const job of Object.values(jobs)) expect(/^ {4}needs: (.+)$/m.exec(job)?.[1] ?? "").not.toMatch(/\bcache\b/);
const withCredential = steps(jobs.cache).filter((step) => credential.test(step));
expect(withCredential).toHaveLength(1);
expect(withCredential[0]).toContain("docker/login-action@");
const building = steps(jobs.cache).filter((step) => step.includes("docker buildx build"));
expect(building).toHaveLength(1);
expect([...building[0].matchAll(/--target (\S+)/g)].map((match) => match[1])).toEqual(["runner-artifacts-runnerd"]);
expect(jobs.cache).not.toMatch(/pnpm|setup-node|node scripts/);
});
it("neither publishes nor writes the cache from a scheduled run, and runs nothing on a fork's schedule", () => {
expect(workflow).toMatch(/^ {2}schedule:\n {4}- cron: /m);
expect(canonical).toContain("github.event_name == 'push'");
expect(jobs.build).toContain(`KEEP_IMAGE: \${{ ${canonical} }}`);
expect(jobCondition(jobs.identity)).toBe(`(github.event_name != 'push' && github.event_name != 'schedule') || (${repository})`);
});
const imageBuild = scripts.find((script) => script.includes('--target "$target"'))!;
const bashExpandsEmptyArrays = spawnSync("bash", ["-uc", 'empty=(); : "${empty[@]}"']).status === 0;
function imageBuildCommands(event: string) {
const directory = mkdtempSync(path.join(os.tmpdir(), "runner-image-build-"));
try {
writeFileSync(path.join(directory, "docker"), `#!/bin/sh\nprintf '%s\\n' "$*" >> "$RUNNER_TEMP/docker.log"\n`, { mode: 0o755 });
const run = spawnSync("bash", ["--noprofile", "--norc", "-eo", "pipefail", "-c", imageBuild], {
cwd: directory,
encoding: "utf8",
env: { PATH: `${directory}${path.delimiter}${process.env.PATH}`, RUNNER_TEMP: directory, GITHUB_EVENT_NAME: event, GITHUB_SHA: "a".repeat(40),
BUILD_CACHE: "registry.invalid/buildcache", ARCH: "amd64", PLATFORM: "linux/amd64" },
});
expect(run.status, run.stderr).toBe(0);
return readFileSync(path.join(directory, "docker.log"), "utf8").trimEnd().split("\n");
} finally {
rmSync(directory, { recursive: true, force: true });
}
}
it("replaces the cache read of the image build with --no-cache when the event is a schedule", () => {
expect(imageBuild).toContain('cache=(--cache-from "type=registry,ref=$BUILD_CACHE:$ARCH")\n if [ "$GITHUB_EVENT_NAME" = schedule ]; then cache=(--no-cache); fi\n');
expect(imageBuild).toContain('"${cache[@]}"');
});
it.skipIf(!bashExpandsEmptyArrays)("runs the image build step: a scheduled run builds with --no-cache and no cache read, any other run reads the cache (needs bash 4.4)", () => {
const cacheRead = "--cache-from type=registry,ref=registry.invalid/buildcache:amd64";
const scheduled = imageBuildCommands("schedule");
expect(scheduled.map((command) => /--target (\S+)/.exec(command)?.[1])).toEqual(["runner-artifacts", "runner-artifacts-slim"]);
expect(scheduled[0]).toContain(" --no-cache ");
for (const command of scheduled) expect(command).not.toContain("--cache-from");
for (const event of ["pull_request", "push", "workflow_dispatch"]) {
const commands = imageBuildCommands(event);
expect(commands).toHaveLength(2);
expect(commands[0]).toContain(` ${cacheRead} `);
expect(commands[1]).not.toContain("--cache-from");
for (const command of commands) expect(command).not.toContain("--no-cache");
}
});
it("publishes, and keeps the images for publication, only for a master push in the canonical repository", () => {
expect(jobCondition(jobs.publish).startsWith(`${canonical} && `)).toBe(true);
expect(jobs.publish).toContain(" needs: [identity, build]\n");
expect(jobs.build).toContain(`KEEP_IMAGE: \${{ ${canonical} }}`);
// The one step that hands the images to the publish job is behind that switch.
const uploading = steps(jobs.build).filter((step) => step.includes("upload-artifact"));
expect(uploading).toHaveLength(1);
expect(uploading[0]).toMatch(/^ {8}if: env\.KEEP_IMAGE == 'true' && /m);
// The record is written on every event, so a pull request exercises it. It needs no credential.
const recording = steps(jobs.build).filter((step) => step.includes("runner-image-publish.mjs record"));
expect(recording).toHaveLength(1);
expect(recording[0]).not.toMatch(/KEEP_IMAGE/);
expect(recording[0]).not.toMatch(credential);
// A fork's own pushes run nothing; no job overrides a skipped or failed dependency.
expect(jobCondition(jobs.identity)).toContain(`github.event_name != 'push' && `);
expect(workflow).not.toMatch(/always\(\)|!cancelled\(\)|failure\(\)|continue-on-error/);
});
it("keeps the build legs free of credentials, and lets them read the build cache but not write it", () => {
// No job-level token: the block before the steps holds none, in any job.
for (const job of Object.values(jobs)) expect(job.slice(0, job.indexOf("\n steps:\n"))).not.toMatch(credential);
// The steps that build, check and smoke the image never receive one.
const working = steps(jobs.build).filter((step) => /docker buildx build|runner-image-layout\.mjs|pnpm |upload-artifact/.test(step));
expect(working.length).toBeGreaterThanOrEqual(4);
for (const step of working) expect(step).not.toMatch(credential);
// The one token the legs can see only reads packages, and only a lookup gets it.
for (const step of steps(jobs.build).filter((entry) => credential.test(entry))) {
expect(step).toContain("runner-image-publish.mjs publication-state");
expect(step).not.toContain("--strict");
}
expect(jobs.build).toContain('--cache-from "type=registry,ref=$BUILD_CACHE:$ARCH"');
expect(jobs.build).not.toMatch(/cache-to|docker login|docker\/login-action/);
});
it("writes the full tag last, after a strict lookup and after both images are attested", () => {
// The full tag marks a complete publication, so nothing may follow it
// that can fail to write a tag, and no tag is written on a guess.
const publish = jobs.publish;
const order = [
"publication-state --inputs-digest \"$DIGEST\" --strict\n",
"subject-digest: ${{ steps.slim.outputs.digest }}",
"subject-digest: ${{ steps.full.outputs.digest }}",
'imagetools create -t "$IMAGE:inputs-$DIGEST-slim" "$IMAGE@$SLIM_INDEX"',
'imagetools create -t "$IMAGE:inputs-$DIGEST" "$IMAGE@$FULL_INDEX"',
].map((text) => publish.indexOf(text));
expect(order.every((position) => position >= 0)).toBe(true);
expect([...order].sort((a, b) => a - b)).toEqual(order);
// The final tags are written in one place each; every other tag is a candidate.
expect([...workflow.matchAll(/-t "\$IMAGE:([a-z]+)-/g)].map((match) => match[1])).toEqual(["candidate", "candidate", "inputs", "inputs"]);
// Every step that writes a tag or signs runs only after the strict lookup allowed it.
const writing = steps(publish).filter((step) => /imagetools create|actions\/attest/.test(step));
expect(writing).toHaveLength(5);
for (const step of writing) expect(step).toMatch(/^ {8}if: steps\.gate\.outputs\.publish == 'true'$/m);
expect(publish).toContain("group: runner-image-publish-${{ needs.identity.outputs.digest }}\n cancel-in-progress: false");
});
it("never resolves the lockfile on a master push, and neither builds nor publishes when it is behind", () => {
const resolving = steps(jobs.identity).filter((step) => step.includes("pnpm install"));
expect(resolving).toHaveLength(1);
expect(resolving[0]).toMatch(/^ {8}if: github\.event_name != 'push'$/m);
expect(workflow.match(/pnpm install/g)).toHaveLength(1);
expect(jobCondition(jobs.build).startsWith("needs.identity.outputs.lock == 'current' && ")).toBe(true);
expect(jobCondition(jobs.publish)).toContain("needs.identity.outputs.lock == 'current'");
// Pull requests and manual runs always build; only a push skips an image that exists.
expect(jobCondition(jobs.build)).toContain("github.event_name != 'push' || (");
});
it("pins every action by commit and keeps expressions out of shell scripts", () => {
const uses = [...workflow.matchAll(/^\s*(?:- )?uses: (\S+)/gm)].map((match) => match[1]);
expect(uses.length).toBeGreaterThan(5);
for (const action of uses) expect(action).toMatch(/^[\w.-]+\/[\w./-]+@[0-9a-f]{40}$/);
// An expression in a script is substituted before the shell parses it.
expect(scripts.length).toBeGreaterThan(5);
for (const script of scripts) expect(script).not.toContain("${{");
});
it("gives every image build one export and a time limit", () => {
// A command with two exports stalled on the hosted runners until the job
// was cancelled. One export for each command, and a limit on each step,
// so a stall fails in minutes.
const building = workflow.split(/\n(?= {6}- name: )/).filter((step) => step.includes("docker buildx build"));
expect(building.length).toBeGreaterThanOrEqual(4);
for (const step of building) {
expect(step).toMatch(/^ {8}timeout-minutes: \d+$/m);
for (const command of step.split("docker buildx build").slice(1)) expect(command.match(/--output /g) ?? []).toHaveLength(1);
}
// The trees the checks read come from the archives, not from a second export.
expect(workflow).toContain("node scripts/runner-image-oci.mjs unpack");
expect(workflow.match(/type=local/g)).toHaveLength(3);
});
it("passes the image build exactly two build arguments", () => {
// Build arguments are not part of the image identity, so a new one would
// change what is published under an unchanged digest.
const image = steps(jobs.build).filter((step) => step.includes("--target \"$target\""));
expect(image).toHaveLength(1);
expect([...image[0].matchAll(/--build-arg (\S+)/g)].map((match) => match[1])).toEqual([
'"PAPERCLIP_RUNNER_SOURCE_REVISION=$GITHUB_SHA"',
"PAPERCLIP_RUNNER_IMAGE_PUBLICATION=1",
]);
expect(image[0]).toContain("target=runner-artifacts\n");
expect(image[0]).toContain('if [ "$variant" = slim ]; then target=runner-artifacts-slim; fi');
// No other command passes a build argument, and the identity is computed without one.
expect(workflow.match(/--build-arg /g)).toHaveLength(2);
expect(workflow).not.toMatch(/build-args:|BUILDX_BUILD_ARG|--build-arg-file/);
});
it("runs for a pull request that changes any input of the image identity", () => {
const paths = [...workflow.matchAll(/^ {6}- (\S+)$/gm)].map((match) => match[1]);
const covered = (file: string) => paths.some((pattern) => pattern === file
|| (pattern.endsWith("/**") && (file === pattern.slice(0, -3) || file.startsWith(pattern.slice(0, -2)))));
// .dockerignore is not in the identity, but it decides which files the build receives.
for (const input of ["Dockerfile", ".dockerignore", ".github/workflows/runner-image.yml", "docker/runner-image/Dockerfile.smoke",
"scripts/runner-image-oci.mjs", "scripts/runner-image-publish.mjs", "scripts/standard-image-contract.mjs", ...RUNNER_IMAGE_CONTEXT_INPUTS]) {
expect(covered(input), input).toBe(true);
}
});
it("is registered with the merge-review notifier under its own name", () => {
const name = /^name: (.+)$/m.exec(workflow)![1];
const listed = /workflow_run:\n {4}workflows:\n((?: {6}- .+\n)+)/.exec(mergeReview)![1].split("\n").filter(Boolean).map((line) => line.trim().slice(2));
expect(listed).toContain(name);
});
});
describe("Runner image smoke matrix", () => {
it("runs the daemon on every consumer base, each pinned by digest", () => {
const bases = [...smoke.matchAll(/^FROM (\S+) AS (\S+)$/gm)].map((match) => match[1]).filter((base) => base !== "scratch");
expect(bases.map((base) => base.slice(0, base.indexOf("@")))).toEqual([
"debian:bookworm-slim",
"debian:trixie-slim",
"node:24-trixie-slim",
"python:3.13-slim-trixie",
"daytonaio/sandbox:0.8.0",
]);
for (const base of bases) expect(base).toMatch(/@sha256:[0-9a-f]{64}$/);
expect(smoke.match(/^RUN paperclip-runnerd --build-metadata /gm)).toHaveLength(bases.length);
// The final stage reads a result from every base, so none can be skipped.
expect(smoke.slice(smoke.indexOf("FROM scratch AS smoke")).match(/^COPY --from=smoke-/gm)).toHaveLength(bases.length);
});
it("reads the Runner image only the way a consumer may", () => {
const copies = [...smoke.matchAll(/^COPY --from=runner-artifacts (.+)$/gm)].map((match) => match[1]);
expect(new Set(copies)).toEqual(new Set(["/paperclip-runnerd /usr/local/bin/paperclip-runnerd"]));
expect(smoke).not.toMatch(/^FROM runner-artifacts/m);
});
});