---
version: 2.1
executors:
docker:
docker:
- image: &image saschagrunert/build-rust
machine:
machine:
docker_layer_caching: true
image: ubuntu-1604:201903-01
workflows:
version: 2
pipeline:
jobs:
- build
- doc
- doc-publish:
requires:
- doc
filters:
branches:
only: master
- rustfmt
- clippy
- test
jobs:
build:
executor: docker
steps:
- checkout
- run:
name: Version information
command: |
rustc --version
rustup --version
cargo --version
- restore_cache:
keys:
- build-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
- run:
name: Build all targets
command: make
- save_cache:
key: build-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
paths:
- /root/.cargo/registry
- target
doc:
executor: docker
steps:
- checkout
- restore_cache:
keys:
- doc-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
- run:
name: Build documentation
command: make build-doc
- save_cache:
key: doc-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
paths:
- /root/.cargo/registry
- target
- persist_to_workspace:
root: .
paths:
- target/doc
doc-publish:
executor: docker
steps:
- add_ssh_keys:
fingerprints:
- a6:4d:19:3c:a5:49:6b:f6:7a:fc:8b:b0:09:a5:45:ac
- checkout
- run:
name: Setup git
command: |
git config --global user.email mail@saschagrunert.de
git config --global user.name "CircleCI"
- attach_workspace:
at: .
- run:
name: Deploy documentation
command: |
git fetch origin gh-pages
git checkout -f gh-pages
rm -rf doc
mv target/doc .
git add .
git diff-index --quiet HEAD || git commit -m 'Update documentation'
git push -f origin gh-pages
rustfmt:
executor: docker
steps:
- checkout
- run:
name: Rust-Format
command: make lint-rustfmt
clippy:
executor: docker
steps:
- checkout
- restore_cache:
keys:
- clippy-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
- run:
name: Clippy
command: make lint-clippy
- save_cache:
key: clippy-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
paths:
- /root/.cargo/registry
- target
test:
executor: machine
steps:
- checkout
- run:
name: Run tests
environment:
IMAGE: *image
command: |
docker pull $IMAGE
docker run --security-opt seccomp=unconfined \
-v $(pwd):/build -w /build -e CODECOV_TOKEN $IMAGE \
bash -c "\
cargo generate-lockfile && \
make coverage && \
bash <(curl -s https://codecov.io/bash)"