From b389f41cb297dbbe764822233b38b7a31fdcbb96 Mon Sep 17 00:00:00 2001 From: Miles Liu Date: Fri, 4 Nov 2022 14:07:58 +0800 Subject: [PATCH] CI: add use of Swatinem/rust-cache --- .github/workflows/CICD.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index feceeab..7d7a9f1 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -26,6 +26,8 @@ jobs: rustup set profile minimal rustup toolchain install stable -c "clippy,rustfmt" rustup default stable + - name: Rust cache + uses: Swatinem/rust-cache@v2 - name: Ensure `cargo fmt` has been run run: cargo fmt --check - name: Ensure MSRV is set in `clippy.toml` @@ -45,6 +47,8 @@ jobs: rustup set profile minimal rustup toolchain install ${{ env.MIN_SUPPORTED_RUST_VERSION }} -c clippy rustup default ${{ env.MIN_SUPPORTED_RUST_VERSION }} + - name: Rust cache + uses: Swatinem/rust-cache@v2 - name: Run clippy (on minimum supported rust version to prevent warnings we can't fix) run: cargo clippy --locked --all-targets --all-features - name: Run tests @@ -111,13 +115,21 @@ jobs: echo "CARGO_CMD=cargo" >> $GITHUB_ENV echo "CARGO_CMD=cargo" >> $Env:GITHUB_ENV - - name: Install cross + - name: Set cargo cmd to cross if: ${{ matrix.job.use-cross == true }} run: | - cargo install cross echo "CARGO_CMD=cross" >> $GITHUB_ENV echo "CARGO_CMD=cross" >> $Env:GITHUB_ENV + - name: Rust cache + uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.job.os }}-${{ matrix.job.target }} + + - name: Install cross + if: ${{ matrix.job.use-cross == true }} + run: cargo install cross + - name: Build run: ${{ env.CARGO_CMD }} build --locked --release --target=${{ matrix.job.target }}