Skip to content

perf(ci): keep the image build cache in GHCR #6404

Description

@dan-petty

Problem

The release writes the build cache of the service, runner and mcp-server images to the GitHub Actions cache (type=gha, release.yml:433, 574 and 710). In run 44415593173 the three exports took 140.6, 61.3 and 140.2 s, and the repository cache use is 10.5 GB. The devcontainer release already writes a registry cache (release.yml:218-219), and its export took 14.4 s.

Change

Renovate. No change.

Risk. The first release after the merge has a cold cache. The packages are public, so a read needs no credentials.

Proof

  • The release step 'exporting cache to registry' takes less time than today's gha export (140.6, 61.3 and 140.2 s in run 44415593173).
  • After the old blobs go, uv run devops gh api repos/dan-petty/devops-cli/actions/cache/usage shows less than today's 10.5 GB.
  • A PR build log shows CACHED steps from the registry.

Depends on: none

Alternatives check of 2026-11-19: not-applicable.
Class: perf, no search.
Tool: none found.

Proposed design

Problem statement

The release writes the build cache of the service, runner and mcp-server images to the GitHub Actions cache. In run 44415593173 the three exports took 140.6, 61.3 and 140.2 s, and the repository cache use is 10.5 GB. The devcontainer release writes a registry cache instead, and its export took 14.4 s. This change moves the three caches to ghcr.io/dan-petty/devops-cli/<image>:buildcache with mode=max. It keeps release.yml as the only writer. It makes the ci.yml image jobs and service-image-test.yml read the same ref. It also changes the tree check and the container-image-layers spec delta.

Acceptance criteria

Requirement: Release reads and writes the registry cache

The release.yml image builds of service, runner and mcp-server SHALL read and write ghcr.io/dan-petty/devops-cli/<image>:buildcache with cache-from: type=registry and cache-to: type=registry,...,mode=max, and SHALL write no type=gha entry.

Scenario: Tree check passes on the release workflow

  • WHEN uv run devops ci --check --only test-tree runs on the changed release.yml
  • THEN it exits 0 and prints no failure line for release.yml.

Requirement: Read jobs reuse the registry cache

The image jobs of ci.yml and service-image-test.yml SHALL read cache-from: type=registry,ref=ghcr.io/dan-petty/devops-cli/<image>:buildcache and SHALL write no cache.

Scenario: Tree check passes on the read jobs

  • WHEN uv run devops ci --check --only test-tree runs on the changed ci.yml and service-image-test.yml
  • THEN it exits 0 and prints no failure line for either workflow.

Requirement: Tree check enforces the registry ref

tests/gate/tree_checks/image_cache.py SHALL require a registry cache-to with mode=max and a registry cache-from with :buildcache for each image build, and SHALL report a type=gha entry as a failure.

Scenario: Tree check passes on the changed tree

  • WHEN uv run devops ci --check --only test-tree runs
  • THEN it exits 0 and prints no failure line.

Requirement: Spec delta names the registry ref

The change's spec delta for container-image-layers SHALL replace the per-image gha scope with the per-image registry :buildcache ref.

Scenario: OpenSpec validates the change

  • WHEN uv run openspec validate --strict runs
  • THEN it exits 0 and reports no validation error.

Existing Tool Considered

The alternatives check of 2026-11-19 records not-applicable for this perf item, with no search and tool none found; the issue body holds the check. The check names no tool and lists no coverage or gap. The open, maintained tool that covers the need is the BuildKit registry cache backend (type=registry). docker/setup-buildx-action provides it, and the devcontainer release already uses it at .github/workflows/release.yml:218-219. The proposal writes mode=max to the per-image tag ghcr.io/dan-petty/devops-cli/<image>:buildcache and reads the same tag from the CI jobs. The backend has no policy to remove old cache blobs or to keep the :buildcache tag. The retention job of #4816 must keep the tag. The first release after the merge reads a cold cache. The GHCR packages are public, so a read needs no credentials.

Key questions

  • Which workflow cache entries change?: release.yml has cache-to at lines 433, 574 and 710 and cache-from at lines 375 and 430. ci.yml has cache-from at lines 490, 609 and 723. service-image-test.yml has one cache-from for the service image. Each entry moves to the registry ref of its image. [sources: .github/workflows/release.yml:375, .github/workflows/release.yml:430, .github/workflows/release.yml:433, .github/workflows/release.yml:574, .github/workflows/release.yml:710, .github/workflows/ci.yml:490, .github/workflows/ci.yml:609, .github/workflows/ci.yml:723, .github/workflows/service-image-test.yml]
  • Which cache backend do the three image builds use?: Use the BuildKit registry cache backend (type=registry) at a per-image GHCR tag. (best practice) [sources: .github/workflows/release.yml:218, .github/workflows/release.yml:433]
    • Rejected: GitHub Actions cache (type=gha). The three exports took 140.6, 61.3 and 140.2 s, and the repository cache use is 10.5 GB.
    • Chosen: Registry cache (type=registry). The devcontainer release already uses it at release.yml:218-219, and its export took 14.4 s.
  • Which tag holds the cache of each image?: Use one tag for each image: ghcr.io/dan-petty/devops-cli/<image>:buildcache. (best practice) [sources: tests/gate/tree_checks/image_cache.py, .github/workflows/release.yml:433]
    • Chosen: Per-image tag. Each build keeps its own cache, and the tree check already requires a per-target scope.
    • Rejected: One shared tag. A second image replaces the cache index of the first image.
  • Which job writes the registry cache?: Only release.yml writes the cache. The ci.yml image jobs and service-image-test.yml only read it. (best practice) [sources: .github/workflows/release.yml:433, .github/workflows/ci.yml:490, .github/workflows/service-image-test.yml]
  • Which cache mode does the export use?: Use mode=max, because it keeps all layers and the tree check requires it for a cache-to. (best practice) [sources: tests/gate/tree_checks/image_cache.py]
    • Chosen: mode=max. It keeps the full layer cache, and the tree check requires it for a write.
    • Rejected: mode=min. It keeps only the final layer, so a later build restores less.
  • How does the tree check enforce the registry ref?: Rewrite both checks of tests/gate/tree_checks/image_cache.py. Each cache-to must name a registry ref with mode=max. Each cache-from must name the registry ref with :buildcache. A type=gha entry is a failure. (best practice) [sources: tests/gate/tree_checks/image_cache.py]
    • Chosen: Rewrite the two existing checks. They already check the scope of each entry and the mode=max of a write.
    • Rejected: Add a third check. It duplicates the scope and mode checks and leaves the old gha checks in place.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/infra
    scope/ci
    source/agent
    status/new
    on Nov 19, 2026
  2. dan-petty commented on Nov 19, 2026

    @dan-petty
    OwnerAuthor
  3. added
    value/medium
    effort/medium
    priority/p2-medium
    on Nov 19, 2026
  4. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  5. added
    status/ready
    and removed
    status/new
    on Nov 19, 2026
  6. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  7. added
    owner/agent
    status/in-progress
    and removed
    status/ready
    on Nov 20, 2026
  8. added
    status/in-review
    and removed
    status/in-progress
    on Nov 20, 2026
  9. removed
    status/in-review
    owner/agent
    on Nov 20, 2026
  10. added a commit that references this issue on Nov 20, 2026
  11. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor
  12. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-20 18:13 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/cisource/agenttype/infravalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions