Skip to content

Commit

Permalink
Merge pull request #1578 from jtgeibel/clear-cache-on-ci-when-rustc-v…
Browse files Browse the repository at this point in the history
…ersion-changes

Run `cargo clean` on CI when the version of rustc changes
  • Loading branch information
jtgeibel authored Dec 15, 2018
2 parents 614b33c + 216f726 commit 387ae4f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ cache:
cargo: true
directories:
- $HOME/.npm
timeout: 600
# Set timeout to 6 minutes (double the default of 3 minutes)
timeout: 360

env:
global:
Expand All @@ -26,6 +27,7 @@ env:
- PERCY_PROJECT=crates-io/crates.io

install:
- script/cargo-clean-on-new-rustc-version.sh
- cargo install --force diesel_cli --vers `cat .diesel_version` --no-default-features --features postgres && export PATH=$HOME/.cargo/bin:$PATH

before_script:
Expand Down Expand Up @@ -68,9 +70,6 @@ matrix:
script:
- cargo build
- cargo test
# This portion of the cache is quickly invalidated anyway
before_cache:
- cargo clean

notifications:
email:
Expand Down
22 changes: 22 additions & 0 deletions script/cargo-clean-on-new-rustc-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

set -e

stamp_file=target/rustc_version_stamp
current_version=$(rustc --version)

if [ -f $stamp_file ]; then
# Compare the current version against the previous version
if echo "$current_version" | cmp -s $stamp_file -; then
echo "Version of rustc hasn't changed, keeping the cache intact"
else
echo "The version of rustc has changed, running cargo clean"
cargo clean
fi
else
echo "There is no existing version stamp, keeping the cache intact"
fi

# Save the version stamp for next time
mkdir -p target/
echo $current_version > $stamp_file

0 comments on commit 387ae4f

Please sign in to comment.