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..3e54e6240 100644 --- a/.github/workflows/code.yml +++ b/.github/workflows/code.yml @@ -9,6 +9,9 @@ defaults: run: shell: bash +env: + CARGO_INCREMENTAL: "0" + jobs: cancel-previous: @@ -61,6 +64,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 +88,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: