Skip to content

Commit af54eb0

Browse files
Rework github actions, add code coverage (#186)
This reworks our GitHub Actions workflow to include code coverage via tarpaulin. Fixes #164.
1 parent 6e6fae7 commit af54eb0

File tree

1 file changed

+57
-22
lines changed

1 file changed

+57
-22
lines changed

.github/workflows/rust.yml

Lines changed: 57 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,65 @@
11
name: Rust
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
6-
build:
6+
7+
codestyle:
78
runs-on: ubuntu-latest
9+
steps:
10+
- name: Set up Rust
11+
uses: hecrj/setup-rust-action@v1
12+
with:
13+
components: rustfmt
14+
# Note that `nightly` is required for `license_template_path`, as
15+
# it's an unstable feature.
16+
rust-version: nightly
17+
- uses: actions/checkout@v2
18+
- run: cargo fmt -- --check --config-path <(echo 'license_template_path = "HEADER"')
19+
20+
lint:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Set up Rust
24+
uses: hecrj/setup-rust-action@v1
25+
with:
26+
components: clippy
27+
- uses: actions/checkout@v2
28+
- run: cargo clippy --all-targets --all-features -- -D warnings
829

30+
compile:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Set up Rust
34+
uses: hecrj/setup-rust-action@v1
35+
- uses: actions/checkout@master
36+
- run: cargo check --all-targets --all-features
37+
38+
test:
39+
strategy:
40+
matrix:
41+
rust: [stable, beta, nightly]
42+
runs-on: ubuntu-latest
943
steps:
10-
- uses: actions/checkout@v1
1144
- name: Setup Rust
12-
run: |
13-
rustup toolchain install nightly --profile default
14-
rustup toolchain install stable
15-
rustup override set stable
16-
# Clippy must be run first, as its lints are only triggered during
17-
# compilation. Put another way: after a successful `cargo build`, `cargo
18-
# clippy` is guaranteed to produce no results. This bug is known upstream:
19-
# https://github.com/rust-lang/rust-clippy/issues/2604.
20-
# - name: Clippy
21-
# run: cargo clippy -- --all-targets --all-features -- -D warnings
22-
- name: Check formatting
23-
run: |
24-
cargo +nightly fmt -- --check --config-path <(echo 'license_template_path = "HEADER"')
25-
- name: Build
26-
run: cargo build --verbose
27-
- name: Run tests
28-
run: cargo test --verbose
29-
- name: Run tests for all features
30-
run: cargo test --verbose -- all-features
45+
uses: hecrj/setup-rust-action@v1
46+
with:
47+
rust-version: ${{ matrix.rust }}
48+
- name: Install Tarpaulin
49+
uses: actions-rs/[email protected]
50+
with:
51+
crate: cargo-tarpaulin
52+
version: 0.13.3
53+
use-tool-cache: true
54+
- name: Checkout
55+
uses: actions/checkout@v2
56+
- name: Test
57+
run: cargo test --all-features
58+
- name: Coverage
59+
if: matrix.rust == 'stable'
60+
run: cargo tarpaulin -o Lcov --output-dir ./coverage
61+
- name: Coveralls
62+
if: matrix.rust == 'stable'
63+
uses: coverallsapp/github-action@master
64+
with:
65+
github-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)