Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache builds in CI #20

Merged
merged 2 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/scripts/plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
};

Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ defaults:
run:
shell: bash

env:
CARGO_INCREMENTAL: "0"

jobs:

cancel-previous:
Expand Down Expand Up @@ -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

Expand All @@ -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:
Expand Down