Skip to content

rework github actions for code coverage #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 7, 2020
79 changes: 57 additions & 22 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,65 @@
name: Rust

on: [push]
on: [push, pull_request]

jobs:
build:

codestyle:
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
with:
components: rustfmt
# Note that `nightly` is required for `license_template_path`, as
# it's an unstable feature.
rust-version: nightly
- uses: actions/checkout@v2
- run: cargo fmt -- --check --config-path <(echo 'license_template_path = "HEADER"')
Comment on lines +14 to +18
Copy link
Contributor

@nickolay nickolay Jul 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed this does not use cargo +nightly fmt, making it print a Warning: can't set license_template_path = "HEADER", unstable features are only available in nightly channel. and presumably not run that check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no, definitely an oversight on my part. Should be a trivial fix.


lint:
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
with:
components: clippy
- uses: actions/checkout@v2
- run: cargo clippy --all-targets --all-features -- -D warnings

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:
- uses: actions/checkout@v1
- name: Setup Rust
run: |
rustup toolchain install nightly --profile default
rustup toolchain install stable
rustup override set stable
# Clippy must be run first, as its lints are only triggered during
# compilation. Put another way: after a successful `cargo build`, `cargo
# clippy` is guaranteed to produce no results. This bug is known upstream:
# https://github.com/rust-lang/rust-clippy/issues/2604.
# - name: Clippy
# run: cargo clippy -- --all-targets --all-features -- -D warnings
- name: Check formatting
run: |
cargo +nightly fmt -- --check --config-path <(echo 'license_template_path = "HEADER"')
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Run tests for all features
run: cargo test --verbose -- all-features
uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
- name: Install Tarpaulin
uses: actions-rs/[email protected]
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 }}