Skip to content

Commit 9042ebf

Browse files
committed
Auto merge of #1902 - jtgeibel:ci-cache-improvements, r=jtgeibel
Improve build caching on CI These changes started based on a discussion over on [internals](https://internals.rust-lang.org/t/evaluating-github-actions/11292/8?u=jtgeibel). Basically, on every single build we end up touching some files and invaliding the caches. This forces Travis to compress and upload a new cache on every single build. This PR includes several changes on CI: * Incremental compilation is disabled. It appears that incremental files can change even if nothing in the codebase changes. * Drop the `target/.rustc_info.json` file before caching, as it can change on each build. * Running `cargo install` for the diesel CLI acts similar to a `cargo update` causing changes to the index and some caches maintained under `$HOME/.cargo`. `cargo install` is now only run if the diesel binary is not on the path. The downside to this is that if we bump the `.diesel_version` file then Travis will not be using the exact same version as Heroku until we clear the CI cache. Since we only use this binary to run migrations and we haven't bumped versions since January, I think this change is low risk compared to the improvement. * Add `RUSTFLAGS="-C debuginfo=0"` to disable debug info, which helps shrink the cache size. Based on my observations while putting together this PR, it looks like disabling incremental compilation has an impact on compile times, but this is small relative to the overall win on caching behavior. Additionally, our cache size has been reduced from 3948.04MB to 2439.19MB.
2 parents 2b43e48 + 45675ec commit 9042ebf

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@ env:
1313
- JOBS=1 # See https://git.io/vdao3 for details.
1414
- DATABASE_URL=postgres://postgres:@localhost/cargo_registry_test
1515
- TEST_DATABASE_URL=postgres://postgres:@localhost/cargo_registry_test
16-
- CARGO_TARGET_DIR=target
16+
- CARGO_INCREMENTAL=0
1717
- PERCY_PARALLEL_TOTAL=2
1818
# Percy secrets are included here to enable Percy's GitHub integration
1919
# on community-submitted PRs
2020
- PERCY_TOKEN=0d8707a02b19aebbec79bb0bf302b8d2fa95edb33169cfe41b084289596670b1
2121
- PERCY_PROJECT=crates-io/crates.io
2222
- PGPORT=5433
23+
- PATH=$HOME/.cargo/bin:$PATH
24+
- RUSTFLAGS="-C debuginfo=0"
2325

2426
install:
2527
- sudo cp /etc/postgresql/10/main/pg_hba.conf /etc/postgresql/11/main/pg_hba.conf
2628
- sudo systemctl restart postgresql@11-main
2729
- script/ci/cargo-clean-on-new-rustc-version.sh
28-
- cargo install --force diesel_cli --vers `cat .diesel_version` --no-default-features --features postgres && export PATH=$HOME/.cargo/bin:$PATH
30+
- which diesel || cargo install diesel_cli --vers `cat .diesel_version` --no-default-features --features postgres
2931

3032
before_script:
3133
- diesel database setup --locked-schema

script/ci/cargo-clean-on-new-rustc-version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e
44

55
manual_stamp_file=target/ci_manual_stamp
6-
manual_stamp=7 # Change this to force a clean build on CI
6+
manual_stamp=8 # Change this to force a clean build on CI
77

88
if [ -f $manual_stamp_file ]; then
99
if echo "$manual_stamp" | cmp -s $manual_stamp_file -; then

script/ci/prune-cache.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@ for name in $bin_names; do
2525
rm -v target/debug/deps/$normalized-*
2626
done
2727

28+
rm -v target/.rustc_info.json
29+
2830
echo "Final cache size:"
2931
du -hs target/debug

0 commit comments

Comments
 (0)