influxdb/.circleci/config.yml

158 lines
4.7 KiB
YAML
Raw Normal View History

# CI Overview
# -----------
#
# Each night:
#
# A build image is created (ci_image) from `docker/Dockerfile.ci` and is
# pushed to `quay.io/influxdb/rust:ci`. This build image is then used to run
# the CI tasks for the day.
#
# CI runs for git branches ending in `/perf`:
#
# Runs tests, fmt, & lints and then compiles binaries using the "release"
# cargo target and pushes a container with the binary to
# `quay.io/influxdb/fusion` (see perf_image below).
#
# CI for all other branches is performed by the GitHub actions (see .github dir)
version: 2.1
commands:
2020-06-05 21:45:44 +00:00
rust_nightly:
description: Install nightly Rust toolchain
2020-06-05 21:45:44 +00:00
steps:
- run:
name: Install rust nightly-2020-11-19
command: rustup toolchain install nightly-2020-11-19
2020-06-05 21:45:44 +00:00
- run:
name: Install rustfmt and clippy for nightly-2020-11-19
command: rustup component add rustfmt clippy --toolchain nightly-2020-11-19
2020-06-05 21:45:44 +00:00
jobs:
fmt:
docker:
- image: quay.io/influxdb/rust:ci
steps:
- checkout
2020-06-05 21:45:44 +00:00
- rust_nightly
- run:
name: Rust fmt
2020-02-14 13:01:39 +00:00
command: cargo fmt --all -- --check
lint:
docker:
- image: quay.io/influxdb/rust:ci
steps:
- checkout
2020-06-05 21:45:44 +00:00
- rust_nightly
- run:
name: Clippy
command: cargo clippy --all-targets --workspace -- -D warnings
test:
docker:
- image: quay.io/influxdb/rust:ci
resource_class: xlarge # use of a smaller executor tends crashes on link
steps:
- checkout
2020-06-05 21:45:44 +00:00
- rust_nightly
- run:
name: Cargo test
command: cargo test --workspace
# Build a dev binary.
#
# Compiles a binary with the default ("dev") cargo profile from the iox source
# using the latest ci_image.
build:
docker:
- image: quay.io/influxdb/rust:ci
steps:
- checkout
2020-06-05 21:45:44 +00:00
- rust_nightly
- run:
name: Cargo build
command: cargo build --workspace
# Compile a cargo "release" profile binary for branches that end in `/perf`
#
# Uses the latest ci_image (influxdb/rust below) to build a release binary and
# copies it to a minimal container image based upon `rust:slim-buster`. This
# minimal image is then pushed to `quay.io/influxdb/fusion:${BRANCH}` with '/'
# repaced by '.' - as an example:
#
# git branch: dom/my-awesome-feature/perf
# container: quay.io/influxdb/fusion:dom.my-awesome-feature.perf
#
# Subsequent CI runs will overwrite the tag if you push more changes, so watch
# out for parallel CI runs!
#
# To change the contents of the build container, modify docker/Dockerfile.ci
# To change the final release container, modify docker/Dockerfile.perf
perf_image:
docker:
- image: quay.io/influxdb/rust:ci
steps:
- checkout
- rust_nightly
- run:
name: Cargo release build with target arch set for CRoaring
command: ROARING_ARCH=x86-64 cargo build --release
- setup_remote_docker:
docker_layer_caching: true
- run: |
sudo apt-get update
sudo apt-get install -y docker.io
- run: |
echo "$QUAY_PASS" | docker login quay.io --username $QUAY_USER --password-stdin
- run: |
BRANCH=$(git rev-parse --abbrev-ref HEAD | tr '/' '.')
docker build -t quay.io/influxdb/fusion:$BRANCH -f docker/Dockerfile.perf .
docker push quay.io/influxdb/fusion:$BRANCH
# Prepare the CI image used for other tasks.
#
# A nightly job (scheduled below in the `workflows` section) to build the CI
# image (influxdb/rust) used for the rest of the checks.
#
# To modify the contents of the CI image, update docker/Dockerfile.ci
ci_image:
machine: true
resource_class: xlarge
steps:
- checkout
- run: |
echo "$QUAY_PASS" | docker login quay.io --username $QUAY_USER --password-stdin
- run: |
COMMIT_SHA=$(git rev-parse --short HEAD)
docker build -t quay.io/influxdb/rust:$COMMIT_SHA -f docker/Dockerfile.ci .
docker tag quay.io/influxdb/rust:$COMMIT_SHA quay.io/influxdb/rust:ci
docker push quay.io/influxdb/rust:$COMMIT_SHA
docker push quay.io/influxdb/rust:ci
workflows:
version: 2
build:
jobs:
- fmt
- lint
- test
- build
- perf_image:
requires: # Only do a release build if all tests have passed
- fmt
- lint
- test
- build
filters:
branches:
only: /.*\/perf$/ # Only do a release build if the branch name ends in `/perf`
ci_image:
triggers:
- schedule:
cron: "0 5 * * *"
filters:
branches:
only:
- main
jobs:
- ci_image