Skip to content

Commit 8b15368

Browse files
committed
Auto merge of #2142 - jtgeibel:ci/actions/improve-caching, r=pietroalbini
CI: Include rustc version in key for `target/` cache Based on a solution suggested by @pietroalbini. I plan to push a few more things to this branch to test things and will probably drop the cache of rustc. So for now, r? @ghost
2 parents 5c04e53 + 239ec4b commit 8b15368

File tree

1 file changed

+16
-36
lines changed

1 file changed

+16
-36
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -86,39 +86,16 @@ jobs:
8686
fi
8787
echo "::add-path::$HOME/.cargo/bin"
8888
89-
# FIXME: Nightly and beta channels have high churn. The cache quickly expires, but there is
90-
# no way (that I can find) to overwrite an existing cache. There is also no way to
91-
# dynamically include the latest version number for a release channel into the cache `key`
92-
# value. Once a cached release becomes stale, every job will begin downloading the latest
93-
# release from upstream and the cache becomes useless for that channel.
89+
# Cache `diesel` binary
9490
#
95-
# Including `hashFiles('**/Cargo.lock')` below is a hack. Ideally, we would change the `key`
96-
# for each channel at the same rate as the release cadence for that channel. For the stable
97-
# channel this is too frequent and for the nightly channel (and probably beta as well) it is
98-
# not often enough.
99-
#
100-
# Current size as of 2019-12-23: ~123 MB
101-
- name: Cache rustup
102-
uses: actions/cache@v1
103-
with:
104-
path: ~/.rustup
105-
key: ${{ runner.os }}-rustup-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
106-
restore-key: |
107-
${{ runner.os }}-rustup-${{ matrix.rust }}-
108-
${{ runner.os }}-rustup-
109-
110-
# This step has the same tradeoffs as `Cache rustup`, however the cache size is significantly
111-
# smaller. The installed `diesel` binary is also stored here.
91+
# The other binaries (like `rustc`) will be overwritten by rustup.
11292
#
11393
# Current size as of 2019-12-23: ~6 MB
11494
- name: Cache cargo binaries
11595
uses: actions/cache@v1
11696
with:
11797
path: ~/.cargo/bin
118-
key: ${{ runner.os }}-cargo-bin-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
119-
restore-key: |
120-
${{ runner.os }}-cargo-bin-${{ matrix.rust }}-
121-
${{ runner.os }}-cargo-bin-
98+
key: ${{ runner.os }}-cargo-bin-${{ matrix.rust }}-${{ hashFiles('.diesel_version') }}
12299

123100
# Current size as of 2019-12-23: ~77 MB
124101
- name: Cache cargo registry cache
@@ -150,16 +127,6 @@ jobs:
150127
${{ runner.os }}-cargo-git-db-${{ matrix.rust }}-
151128
${{ runner.os }}-cargo-git-db-
152129
153-
# Current size as of 2019-12-23: ~336 MB
154-
- name: Cache cargo build
155-
uses: actions/cache@v1
156-
with:
157-
path: target
158-
key: ${{ runner.os }}-cargo-build-target-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
159-
restore-key: |
160-
${{ runner.os }}-cargo-build-target-${{ matrix.rust }}-
161-
${{ runner.os }}-cargo-build-target-
162-
163130
- name: Install ${{ matrix.rust }} Rust
164131
run: |
165132
if [[ ! -d "$HOME/.cargo" || ! -d "$HOME/.rustup" ]]; then
@@ -176,6 +143,19 @@ jobs:
176143
rustup component add rustfmt
177144
rustup component add clippy
178145
146+
- id: rustc
147+
run:
148+
echo "::set-output name=version::$(rustc -V)"
149+
150+
# Current size as of 2019-12-23: ~336 MB
151+
- name: Cache cargo build
152+
uses: actions/cache@v1
153+
with:
154+
path: target
155+
key: ${{ runner.os }}-cargo-build-target-${{ steps.rustc.outputs.version }}-${{ hashFiles('**/Cargo.lock') }}
156+
restore-key: |
157+
${{ runner.os }}-cargo-build-target-${{ steps.rustc.outputs.version }}-
158+
179159
- name: Cargo clean on new rustc version
180160
run: script/ci/cargo-clean-on-new-rustc-version.sh
181161

0 commit comments

Comments
 (0)