From 6dfdfbe514b888c9d132bcb94f1324aac3d6e7c6 Mon Sep 17 00:00:00 2001 From: Cameron Campbell Date: Wed, 23 Jul 2025 00:13:23 +0100 Subject: [PATCH] Cache Rust Dependencies in release.yml. (#1079) --- .github/workflows/ci.yml | 56 +++++++++++++++++++++++++++++++---- .github/workflows/release.yml | 26 ++++++++++++---- 2 files changed, 70 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f7b8a02..6f68febe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,8 +26,14 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable - - name: Rust cache - uses: Swatinem/rust-cache@v2 + - name: Restore Rust Cache + uses: actions/cache/restore@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Setup Aftman uses: ok-nick/setup-aftman@v0.4.2 @@ -40,6 +46,15 @@ jobs: - name: Test run: cargo test --locked --verbose + - name: Save Rust Cache + uses: actions/cache/save@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + msrv: name: Check MSRV runs-on: ubuntu-latest @@ -52,8 +67,14 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@1.70.0 - - name: Rust cache - uses: Swatinem/rust-cache@v2 + - name: Restore Rust Cache + uses: actions/cache/restore@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Setup Aftman uses: ok-nick/setup-aftman@v0.4.2 @@ -63,6 +84,15 @@ jobs: - name: Build run: cargo build --locked --verbose + - name: Save Rust Cache + uses: actions/cache/save@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + lint: name: Rustfmt, Clippy, Stylua, & Selene runs-on: ubuntu-latest @@ -77,8 +107,14 @@ jobs: with: components: rustfmt, clippy - - name: Rust cache - uses: Swatinem/rust-cache@v2 + - name: Restore Rust Cache + uses: actions/cache/restore@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Setup Aftman uses: ok-nick/setup-aftman@v0.4.2 @@ -97,3 +133,11 @@ jobs: - name: Clippy run: cargo clippy + - name: Save Rust Cache + uses: actions/cache/save@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6c299878..4ce868a6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -86,6 +86,15 @@ jobs: with: targets: ${{ matrix.target }} + - name: Restore Rust Cache + uses: actions/cache/restore@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Setup Aftman uses: ok-nick/setup-aftman@v0.4.2 with: @@ -93,10 +102,15 @@ jobs: - name: Build Release run: cargo build --release --locked --verbose --target ${{ matrix.target }} - env: - # Build into a known directory so we can find our build artifact more - # easily. - CARGO_TARGET_DIR: output + + - name: Save Rust Cache + uses: actions/cache/save@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Generate Artifact Name shell: bash @@ -113,11 +127,11 @@ jobs: mkdir staging if [ "${{ matrix.host }}" = "windows" ]; then - cp "output/${{ matrix.target }}/release/$BIN.exe" staging/ + cp "target/${{ matrix.target }}/release/$BIN.exe" staging/ cd staging 7z a ../$ARTIFACT_NAME * else - cp "output/${{ matrix.target }}/release/$BIN" staging/ + cp "target/${{ matrix.target }}/release/$BIN" staging/ cd staging zip ../$ARTIFACT_NAME * fi