Skip to content

Commit faa5776

Browse files
committed
build(coverage): improve coverage generation
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
1 parent 7483d1a commit faa5776

2 files changed

Lines changed: 54 additions & 12 deletions

File tree

.github/workflows/linux.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
name: Linux
77

8+
permissions:
9+
pull-requests: write
10+
811
on:
912
workflow_call:
1013
inputs:
@@ -62,14 +65,22 @@ jobs:
6265

6366
- name: Build and run (source coverage)
6467
working-directory: build
65-
run: make
68+
run: make coverage report.md
6669

6770
- name: Upload coverage report
6871
uses: actions/upload-artifact@v4
6972
with:
7073
name: ocre-coverage
7174
include-hidden-files: true
72-
path: build/report
75+
path: build/coverage
76+
77+
- name: Report code coverage
78+
uses: marocchino/sticky-pull-request-comment@v3
79+
with:
80+
message: |
81+
```
82+
$(cat build/report.txt)
83+
```
7384
7485
- name: Delete build directory
7586
run: rm -rf build

tests/coverage/CMakeLists.txt

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,53 @@ project(OcreTestSourceCoverage)
1515

1616
add_subdirectory(../system/posix OcreSystemTests)
1717

18-
add_custom_target(coverage ALL
18+
add_custom_target(default.profdata
1919
COMMAND llvm-profdata merge -sparse
20-
OcreSystemTests/test_lib.profraw
21-
OcreSystemTests/test_ocre.profraw
22-
OcreSystemTests/test_context.profraw
23-
OcreSystemTests/test_container.profraw
24-
-o default.profdata
20+
OcreSystemTests/test_lib.profraw
21+
OcreSystemTests/test_ocre.profraw
22+
OcreSystemTests/test_context.profraw
23+
OcreSystemTests/test_container.profraw
24+
-o default.profdata
25+
DEPENDS
26+
OcreSystemTests/test_lib.profraw
27+
OcreSystemTests/test_ocre.profraw
28+
OcreSystemTests/test_context.profraw
29+
OcreSystemTests/test_container.profraw
30+
run-systests
31+
)
32+
33+
add_custom_target(coverage ALL
2534
COMMAND llvm-cov show
26-
-format=html -output-dir=report
35+
-format=html -output-dir=coverage
2736
-instr-profile=default.profdata
28-
--ignore-filename-regex=$wasm-micro-runtime/
29-
--ignore-filename-regex=$test/
37+
--sources ${CMAKE_CURRENT_LIST_DIR}/../../src
3038
--object=OcreSystemTests/test_lib
3139
--object=OcreSystemTests/test_ocre
3240
--object=OcreSystemTests/test_context
3341
--object=OcreSystemTests/test_container
3442
DEPENDS
35-
run-systests
43+
OcreSystemTests/test_lib
44+
OcreSystemTests/test_ocre
45+
OcreSystemTests/test_context
46+
OcreSystemTests/test_container
47+
default.profdata
48+
)
49+
50+
add_custom_target(report.md
51+
COMMAND echo '```' > report.md
52+
COMMAND llvm-cov report
53+
-instr-profile=default.profdata
54+
--sources ${CMAKE_CURRENT_LIST_DIR}/../../src
55+
--object=OcreSystemTests/test_lib
56+
--object=OcreSystemTests/test_ocre
57+
--object=OcreSystemTests/test_context
58+
--object=OcreSystemTests/test_container
59+
>> report.md
60+
COMMAND echo '```' >> report.md
61+
DEPENDS
62+
OcreSystemTests/test_lib
63+
OcreSystemTests/test_ocre
64+
OcreSystemTests/test_context
65+
OcreSystemTests/test_container
66+
default.profdata
3667
)

0 commit comments

Comments
 (0)