Skip to content
This repository has been archived by the owner on Mar 20, 2020. It is now read-only.

Commit

Permalink
Use sscache
Browse files Browse the repository at this point in the history
Separate package tests
Per branch cache
  • Loading branch information
jordy25519 committed Aug 29, 2019
1 parent 1bf9cb4 commit 7790c4e
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 38 deletions.
143 changes: 105 additions & 38 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,130 @@
version: 2
jobs:
build:
machine:
image: ubuntu-1604:201903-01
environment:
RUST_VERSION: nightly-2019-07-14
version: 2.1
commands:
install-rust:
steps:
- checkout
- restore_cache:
keys:
- v2-cargo-global-cache-{{ arch }}-{{ checksum "Cargo.lock" }}-{{ checksum ".circleci/RUST_VERSION" }}
- v2-cargo-global-cache-{{ arch }}-{{ checksum "Cargo.lock" }}-
- run:
name: Install rust
name: Install Rust
command: |
sudo apt-get update
sudo apt-get -y install apt-utils cmake pkg-config libssl-dev git llvm clang
if [ ! -d /home/circleci/.cargo ]; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
fi
source $HOME/.cargo/env
source ~/.cargo/env
rustup toolchain install $RUST_VERSION
rustup default $RUST_VERSION
rustup target add wasm32-unknown-unknown --toolchain=$RUST_VERSION
export RUSTC_WRAPPER=""
command -v wasm-gc || cargo install --git https://github.com/alexcrichton/wasm-gc --force
rustup target add x86_64-unknown-linux-musl --toolchain=$RUST_VERSION
rustc --version; cargo --version; rustup --version
install-sccache:
steps:
- run:
name: Install sccache
command: |
curl -L https://github.com/mozilla/sccache/releases/download/0.2.10/sccache-0.2.10-x86_64-unknown-linux-musl.tar.gz | tar -xz
chmod +x sccache-0.2.10-x86_64-unknown-linux-musl/sccache
mv sccache-0.2.10-x86_64-unknown-linux-musl/sccache ~/.cargo/bin/sccache
sccache --version
restore-cache:
steps:
- restore_cache:
keys:
- v1-cargo-wasm-cache-{{ arch }}-{{ checksum "Cargo.lock" }}-{{ checksum ".circleci/RUST_VERSION" }}
- v1-cargo-wasm-cache-{{ arch }}-{{ checksum "Cargo.lock" }}-
name: Restore sccache
key: sccache-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
save-cache:
steps:
- save_cache:
name: Save sccache
# 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-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ epoch }}
paths:
- "~/.cache/sccache"
save-target-cache:
steps:
- save_cache:
name: Save target cache
paths:
- runtime/wasm/target/
key: v1-cargo-wasm-cache-{{ arch }}-{{ checksum "Cargo.lock" }}-{{ checksum ".circleci/RUST_VERSION" }}
- /home/circleci/.cargo
key: target-cache-{{ arch }}-{{ checksum ".circleci/RUST_VERSION" }}-{{ $CIRCLE_BRANCH }}-{{ epoch }}
restore-target-cache:
steps:
- restore_cache:
keys:
- v1-target-cache-{{ arch }}-{{ checksum "Cargo.lock" }}-{{ checksum ".circleci/RUST_VERSION" }}
- v1-target-cache-{{ arch }}-{{ checksum "Cargo.lock" }}-
name: Restore target cache
key: target-cache-{{ arch }}-{{ checksum ".circleci/RUST_VERSION" }}-{{ $CIRCLE_BRANCH }}-{{ epoch }}
jobs:
build:
machine:
image: ubuntu-1604:201903-01
environment:
BASH_ENV: ~/.cargo/env
RUST_VERSION: nightly-2019-07-14
RUSTC_WRAPPER: sccache
SCCACHE_CACHE_SIZE: 10G
steps:
- checkout
- install-rust
- install-sccache
- restore-cache
- restore-target-cache
- run:
name: Build binary
command: |
source $HOME/.cargo/env
cargo build
no_output_timeout: 40m
- save_cache:
paths:
- target/debug/.fingerprint
- target/debug/build
- target/debug/deps
- target/debug/incremental
key: v1-target-cache-{{ arch }}-{{ checksum "Cargo.lock" }}-{{ checksum ".circleci/RUST_VERSION" }}
- save_cache:
paths:
- /home/circleci/.cargo
key: v1-cargo-global-cache-{{ arch }}-{{ checksum "Cargo.lock" }}-{{ checksum ".circleci/RUST_VERSION" }}
- save-cache
- save-target-cache
- run:
name: Run srml tests
command: |
for p in $(find srml -name Cargo.toml | sort -u | sed 's/Cargo.toml//g'); do
pushd $p > /dev/null
cargo test
popd > /dev/null
done
- save-cache
- save-target-cache
- run:
name: Run node tests
command: |
for p in $(find node -name Cargo.toml | sort -u | sed 's/Cargo.toml//g'); do
pushd $p > /dev/null
cargo test
popd > /dev/null
done
- save-cache
- save-target-cache
- run:
name: Run core tests
command: |
for p in $(find core -name Cargo.toml | sort -u | sed 's/Cargo.toml//g'); do
pushd $p > /dev/null
cargo test
popd > /dev/null
done
- save-cache
- save-target-cache
- run:
name: Run node-template tests
command: |
for p in $(find node-template -name Cargo.toml | sort -u | sed 's/Cargo.toml//g'); do
pushd $p > /dev/null
cargo test
popd > /dev/null
done
- save-cache
- save-target-cache
- run:
name: Run tests
name: Run subkey tests
command: |
source $HOME/.cargo/env
cargo test --all --verbose --locked
no_output_timeout: 120m
for p in $(find subkey -name Cargo.toml | sort -u | sed 's/Cargo.toml//g'); do
pushd $p > /dev/null
cargo test
popd > /dev/null
done
- save-cache
- save-target-cache

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,7 @@ maintenance = { status = "actively-developed" }
[profile.release]
# Substrate runtime requires unwinding.
panic = "unwind"

[profile.test]
lto = false

0 comments on commit 7790c4e

Please sign in to comment.