From 9c785a3b0f38c30ffc21fba299dd27688a2e999e Mon Sep 17 00:00:00 2001 From: Dom Date: Thu, 26 Nov 2020 16:38:57 +0000 Subject: [PATCH] ci: add GitHub actions Adds a GitHub CI action: * Uses the rust-toolchain file to install the requested version. * Performs a build with default cargo target * Runs workspace tests * Checks cargo fmt is happy * Runs clippy for lints, denying warnings All commands taken from the existing CircleCI pipeline. Currently no caching / reuse of build container. --- .circleci/config.yml | 7 +-- .github/workflows/rust.yml | 87 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/rust.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 85c64dec0d..60f3259c2b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,16 +7,13 @@ # pushed to `quay.io/influxdb/rust:ci`. This build image is then used to run # the CI tasks for the day. # -# Each CI run: -# -# Runs tests, fmt, & lints and then compiles binaries using the default cargo -# target ("dev"). -# # 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 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000000..ea2a869ee6 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,87 @@ +# CI Overview +# ----------- +# +# All pushes and PRs (including from forks) run: +# +# - cargo build with the default cargo profile ("dev") +# - cargo test +# - cargo fmt +# - clippy (with warnings denied) +# +# All workflow actions make use of our build container +# (`quay.io/influxdb/rust:ci`) to satisfy system dependencies, and is updated +# nightly. +# +# Cargo's build artefacts are cached to reduce the build time, see +# https://github.com/actions/cache for more info. + +on: [push, pull_request] + +name: ci + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + container: + image: quay.io/influxdb/rust:ci + # Run as the "root" user in the build container to fix workspace & cache + # permission errors. + options: --user root + steps: + # Checkout the code + - uses: actions/checkout@v2 + + # Enable caching of build artefacts + - uses: actions/cache@v2 + with: + path: target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + # Build! + - name: Run dev build + uses: actions-rs/cargo@v1 + with: + command: build + args: --workspace + + test: + name: Test + runs-on: ubuntu-latest + container: + image: quay.io/influxdb/rust:ci + options: --user root + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Run tests + uses: actions-rs/cargo@v1 + with: + command: test + args: --workspace + + lints: + name: Lints + runs-on: ubuntu-latest + container: + image: quay.io/influxdb/rust:ci + options: --user root + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Run cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + - uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-targets --workspace -- -D warnings