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
70 changes: 50 additions & 20 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,58 @@ name: Rust
on: [push]

jobs:
build:

codestyle:
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
with:
components: rustfmt
rust-version: nightly
- uses: actions/checkout@v2
- run: cargo fmt -- --check --config-path <(echo 'license_template_path = "HEADER"')

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 -- -D clippy::all

compile:
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
- uses: actions/checkout@master
- run: cargo check --all

test:
needs: [codestyle, lint, compile]
strategy:
matrix:
rust: [stable, beta, nightly]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup Rust
uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
- name: Checkout
uses: actions/checkout@v2
- name: Test
run: cargo test
- name: Coverage
if: matrix.rust == 'stable'
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
# Tarpaulin interoperates with CI services, however Actions is not
# currently supported. As a workaround, we can pretend to be Travis.
export TRAVIS_JOB_ID=${GITHUB_SHA}
export TRAVIS_PULL_REQUEST=false
export TRAVIS_BRANCH=${GITHUB_REF##*/}
cargo install cargo-tarpaulin
cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID