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.
pull/24376/head
Dom 2020-11-26 16:38:57 +00:00
parent da3b616368
commit 9c785a3b0f
2 changed files with 89 additions and 5 deletions

View File

@ -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

87
.github/workflows/rust.yml vendored Normal file
View File

@ -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