From df42261bfce69159e947bbb89127a644e5501ed9 Mon Sep 17 00:00:00 2001 From: Chawye Hsu Date: Wed, 26 Jul 2023 00:00:52 +0800 Subject: [PATCH] chore(ci): setup cargo cache to speed up cicd Signed-off-by: Chawye Hsu --- .github/workflows/cicd.yml | 58 ++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 6a3b847..9909c62 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -9,8 +9,8 @@ permissions: contents: write pull-requests: write jobs: - # Check code style - check_cargo_style: + # Check code style and tests + check_cargo_base: name: Check Code Style runs-on: windows-latest steps: @@ -20,36 +20,34 @@ jobs: - name: Setup Rust uses: dtolnay/rust-toolchain@stable with: + profile: minimal toolchain: stable components: clippy, rustfmt + - name: Setup Cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Format Check run: cargo fmt -- --check - name: Clippy Check run: cargo clippy - # Check tests - check_cargo_test: - name: Check Tests - needs: check_cargo_style - runs-on: windows-latest - steps: - - name: Checkout Source - uses: actions/checkout@v3 - - - name: Setup Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - - - name: Test Check + - name: Tests Check run: cargo test --workspace # Check build check_cargo_build: name: Check Dev Build - needs: check_cargo_test + needs: check_cargo_base strategy: fail-fast: false matrix: @@ -65,9 +63,21 @@ jobs: - name: Setup Rust uses: dtolnay/rust-toolchain@stable with: + profile: minimal toolchain: stable target: ${{ matrix.target }} + - name: Setup Cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Build Check run: cargo build --locked --target ${{ matrix.target }} @@ -118,9 +128,21 @@ jobs: - name: Setup Rust uses: dtolnay/rust-toolchain@stable with: + profile: minimal toolchain: stable target: ${{ matrix.target }} + - name: Setup Cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Build uses: actions-rs/cargo@v1.0.3 with: