Skip to content

Commit 739a8a9

Browse files
committed
rework github actions for code coverage
This reworks our GitHub Actions workflow to include code coverage via tarpaulin. Note that this is essentially directly lifted from the again[1] crate's methodology. Fixes apache#164. [1] https://github.com/softprops/again/blob/dd5f0013533e28f803b282ebc281e9525ca64d86/.github/workflows/main.yml
1 parent d32df52 commit 739a8a9

File tree

1 file changed

+50
-20
lines changed

1 file changed

+50
-20
lines changed

.github/workflows/rust.yml

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,58 @@ name: Rust
33
on: [push]
44

55
jobs:
6-
build:
6+
7+
codestyle:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Set up Rust
11+
uses: hecrj/setup-rust-action@v1
12+
with:
13+
components: rustfmt
14+
rust-version: nightly
15+
- uses: actions/checkout@v2
16+
- run: cargo fmt -- --check --config-path <(echo 'license_template_path = "HEADER"')
17+
18+
lint:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Set up Rust
22+
uses: hecrj/setup-rust-action@v1
23+
with:
24+
components: clippy
25+
- uses: actions/checkout@v2
26+
- run: cargo clippy --all-targets -- -D clippy::all
27+
28+
compile:
729
runs-on: ubuntu-latest
30+
steps:
31+
- name: Set up Rust
32+
uses: hecrj/setup-rust-action@v1
33+
- uses: actions/checkout@master
34+
- run: cargo check --all
835

36+
test:
37+
needs: [codestyle, lint, compile]
38+
strategy:
39+
matrix:
40+
rust: [stable, beta, nightly]
41+
runs-on: ubuntu-latest
942
steps:
10-
- uses: actions/checkout@v1
1143
- name: Setup Rust
44+
uses: hecrj/setup-rust-action@v1
45+
with:
46+
rust-version: ${{ matrix.rust }}
47+
- name: Checkout
48+
uses: actions/checkout@v2
49+
- name: Test
50+
run: cargo test
51+
- name: Coverage
52+
if: matrix.rust == 'stable'
1253
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
54+
# Tarpaulin interoperates with CI services, however Actions is not
55+
# currently supported. As a workaround, we can pretend to be Travis.
56+
export TRAVIS_JOB_ID=${GITHUB_SHA}
57+
export TRAVIS_PULL_REQUEST=false
58+
export TRAVIS_BRANCH=${GITHUB_REF##*/}
59+
cargo install cargo-tarpaulin
60+
cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID

0 commit comments

Comments
 (0)