Skip to content

Instantly share code, notes, and snippets.

@eoger
Last active August 29, 2019 22:36
Show Gist options
  • Save eoger/5c6896ea97a1edd4fda7045ecaf2ace3 to your computer and use it in GitHub Desktop.
Save eoger/5c6896ea97a1edd4fda7045ecaf2ace3 to your computer and use it in GitHub Desktop.
sccache with rust
version: 2.1
commands:
setup-sccache:
steps:
- run:
name: Install sccache
command: |
cargo install sccache
# This configures Rust to use sccache.
echo 'export "RUSTC_WRAPPER"="sccache"' >> $BASH_ENV
# This is the maximum space sccache cache will use on disk.
echo 'export "SCCACHE_CACHE_SIZE"="1G"' >> $BASH_ENV
sccache --version
restore-sccache-cache:
steps:
- restore_cache:
name: Restore sccache cache
key: sccache-cache-stable-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
save-sccache-cache:
steps:
- save_cache:
name: Save sccache cache
# We use {{ epoch }} to always upload a fresh cache:
# Of course, restore_cache will not find this exact key,
# but it will fall back to the closest key (aka the most recent).
# See https://discuss.circleci.com/t/add-mechanism-to-update-existing-cache-key/9014/13
key: sccache-cache-stable-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ epoch }}
paths:
- "~/.cache/sccache"
jobs:
rust-tests:
docker:
- image: circleci/rust:latest
steps:
- checkout
- setup-sccache
- restore-sccache-cache
- run: cargo test
- save-sccache-cache
workflows:
version: 2
run-tests:
jobs:
- rust-tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment