Skip to content

Commit 013b4a0

Browse files
ZaynJarvisclaude
andauthored
ci: persist BuildKit mount caches across runs (#4421)
* ci: persist BuildKit mount caches across runs Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * ci: key mount caches on native-build inputs, drop npm/uv from cache-map Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 66c1656 commit 013b4a0

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

.github/workflows/build-docker-image.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,39 @@ jobs:
9595
type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }}
9696
9797
- name: Set up Docker Buildx
98+
id: buildx
9899
uses: docker/setup-buildx-action@v4
99100

101+
# Persist the Dockerfile's cargo/ccache RUN --mount=type=cache dirs across
102+
# runs. On ephemeral runners they start empty, so the Rust CLI and C++
103+
# extension recompile from scratch every build (~13 min of a ~16 min job).
104+
# Key on the native-build inputs, not the commit sha: commits that do not
105+
# touch Rust/C++ hit the exact key, which also skips the cache upload, so
106+
# this stays quiet inside the repo's shared 10 GB Actions cache budget.
107+
# npm/uv mounts are deliberately not persisted: they only save ~1 min and
108+
# would churn the cache on every dependency change.
109+
- name: Restore BuildKit mount caches
110+
id: mount-cache
111+
uses: actions/cache@v4
112+
with:
113+
path: buildkit-mount-cache
114+
key: buildkit-mount-${{ matrix.arch }}-${{ hashFiles('Cargo.toml', 'Cargo.lock', 'crates/**', 'src/**', 'third_party/**', 'setup.py') }}
115+
restore-keys: |
116+
buildkit-mount-${{ matrix.arch }}-
117+
118+
- name: Inject mount caches into BuildKit
119+
uses: reproducible-containers/buildkit-cache-dance@v3.4.0
120+
with:
121+
builder: ${{ steps.buildx.outputs.name }}
122+
cache-map: |
123+
{
124+
"buildkit-mount-cache/cargo-target": {"target": "/cargo-target", "id": "cargo-target-${{ matrix.platform }}"},
125+
"buildkit-mount-cache/cargo-registry": {"target": "/usr/local/cargo/registry", "id": "cargo-registry-${{ matrix.platform }}"},
126+
"buildkit-mount-cache/cargo-git": {"target": "/usr/local/cargo/git", "id": "cargo-git-${{ matrix.platform }}"},
127+
"buildkit-mount-cache/ccache": {"target": "/root/.ccache", "id": "ccache-${{ matrix.platform }}"}
128+
}
129+
skip-extraction: ${{ steps.mount-cache.outputs.cache-hit }}
130+
100131
- name: Build and push Docker image to GHCR
101132
id: push-ghcr
102133
uses: docker/build-push-action@v7

0 commit comments

Comments
 (0)