|
95 | 95 | type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }} |
96 | 96 |
|
97 | 97 | - name: Set up Docker Buildx |
| 98 | + id: buildx |
98 | 99 | uses: docker/setup-buildx-action@v4 |
99 | 100 |
|
| 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 | + |
100 | 131 | - name: Build and push Docker image to GHCR |
101 | 132 | id: push-ghcr |
102 | 133 | uses: docker/build-push-action@v7 |
|
0 commit comments