From a79659b7185bd61ba3f1ec37d0ffb12ea3ea5ad2 Mon Sep 17 00:00:00 2001 From: Lorenzo Delgado Date: Tue, 23 Jan 2024 15:47:41 +0100 Subject: [PATCH 1/2] chore(ci): use cargo-sweep to reduce build artifacts cache size --- .github/workflows/ci.yml | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a4070731..e1f02db9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,15 +24,21 @@ jobs: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - name: Setup Rust toolchain - uses: dtolnay/rust-toolchain@stable + uses: dtolnay/rust-toolchain@master with: toolchain: stable components: rustfmt, clippy - profile: minimal - override: true - - name: Cache Cargo build files - uses: Leafwing-Studios/cargo-cache@5edda26afa3d28be5d6ee87d4c69c246e3ee37fb # v1 + - name: Cache Cargo files + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + save-always: true - name: Prepare build env run: | @@ -43,8 +49,25 @@ jobs: (echo url=https://github.com; echo "username=${GH_USER}"; echo "password=${GH_TOKEN}"; echo ) | git credential approve sudo apt-get install -y lld librdkafka-dev libsasl2-dev - - run: cargo check + - name: Install Cargo-sweep + uses: baptiste0928/cargo-install@v2 + with: + crate: cargo-sweep + + - name: Cache build artifacts + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4 + with: + path: target/ + key: ${{ runner.os }}-build-artifacts-${{ hashFiles('**/Cargo.lock') }} + + # Clean up build artifacts older than 5 days + - name: Sweep Cargo build artifacts + run: cargo sweep --time 5 + - run: cargo fmt --all -- --check + + - run: cargo check + - run: cargo clippy -- -D warnings - name: Unit tests From 2a7d152412dfa4a3f7d0530f56edde032cb7884f Mon Sep 17 00:00:00 2001 From: Lorenzo Delgado Date: Tue, 23 Jan 2024 15:54:29 +0100 Subject: [PATCH 2/2] chore(ci): use cargo-sweep to reduce build artifacts cache size (I) --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1f02db9..b24d3794 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,7 @@ jobs: crate: cargo-sweep - name: Cache build artifacts + id: cache-build-artifacts uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4 with: path: target/ @@ -62,6 +63,7 @@ jobs: # Clean up build artifacts older than 5 days - name: Sweep Cargo build artifacts + if: steps.cache-build-artifacts.outputs.cache-hit == 'true' run: cargo sweep --time 5 - run: cargo fmt --all -- --check