Fix ARM Rust cache to avoid reinstalling on every build#1665
Fix ARM Rust cache to avoid reinstalling on every build#1665
Conversation
The ARM build installs Rust inside a Docker container, but the Swatinem/rust-cache action runs on the host — so the cache was never hitting. Move CARGO_HOME and RUSTUP_HOME to workspace-relative paths (.rust/) and cache them with actions/cache, which sees the same filesystem as the container mount. Skip rustup install when cargo already exists from a cache restore. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
WalkthroughThis pull request optimizes CI/CD workflows for ARM builds by introducing caching mechanisms and conditional Rust toolchain setup. Changes to 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/build-all.yml:
- Around line 97-106: The ARM cache key for the actions/cache step (conditional
on matrix.os == 'LinuxARM' using actions/cache@v4) must include an explicit
toolchain version component so the cached .rust/ toolchain can be invalidated;
add an environment variable like ARM_RUST_CACHE_VERSION (e.g., stable-2026-03)
and include it in both the `key` and `restore-keys` values for the ARM job so
the cache changes when you bump that variable, ensuring the ARM job does not
remain pinned to an old toolchain.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c8ab3163-3133-4229-928a-567a23287aaa
📒 Files selected for processing (2)
.github/workflows/build-all.yml.github/workflows/scripts/build-arm.sh
| - uses: actions/cache@v4 | ||
| if: ${{ matrix.os == 'LinuxARM' }} | ||
| name: Cache ARM Rust toolchain and build | ||
| with: | ||
| path: | | ||
| .rust/ | ||
| target/ | ||
| key: ${{ matrix.os-name }}-rust-${{ hashFiles('Cargo.lock') }} | ||
| restore-keys: | | ||
| ${{ matrix.os-name }}-rust- |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== ARM cache key ==="
sed -n '97,106p' .github/workflows/build-all.yml
echo
echo "=== ARM toolchain bootstrap logic ==="
sed -n '15,26p' .github/workflows/scripts/build-arm.shRepository: fossas/fossa-cli
Length of output: 1070
🏁 Script executed:
cat -n .github/workflows/build-all.yml | head -100Repository: fossas/fossa-cli
Length of output: 3902
🏁 Script executed:
# Check for rust-toolchain files in the repo
find . -name "rust-toolchain*" -o -name ".rust-version"Repository: fossas/fossa-cli
Length of output: 42
🏁 Script executed:
# Search for Rust version specifications in workflows
rg "rust-version|toolchain" .github/workflows/ -A 2 -B 2Repository: fossas/fossa-cli
Length of output: 2195
Add toolchain versioning to the ARM cache key.
The ARM cache stores .rust/ (the Rust toolchain itself), but its key only changes with Cargo.lock. Non-ARM jobs use dtolnay/rust-toolchain@stable to always install the latest stable Rust, while the ARM job will stay on whatever stable version was cached until the cache expires or Cargo.lock changes. This creates a divergence: ARM can remain on an outdated Rust version indefinitely, breaking independently from other platforms. Add an explicit version component to the cache key, such as an environment variable like ARM_RUST_CACHE_VERSION: stable-2026-03, and include it in both the key and restore-keys fields so you can invalidate the cache when needed.
Suggested direction
jobs:
build-all:
+ env:
+ ARM_RUST_CACHE_VERSION: stable-2026-03
name: ${{ matrix.os-name }}-build
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
@@
- uses: actions/cache@v4
if: ${{ matrix.os == 'LinuxARM' }}
name: Cache ARM Rust toolchain and build
with:
path: |
.rust/
target/
- key: ${{ matrix.os-name }}-rust-${{ hashFiles('Cargo.lock') }}
+ key: ${{ matrix.os-name }}-rust-${{ env.ARM_RUST_CACHE_VERSION }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
- ${{ matrix.os-name }}-rust-
+ ${{ matrix.os-name }}-rust-${{ env.ARM_RUST_CACHE_VERSION }}-🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/build-all.yml around lines 97 - 106, The ARM cache key for
the actions/cache step (conditional on matrix.os == 'LinuxARM' using
actions/cache@v4) must include an explicit toolchain version component so the
cached .rust/ toolchain can be invalidated; add an environment variable like
ARM_RUST_CACHE_VERSION (e.g., stable-2026-03) and include it in both the `key`
and `restore-keys` values for the ARM job so the cache changes when you bump
that variable, ensuring the ARM job does not remain pinned to an old toolchain.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Overview
Fix the Linux ARM build's Rust cache. Currently, Rust gets reinstalled from scratch every run because the cache action runs on the host but the build runs inside a Docker container — they see different filesystems.
Fix: point
CARGO_HOMEandRUSTUP_HOMEto workspace-relative paths that both the host and container can see, then cache those paths.Acceptance criteria
rustupinstall on cache hit.cargo build --releasegets incremental compilation from cachedtarget/.Testing plan
rustupinstall is skipped andcargo buildis incremental.Risks
.rust/dir lives in the workspace during CI only. It's not committed (workspace is ephemeral).Metrics
References
N/A — internal CI improvement.
Checklist
docs/.docs/README.msand gave consideration to how discoverable or not my documentation is.Changelog.md. If this PR did not mark a release, I added my changes into an## Unreleasedsection at the top..fossa.ymlorfossa-deps.{json.yml}, I updateddocs/references/files/*.schema.jsonAND I have updated example files used byfossa initcommand. You may also need to update these if you have added/removed new dependency type (e.g.pip) or analysis target type (e.g.poetry).docs/references/subcommands/<subcommand>.md.