From 7159018b5eeff341038824364dd81221aab8f8cf Mon Sep 17 00:00:00 2001 From: Ori Ziv Date: Thu, 11 Jun 2026 17:06:50 +0300 Subject: [PATCH 1/3] opt(ci): cache Rust build artifacts on macOS test job The macOS test job had no Swatinem/rust-cache step, so it recompiled the entire workspace from scratch on every run (~13m of cold compile on runners that cost ~10x the Linux ones). Add the cache step, matching the Linux job. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d9af8ceb..c9ab21c7f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -187,6 +187,8 @@ jobs: components: clippy - name: Rust `$PATH` workaround. run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH + - name: Retreive cached dependecies + uses: Swatinem/rust-cache@v2 - uses: Homebrew/actions/setup-homebrew@master - name: Install deps run: make deps From f12f39ad327be72a217af4e383e9a9b9ee3d57cf Mon Sep 17 00:00:00 2001 From: Ori Ziv Date: Thu, 11 Jun 2026 17:11:57 +0300 Subject: [PATCH 2/3] opt(ci): cache Docker build to make it incremental across runs The dockerfile job ran `docker build .` with no caching, so the full release-LTO build of the workspace re-ran from scratch every time (~32m). Plain layer caching wouldn't help: `COPY . ` precedes `make deps`/`make build`, so any source change busts every layer after it. Instead, mount the cargo registry/git and target dirs as BuildKit cache mounts in the Dockerfile (incremental compile, contents kept out of the final image), and persist them across ephemeral runners via actions/cache + buildkit-cache-dance. The first run is cold; subsequent runs reuse the build cache. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/ci.yml | 32 +++++++++++++++++++++++++++++++- Dockerfile | 14 ++++++++++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9ab21c7f..86e24ea57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -223,8 +223,38 @@ jobs: sudo rm -rf /usr/share/dotnet/ sudo rm -rf /usr/local/lib/android df -h + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Cache cargo registry and build artifacts + uses: actions/cache@v4 + id: docker-build-cache + with: + path: | + cargo-registry-cache + cargo-git-cache + target-cache + key: docker-build-cache-${{ hashFiles('Cargo.lock') }} + restore-keys: | + docker-build-cache- + # Inject the cached dirs into the BuildKit cache mounts used by the + # Dockerfile (and extract them back out afterwards for actions/cache to + # persist). Without this the cache mounts start empty on every ephemeral + # runner and the full release build re-runs from scratch. + - name: Inject build cache into Docker + uses: reproducible-containers/buildkit-cache-dance@v3.1.2 + with: + cache-map: | + { + "cargo-registry-cache": "/root/.cargo/registry", + "cargo-git-cache": "/root/.cargo/git", + "target-cache": "/cairo_native/target" + } + skip-extraction: ${{ steps.docker-build-cache.outputs.cache-hit }} - name: build image - run: docker build . + uses: docker/build-push-action@v6 + with: + context: . + push: false build-sierra-emu: name: Build sierra-emu diff --git a/Dockerfile b/Dockerfile index ddc537821..b5bf0a772 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,5 +33,15 @@ WORKDIR /cairo_native/ ENV MLIR_SYS_190_PREFIX=/usr/lib/llvm-19 ENV LLVM_SYS_191_PREFIX=/usr/lib/llvm-19 ENV TABLEGEN_190_PREFIX=/usr/lib/llvm-19 -RUN make deps -RUN make build +# The cargo registry/git and target dirs are mounted as BuildKit caches so the +# (slow, release-LTO) Rust build is incremental across CI runs. They are cache +# mounts rather than image layers: the contents are not part of the final image, +# which only needs to prove the build succeeds. +RUN --mount=type=cache,target=/root/.cargo/registry \ + --mount=type=cache,target=/root/.cargo/git \ + --mount=type=cache,target=/cairo_native/target \ + make deps +RUN --mount=type=cache,target=/root/.cargo/registry \ + --mount=type=cache,target=/root/.cargo/git \ + --mount=type=cache,target=/cairo_native/target \ + make build From 8331915ac65a9a47c613879abab85bffeb27c260 Mon Sep 17 00:00:00 2001 From: Ori Ziv Date: Thu, 11 Jun 2026 18:30:32 +0300 Subject: [PATCH 3/3] opt(ci): drop unnecessary work from CI jobs - unused-deps: cargo-machete only parses Cargo manifests, so it needs neither LLVM nor a compiled workspace. Remove the LLVM install/repo steps and env (also one fewer apt.llvm.org dependency to flake). - test: replace `apt-get update && apt-get upgrade -y` with just `apt-get update`; the job only needs the pinned LLVM-19 packages, not a full system upgrade (~41s). --- .github/workflows/ci.yml | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86e24ea57..78062cdd1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,25 +86,14 @@ jobs: unused-deps: name: No unused dependencies runs-on: ubuntu-24.04 - env: - MLIR_SYS_190_PREFIX: /usr/lib/llvm-19/ - LLVM_SYS_191_PREFIX: /usr/lib/llvm-19/ - TABLEGEN_190_PREFIX: /usr/lib/llvm-19/ steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: toolchain: nightly components: rustfmt - - - name: add llvm deb repository - uses: myci-actions/add-deb-repo@11 - with: - repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main - repo-name: llvm-repo - keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key - - name: Install LLVM - run: sudo apt-get install llvm-19 llvm-19-dev llvm-19-runtime clang-19 clang-tools-19 lld-19 libpolly-19-dev libmlir-19-dev mlir-19-tools + # cargo-machete only parses Cargo manifests/sources, so it needs neither + # LLVM nor a compiled workspace. - name: Machete uses: bnjbvr/cargo-machete@main @@ -153,7 +142,7 @@ jobs: repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main repo-name: llvm-repo keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key - - run: sudo apt-get update && sudo apt-get upgrade -y + - run: sudo apt-get update - name: Install LLVM run: sudo apt-get install llvm-19 llvm-19-dev llvm-19-runtime clang-19 clang-tools-19 lld-19 libpolly-19-dev libmlir-19-dev mlir-19-tools - name: Install deps