version: 2.1 # Adding these commands but need confirmation of cache location commands: cache_restore: description: Restore Cargo Cache steps: - restore_cache: name: Restoring Cargo Cache keys: - cargo-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Cargo.lock" }} - cargo-cache-{{ arch }}-{{ .Branch }} - cargo-cache cache_save: description: Save Cargo Cache steps: - save_cache: name: Save Cargo Cache paths: - /usr/local/cargo/registry key: cargo-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Cargo.lock" }} rust_nightly: description: Install nightly tools steps: - run: name: Install rust nightly-2020-04-22 command: rustup toolchain install nightly-2020-04-22 - run: name: Install rustfmt and clippy for nightly-2020-04-22 command: rustup component add rustfmt clippy --toolchain nightly-2020-04-22 jobs: fmt: docker: - image: quay.io/influxdb/rust:ci steps: - checkout - rust_nightly - run: name: Rust fmt command: cargo fmt --all -- --check lint: docker: - image: quay.io/influxdb/rust:ci steps: - checkout - rust_nightly - run: name: Clippy command: cargo clippy --all-targets --workspace -- -D warnings test: docker: - image: quay.io/influxdb/rust:ci steps: - checkout - cache_restore - rust_nightly - run: name: Cargo test command: cargo test --workspace - cache_save build: docker: - image: quay.io/influxdb/rust:ci steps: - checkout - cache_restore - rust_nightly - run: name: Cargo build command: cargo build --workspace - cache_save ci_image: machine: true 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 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 ci_image: triggers: - schedule: cron: "0 5 * * *" filters: branches: only: - master jobs: - ci_image