From e42fdf20581962a57253eaea5d9d65b020f21d5a Mon Sep 17 00:00:00 2001 From: Shark Date: Fri, 29 Mar 2024 02:48:51 +0100 Subject: [PATCH] fix ci caching --- .github/workflows/ci.yaml | 95 ++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 47 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d5cb93bd4..ac68d1d0a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,9 +2,9 @@ name: Rust CI on: push: - branches: [main] + branches: [ main ] pull_request: - branches: [main] + branches: [ main ] env: CARGO_TERM_COLOR: always @@ -15,29 +15,33 @@ jobs: strategy: fail-fast: false matrix: - rust_version: [stable, beta, nightly, 1.73.0, "stable minus 1 release", "stable minus 2 releases"] + rust_version: [ stable, beta, nightly, 1.73.0, "stable minus 1 release", "stable minus 2 releases" ] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust_version }} - - name: Cache cargo registry - uses: actions/cache@v3 - with: - path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.rust_version }} - - name: Cache cargo index - uses: actions/cache@v3 + - name: Cache cargo + uses: actions/cache@v4 with: - path: ~/.cargo/git - key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.rust_version }} + path: ~/.cargo/ + key: ${{ runner.os }}-cargo-registry-${{ matrix.rust_version }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-registry-${{ matrix.rust_version }}- - name: Cache cargo build uses: actions/cache@v3 with: - path: target - key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.rust_version }} + path: ~/work/gosub-engine/gosub-engine/target + key: ${{ runner.os }}-cargo-target-${{ matrix.rust_version }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-target-${{ matrix.rust_version }}- - name: Build run: cargo build --verbose --all --all-features + - name: Clean + run: | + cargo install cargo-sweep + cargo sweep --installed + cargo sweep --time 7 test: runs-on: ubuntu-latest @@ -52,21 +56,20 @@ jobs: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust_version }} - - name: Cache cargo registry - uses: actions/cache@v3 - with: - path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.rust_version }} - - name: Cache cargo index - uses: actions/cache@v3 + - name: Cache cargo + uses: actions/cache@v4 with: - path: ~/.cargo/git - key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.rust_version }} + path: ~/.cargo + key: ${{ runner.os }}-cargo-registry-${{ matrix.rust_version }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-registry-${{ matrix.rust_version }}- - name: Cache cargo build uses: actions/cache@v3 with: - path: target - key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.rust_version }} + path: ~/work/gosub-engine/gosub-engine/target + key: ${{ runner.os }}-cargo-target-${{ matrix.rust_version }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-target-${{ matrix.rust_version }}- - name: Run tests run: cargo test --verbose --all --no-fail-fast --all-features --all-targets @@ -81,21 +84,20 @@ jobs: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust_version }} - - name: Cache cargo registry - uses: actions/cache@v3 - with: - path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.rust_version }} - - name: Cache cargo index - uses: actions/cache@v3 + - name: Cache cargo + uses: actions/cache@v4 with: - path: ~/.cargo/git - key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.rust_version }} + path: ~/.cargo + key: ${{ runner.os }}-cargo-registry-${{ matrix.rust_version }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-registry-${{ matrix.rust_version }}- - name: Cache cargo build uses: actions/cache@v3 with: - path: target - key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.rust_version }} + path: ~/work/gosub-engine/gosub-engine/target + key: ${{ runner.os }}-cargo-target-${{ matrix.rust_version }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-target-${{ matrix.rust_version }}- - name: Run Clippy run: cargo clippy --all --tests -- -D warnings @@ -104,20 +106,19 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - name: Cache cargo registry - uses: actions/cache@v3 - with: - path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}-stable - - name: Cache cargo index - uses: actions/cache@v3 + - name: Cache cargo + uses: actions/cache@v4 with: - path: ~/.cargo/git - key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}-stable + path: ~/.cargo + key: ${{ runner.os }}-cargo-registry-${{ matrix.rust_version }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-registry-${{ matrix.rust_version }}- - name: Cache cargo build uses: actions/cache@v3 with: - path: target - key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}-stable + path: ~/work/gosub-engine/gosub-engine/target + key: ${{ runner.os }}-cargo-target-${{ matrix.rust_version }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-target-${{ matrix.rust_version }}- - name: Run fmt run: cargo fmt --check --all