Skip to content

Commit 5d17478

Browse files
committed
ci: Add coverage.yml workflow
1 parent 19d9578 commit 5d17478

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

.github/workflows/coverage.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Code Coverage
2+
3+
on:
4+
push:
5+
branches: [
6+
"master",
7+
"test_ci"
8+
]
9+
pull_request:
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
14+
jobs:
15+
coverage:
16+
name: Code Coverage
17+
runs-on: ubuntu-latest
18+
env:
19+
RUSTFLAGS: "-Cinstrument-coverage"
20+
RUSTDOCFLAGS: "-Cinstrument-coverage"
21+
LLVM_PROFILE_FILE: "./target/coverage/%p-%m.profraw"
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
persist-credentials: false
28+
- name: Install lcov tools
29+
run: sudo apt-get install lcov -y
30+
- name: Install Rust toolchain
31+
uses: dtolnay/rust-toolchain@v1
32+
with:
33+
toolchain: stable
34+
components: llvm-tools-preview
35+
- name: Rust Cache
36+
uses: Swatinem/[email protected]
37+
- name: Install grcov
38+
run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi
39+
- name: Test
40+
run: cargo test --all-features
41+
- name: Make coverage directory
42+
run: mkdir coverage
43+
- name: Run grcov
44+
run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore '/*' --ignore '**/tests/**' --ignore '**/examples/**' -o ./coverage/lcov.info
45+
- name: Generate HTML report
46+
run: genhtml -o coverage-report -s --highlight --ignore-errors source --legend ./coverage/lcov.info
47+
- name: Coveralls upload
48+
uses: coverallsapp/github-action@master
49+
with:
50+
github-token: ${{ secrets.GITHUB_TOKEN }}
51+
- name: Upload artifact
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: coverage-report
55+
path: ./coverage/lcov.info

.github/workflows/rust.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ name: CI
22

33
on:
44
push:
5-
branches: [ "master" ]
5+
branches: [
6+
"master",
7+
"test_ci",
8+
]
69
pull_request:
710

811
env:

0 commit comments

Comments
 (0)