Skip to content

Commit 819a1e7

Browse files
committed
feat: enable code coverage
1 parent b74544e commit 819a1e7

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

.github/workflows/build.yml

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
name: Build & Test
22

3-
env:
4-
CARGO_TERM_COLOR: always
5-
RUSTFLAGS: "-D warnings"
6-
RUST_LOG: "info"
7-
RUST_LOG_SPAN_EVENTS: full
8-
93
on:
104
workflow_call:
115
inputs:
@@ -45,13 +39,47 @@ jobs:
4539
- name: Install Rust
4640
uses: dtolnay/rust-toolchain@master
4741
with:
42+
components: 'llvm-tools-preview'
4843
toolchain: stable
4944

45+
- name: Install grcov
46+
uses: taiki-e/install-action@main
47+
with:
48+
tool: grcov
49+
5050
- name: Enable caching
5151
uses: Swatinem/rust-cache@v2
5252

5353
- name: Tests
5454
env:
55+
CARGO_TERM_COLOR: always
5556
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
57+
LLVM_PROFILE_FILE: postgresql-%p-%m.profraw
58+
RUST_LOG: "info"
59+
RUST_LOG_SPAN_EVENTS: full
60+
RUSTFLAGS: -Cinstrument-coverage
61+
RUSTDOCFLAGS: -Cinstrument-coverage
5662
run: |
5763
cargo test --workspace --all-features
64+
65+
- name: Produce coverage info
66+
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
67+
run: |
68+
grcov $(find . -name "postgresql-*.profraw" -print) \
69+
-s . \
70+
--branch \
71+
--ignore-not-existing \
72+
--ignore='target/*' \
73+
--ignore='benches/*' \
74+
--ignore='/*' \
75+
--binary-path ./target/debug/ \
76+
--excl-line='#\[derive' \
77+
-t lcov \
78+
-o lcov.info
79+
80+
- name: Upload to codecov.io
81+
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
82+
uses: codecov/codecov-action@v3
83+
with:
84+
files: lcov.info
85+
fail_ci_if_error: true

0 commit comments

Comments
 (0)