Rework github actions, add code coverage (#186)

This reworks our GitHub Actions workflow to include code coverage via
tarpaulin.

Fixes #164.
This commit is contained in:
Max Countryman 2020-06-07 10:15:31 -07:00 committed by GitHub
parent 6e6fae73a0
commit af54eb02b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,30 +1,65 @@
name: Rust name: Rust
on: [push] on: [push, pull_request]
jobs: jobs:
build:
runs-on: ubuntu-latest
codestyle:
runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v1
- name: Set up Rust - name: Set up Rust
run: | uses: hecrj/setup-rust-action@v1
rustup toolchain install nightly --profile default with:
rustup toolchain install stable components: rustfmt
rustup override set stable # Note that `nightly` is required for `license_template_path`, as
# Clippy must be run first, as its lints are only triggered during # it's an unstable feature.
# compilation. Put another way: after a successful `cargo build`, `cargo rust-version: nightly
# clippy` is guaranteed to produce no results. This bug is known upstream: - uses: actions/checkout@v2
# https://github.com/rust-lang/rust-clippy/issues/2604. - run: cargo fmt -- --check --config-path <(echo 'license_template_path = "HEADER"')
# - name: Clippy
# run: cargo clippy -- --all-targets --all-features -- -D warnings lint:
- name: Check formatting runs-on: ubuntu-latest
run: | steps:
cargo +nightly fmt -- --check --config-path <(echo 'license_template_path = "HEADER"') - name: Set up Rust
- name: Build uses: hecrj/setup-rust-action@v1
run: cargo build --verbose with:
- name: Run tests components: clippy
run: cargo test --verbose - uses: actions/checkout@v2
- name: Run tests for all features - run: cargo clippy --all-targets --all-features -- -D warnings
run: cargo test --verbose -- all-features
compile:
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
- uses: actions/checkout@master
- run: cargo check --all-targets --all-features
test:
strategy:
matrix:
rust: [stable, beta, nightly]
runs-on: ubuntu-latest
steps:
- name: Setup Rust
uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
- name: Install Tarpaulin
uses: actions-rs/install@v0.1
with:
crate: cargo-tarpaulin
version: 0.13.3
use-tool-cache: true
- name: Checkout
uses: actions/checkout@v2
- name: Test
run: cargo test --all-features
- name: Coverage
if: matrix.rust == 'stable'
run: cargo tarpaulin -o Lcov --output-dir ./coverage
- name: Coveralls
if: matrix.rust == 'stable'
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}