From 2f39cffa1700bfd1dc9664995ed88b673a3c8051 Mon Sep 17 00:00:00 2001 From: MOZGIII Date: Sun, 13 Jun 2021 14:43:36 +0300 Subject: [PATCH] Add CI caching --- .github/scripts/plan.js | 6 +++++- .github/workflows/code.yml | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/scripts/plan.js b/.github/scripts/plan.js index 54ea09ee1..4d418e482 100644 --- a/.github/scripts/plan.js +++ b/.github/scripts/plan.js @@ -33,20 +33,24 @@ const allModes = { name: "clippy", cargoCommand: "clippy", cargoArgs: "--all-targets -- -D warnings", + cargoCacheKey: "clippy", }, test: { name: "test", cargoCommand: "test", + cargoCacheKey: "test", }, build: { name: "build", cargoCommand: "build", + cargoCacheKey: "build", }, fmt: { name: "fmt", cargoCommand: "fmt", cargoArgs: "-- --check", - platformIndependent: true + platformIndependent: true, + cargoCacheKey: "code", } }; diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml index 3bab340d1..a2c8fc0cb 100644 --- a/.github/workflows/code.yml +++ b/.github/workflows/code.yml @@ -61,6 +61,13 @@ jobs: - name: Checkout uses: actions/checkout@v2 + - name: Cache rustup + uses: actions/cache@v2 + with: + path: | + /usr/share/rust/.rustup + key: ${{ runner.os }}-rustup-${{ hashFiles('rust-toolchain.toml') }} + - name: Install rust toolchain run: rustup show @@ -78,6 +85,17 @@ jobs: cargo clippy --version env + - name: Cache cargo + uses: actions/cache@v2 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ matrix.mode.cargoCacheKey }}-${{ hashFiles('rust-toolchain.toml', 'Cargo.lock') }} + - name: Run cargo ${{ matrix.mode.cargoCommand }} uses: actions-rs/cargo@v1 with: