Skip to content

Commit 27f949f

Browse files
committed
upload code coverage from compliance tests to codecov.io
1 parent 0a62f82 commit 27f949f

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

.github/workflows/ci.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs:
6060
runs-on: ubuntu-latest
6161
timeout-minutes: 15
6262
env:
63+
SUDO_TEST_PROFRAW_DIR: /tmp/profraw
6364
SUDO_TEST_VERBOSE_DOCKER_BUILD: 1
6465
CI: true
6566
steps:
@@ -94,6 +95,14 @@ jobs:
9495
SUDO_UNDER_TEST: ours
9596
run: cargo test -p sudo-compliance-tests
9697

98+
- name: Prepare code coverage data
99+
run: ./make-lcov-info.bash
100+
101+
- name: Upload code coverage
102+
uses: codecov/codecov-action@v3
103+
with:
104+
files: lcov.info
105+
97106
- name: Check that we didn't forget to gate a passing compliance test
98107
working-directory: test-framework
99108
env:

make-lcov-info.bash

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
rustup component add llvm-tools
6+
7+
llvm_profdata=$(find "$(rustc --print sysroot)" -name llvm-profdata)
8+
profdata="$SUDO_TEST_PROFRAW_DIR"/sudo-rs.profdata
9+
$llvm_profdata merge \
10+
-sparse \
11+
"$SUDO_TEST_PROFRAW_DIR"/**/*.profraw \
12+
-o "$profdata"
13+
14+
binary="$SUDO_TEST_PROFRAW_DIR"/sudo-rs
15+
dockerid=$(docker create sudo-test-rs)
16+
docker cp "$dockerid":/usr/bin/sudo "$binary"
17+
docker rm "$dockerid"
18+
19+
llvm_cov="$(dirname "$llvm_profdata")"/llvm-cov
20+
$llvm_cov export \
21+
-format=lcov \
22+
--ignore-filename-regex='/usr/local/cargo/registry' \
23+
--ignore-filename-regex='/rustc' \
24+
--instr-profile="$profdata" \
25+
--object "$binary" \
26+
-path-equivalence=/usr/src/sudo,"$(pwd)" >lcov.info

0 commit comments

Comments
 (0)