mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
Replace manual caching with Swatinem/rust-cache
Switch to the industry-standard Swatinem/rust-cache action which: - Automatically handles all Rust caching complexity - Works perfectly with cross-compilation matrix builds - Doesn't conflict with incremental compilation - Provides better cache hit rates - Is more reliable than sccache GHA service Also added --locked flag to cargo build commands for reproducible builds. This should significantly improve build times and reliability.
This commit is contained in:
@@ -104,37 +104,16 @@ jobs:
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
# Cache cargo registry and build artifacts
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v4
|
||||
# Smart caching for Rust builds - handles everything automatically
|
||||
- name: Setup Rust Cache
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/bin/
|
||||
~/.cargo/registry/index/
|
||||
~/.cargo/registry/cache/
|
||||
~/.cargo/git/db/
|
||||
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-registry-
|
||||
|
||||
# Cache target directory with matrix-specific key
|
||||
- name: Cache target directory
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: codex-rs/target
|
||||
key: ${{ runner.os }}-target-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/*.rs') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-target-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}-
|
||||
${{ runner.os }}-target-${{ matrix.target }}-
|
||||
|
||||
# Use sccache for additional compilation caching
|
||||
- name: Install sccache
|
||||
uses: mozilla-actions/[email protected]
|
||||
|
||||
- name: Configure sccache
|
||||
run: |
|
||||
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
|
||||
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
|
||||
# Ensure cache is unique per target
|
||||
key: ${{ matrix.target }}
|
||||
# Cache on failure to speed up debugging
|
||||
cache-on-failure: true
|
||||
# Working directory for the cache
|
||||
workspaces: "codex-rs -> target"
|
||||
|
||||
- name: Install musl tools (Linux)
|
||||
if: contains(matrix.target, 'musl')
|
||||
@@ -175,9 +154,9 @@ jobs:
|
||||
cd codex-rs
|
||||
# Use all available cores
|
||||
export CARGO_BUILD_JOBS=$(($(nproc || sysctl -n hw.ncpu || echo 2) * 2))
|
||||
# Note: CARGO_INCREMENTAL is disabled when using sccache
|
||||
echo "Building with $CARGO_BUILD_JOBS parallel jobs"
|
||||
cargo build --release --target ${{ matrix.target }} --bin coder --bin coder-tui --bin coder-exec
|
||||
# Use --locked to ensure reproducible builds
|
||||
cargo build --release --locked --target ${{ matrix.target }} --bin coder --bin coder-tui --bin coder-exec
|
||||
|
||||
- name: Prepare artifacts
|
||||
run: |
|
||||
|
||||
@@ -95,28 +95,16 @@ jobs:
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
# Smart caching for Rust builds - handles everything automatically
|
||||
- name: Setup Rust Cache
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/bin/
|
||||
~/.cargo/registry/index/
|
||||
~/.cargo/registry/cache/
|
||||
~/.cargo/git/db/
|
||||
${{ github.workspace }}/codex-rs/target/
|
||||
key: cargo-release-${{ matrix.runner }}-${{ matrix.target }}-release-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/*.rs') }}
|
||||
restore-keys: |
|
||||
cargo-release-${{ matrix.runner }}-${{ matrix.target }}-release-${{ hashFiles('**/Cargo.lock') }}-
|
||||
cargo-release-${{ matrix.runner }}-${{ matrix.target }}-release-
|
||||
|
||||
# Use sccache for additional compilation caching
|
||||
- name: Install sccache
|
||||
uses: mozilla-actions/[email protected]
|
||||
|
||||
- name: Configure sccache
|
||||
shell: bash
|
||||
run: |
|
||||
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
|
||||
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
|
||||
# Ensure cache is unique per target
|
||||
key: ${{ matrix.target }}
|
||||
# Cache on failure to speed up debugging
|
||||
cache-on-failure: true
|
||||
# Working directory for the cache
|
||||
workspaces: "codex-rs -> target"
|
||||
|
||||
- if: ${{ matrix.target == 'x86_64-unknown-linux-musl' || matrix.target == 'aarch64-unknown-linux-musl'}}
|
||||
name: Install musl build tools
|
||||
@@ -128,9 +116,9 @@ jobs:
|
||||
run: |
|
||||
# Use all available cores
|
||||
export CARGO_BUILD_JOBS=$(($(nproc || sysctl -n hw.ncpu || echo 2) * 2))
|
||||
# Note: CARGO_INCREMENTAL is disabled when using sccache
|
||||
echo "Building with $CARGO_BUILD_JOBS parallel jobs"
|
||||
cargo build --target ${{ matrix.target }} --release --bin coder
|
||||
# Use --locked to ensure reproducible builds
|
||||
cargo build --target ${{ matrix.target }} --release --locked --bin coder
|
||||
|
||||
- name: Stage artifacts
|
||||
shell: bash
|
||||
|
||||
Reference in New Issue
Block a user