Skip to content

Commit

Permalink
ci: try sccache
Browse files Browse the repository at this point in the history
  • Loading branch information
chesedo committed Jul 22, 2022
1 parent 3fc4c52 commit fec996a
Showing 1 changed file with 43 additions and 13 deletions.
56 changes: 43 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,55 @@ orbs:
docker-buildx: sensu/[email protected]
aws-ecr: circleci/[email protected]

# sscache steps are from this guide
# https://medium.com/@edouard.oger/rust-caching-on-circleci-using-sccache-c996344f0115
commands:
restore-cache:
steps:
# Restore cargo cache before installing anything with the cargo command (ie cargo install ...)
- restore_cache:
name: Restore cargo cache
keys:
- cargo-{{ checksum "Cargo.lock" }}
- run:
name: Install sccache
command: |
cargo install sccache
# This configures Rust to use sccache.
echo 'export "RUSTC_WRAPPER"="sccache"' >> $BASH_ENV
sccache --version
- restore_cache:
name: Restore sccache cache
key: sccache-cache-{{ .Environment.CIRCLE_JOB }}
save-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-{{ .Environment.CIRCLE_JOB }}-{{ epoch }}
paths:
- "~/.cache/sccache"
- save_cache:
name: Save cargo cache
key: cargo-{{ checksum "Cargo.lock" }}-{{ epoch }}
paths:
- ~/.cargo

jobs:
fmt-workspace:
docker:
- image: cimg/rust:1.62.0
steps:
- checkout
- restore_cache:
keys:
- cargo-{{ checksum "Cargo.lock" }}
- restore-cache
- run: cargo fmt --all --check
- run: cargo install cargo-sort
- run: cargo sort --check --workspace
- run: cargo check --workspace --all-targets
- save_cache:
key: cargo-{{ checksum "Cargo.lock" }}
paths:
- ~/.cargo
- save-cache
clippy-workspace:
parameters:
framework:
Expand All @@ -30,9 +62,7 @@ jobs:
- image: cimg/rust:1.62.0
steps:
- checkout
- restore_cache:
keys:
- cargo-{{ checksum "Cargo.lock" }}
- restore-cache
- run: |
cargo clippy --tests \
--all-targets \
Expand All @@ -41,6 +71,7 @@ jobs:
--D warnings \
-A clippy::let-unit-value \
-A clippy::format-push-string
- save-cache
check-standalone:
parameters:
path:
Expand All @@ -50,9 +81,7 @@ jobs:
- image: cimg/rust:1.62.0
steps:
- checkout
- restore_cache:
keys:
- cargo-{{ checksum "Cargo.lock" }}
- restore-cache
- run:
name: Patch service
command: |
Expand All @@ -71,6 +100,7 @@ jobs:
--D warnings \
-A clippy::let-unit-value \
-A clippy::format-push-string
- save-cache

build-test-and-push:
resource_class: xlarge
Expand Down

0 comments on commit fec996a

Please sign in to comment.