Skip to content

Commit fbaecf0

Browse files
committed
Add CI caching
1 parent 6aedfce commit fbaecf0

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

.github/scripts/plan.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,24 @@ const allModes = {
3333
name: "clippy",
3434
cargoCommand: "clippy",
3535
cargoArgs: "--all-targets -- -D warnings",
36+
cargoCacheKey: "clippy",
3637
},
3738
test: {
3839
name: "test",
3940
cargoCommand: "test",
41+
cargoCacheKey: "test",
4042
},
4143
build: {
4244
name: "build",
4345
cargoCommand: "build",
46+
cargoCacheKey: "build",
4447
},
4548
fmt: {
4649
name: "fmt",
4750
cargoCommand: "fmt",
4851
cargoArgs: "-- --check",
49-
platformIndependent: true
52+
platformIndependent: true,
53+
cargoCacheKey: "code",
5054
}
5155
};
5256

.github/workflows/code.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ jobs:
6161
- name: Checkout
6262
uses: actions/checkout@v2
6363

64+
- name: Cache rustup
65+
uses: actions/cache@v2
66+
with:
67+
path: |
68+
/usr/share/rust/.rustup
69+
key: ${{ runner.os }}-rustup-${{ hashFiles('rust-toolchain.toml') }}
70+
6471
- name: Install rust toolchain
6572
run: rustup show
6673

@@ -78,6 +85,17 @@ jobs:
7885
cargo clippy --version
7986
env
8087
88+
- name: Cache cargo
89+
uses: actions/cache@v2
90+
with:
91+
path: |
92+
~/.cargo/bin/
93+
~/.cargo/registry/index/
94+
~/.cargo/registry/cache/
95+
~/.cargo/git/db/
96+
target/
97+
key: ${{ runner.os }}-cargo-${{ matrix.mode.cargoCacheKey }}-${{ hashFiles('rust-toolchain.toml', 'Cargo.lock') }}
98+
8199
- name: Run cargo ${{ matrix.mode.cargoCommand }}
82100
uses: actions-rs/cargo@v1
83101
with:

0 commit comments

Comments
 (0)