Skip to content

Commit cc8b409

Browse files
committed
Enabled coverage report for Clang builds
On all but macOS 13, because that host has a version of llvm-cov that is too old to support the `--source` CLI option. We could probably conditionally skip that option, but its not worth the effort currently. Squashed commit of the following: commit 265d95a1e232856152adfb14b499a1f2a3b3a858 Author: Paul Colby <[email protected]> Date: Wed Oct 9 18:28:47 2024 +1100 Remove the diagnostic `--help` command commit 3286c55 Author: Paul Colby <[email protected]> Date: Tue Oct 8 23:43:16 2024 +1100 Correct workflow syntax commit 45587d7 Author: Paul Colby <[email protected]> Date: Tue Oct 8 23:39:17 2024 +1100 Correct workflow syntax commit 89e5c3e Author: Paul Colby <[email protected]> Date: Tue Oct 8 23:35:24 2024 +1100 Exclude coverage for Clang on macOS 13 Since that GitHub hosted runner has an old version of llvm-cov, that doesn't support the `--source` CLI option (in fact, it doesn't even support `--version`). Also restored the remaining (non-coverage, and Windows) builds. commit 38efb74 Author: Paul Colby <[email protected]> Date: Tue Oct 8 23:34:03 2024 +1100 Choose an arch when using universal builds commit aac9e55 Author: Paul Colby <[email protected]> Date: Tue Oct 8 22:28:01 2024 +1100 Try the prefix path given by brew commit 2c54dec Author: Paul Colby <[email protected]> Date: Tue Oct 8 22:23:17 2024 +1100 Handle '@' char commit d241b35 Author: Paul Colby <[email protected]> Date: Tue Oct 8 22:08:51 2024 +1100 Try the common path commit 048b176 Author: Paul Colby <[email protected]> Date: Tue Oct 8 22:05:22 2024 +1100 Correct YAML syntax commit 606d20e Author: Paul Colby <[email protected]> Date: Tue Oct 8 21:57:10 2024 +1100 Look closer for llvm commit 2fbe208 Author: Paul Colby <[email protected]> Date: Tue Oct 8 21:41:16 2024 +1100 Try looking up the path to LLVM commit db986d4 Author: Paul Colby <[email protected]> Date: Tue Oct 8 21:38:21 2024 +1100 Use a modern (brew) LLVM version The macOS ones is so old, it can't even handle `--version`! :( commit a963e9a Author: Paul Colby <[email protected]> Date: Tue Oct 8 21:13:25 2024 +1100 Get some versoin info commit 4121f0c Author: Paul Colby <[email protected]> Date: Tue Oct 8 20:52:41 2024 +1100 Tell CMake where to find llvm-profdata and llvm-cov commit 1a80658 Author: Paul Colby <[email protected]> Date: Tue Oct 8 20:22:28 2024 +1100 Find where (if anyway) llvm-profdata and llvm-cov are commit 86cc54f Author: Paul Colby <[email protected]> Date: Tue Oct 8 19:12:54 2024 +1100 Try llvm-cov on CI
1 parent 086a070 commit cc8b409

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.github/workflows/build.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ jobs:
3030
- 6.8.0
3131
env:
3232
- { cc: clang, cxx: clang++, coverage: false }
33+
- { cc: clang, cxx: clang++, coverage: true }
3334
- { cc: gcc, cxx: g++, coverage: false }
3435
- { cc: gcc, cxx: g++, coverage: true }
3536
steps:
3637
- name: Upgrade OS
3738
run: |
3839
sudo apt-mark hold grub-efi-amd64-signed
3940
sudo apt update && sudo apt upgrade
40-
sudo apt install lcov libfuse2
41+
sudo apt install lcov libfuse2 llvm
4142
- uses: actions/setup-python@v5
4243
with:
4344
python-version: '>=3.9'
@@ -167,6 +168,7 @@ jobs:
167168
os: [ 'macos-13', 'macos-14', 'macos-15' ]
168169
env:
169170
- { cc: clang, cxx: clang++, coverage: false }
171+
- { cc: clang, cxx: clang++, coverage: true }
170172
- { cc: gcc-14, cxx: g++-14, coverage: false }
171173
- { cc: gcc-14, cxx: g++-14, coverage: true }
172174
exclude:
@@ -213,6 +215,8 @@ jobs:
213215
- { qt: '6.6.3', env: { cc: gcc-14 } }
214216
- { qt: '6.7.3', env: { cc: gcc-14 } }
215217
- { qt: '6.8.0', env: { cc: gcc-14 } }
218+
# Exclude code coverage builds with Clang on macOS 13, since the runner's llvm-cov does not support --source.
219+
- { os: macos-13, env: { cc: clang, coverage: true } }
216220
steps:
217221
- uses: actions/checkout@v4
218222
- name: Install lcov
@@ -259,6 +263,8 @@ jobs:
259263
cmake -D CMAKE_BUILD_TYPE=Release \
260264
-D CODECOV_GCOV=${{ startsWith(matrix.env.cc, 'gcc') && '/usr/local/bin/gcov-14' || '/usr/bin/gcov'}} \
261265
-D ENABLE_COVERAGE=${{ matrix.env.coverage }} \
266+
-D LLVM_COV=/Library/Developer/CommandLineTools/usr/bin/llvm-cov \
267+
-D LLVM_PROFDATA=/Library/Developer/CommandLineTools/usr/bin/llvm-profdata \
262268
-D QT_INSTALL_DOCS="$RUNNER_WORKSPACE/Qt/Docs/Qt-${{ matrix.qt }}" \
263269
-S "$GITHUB_WORKSPACE" -B "$RUNNER_TEMP"
264270
echo "dokitVersion=$(cat "$RUNNER_TEMP/version.txt")" | tee -a "$GITHUB_OUTPUT"

test/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@ if (ENABLE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
2121
"${PROJECT_SOURCE_DIR}/include/*.h"
2222
"${PROJECT_SOURCE_DIR}/src/*.cpp"
2323
"${PROJECT_SOURCE_DIR}/src/*.h")
24+
if (APPLE AND CMAKE_OSX_ARCHITECTURES MATCHES ".*;.*")
25+
list(GET CMAKE_OSX_ARCHITECTURES 0 LLVM_COV_ARCH)
26+
endif()
2427
add_custom_target(
2528
coverage
2629
COMMAND ${LLVM_PROFDATA} merge --output coverage.profdata "${LLVM_PROFILE_FILES}"
2730
COMMAND ${LLVM_PROFDATA} show coverage.profdata
28-
COMMAND ${LLVM_COV} export --format lcov --instr-profile coverage.profdata
31+
COMMAND ${LLVM_COV} export
32+
"$<$<BOOL:${LLVM_COV_ARCH}>:--arch;${LLVM_COV_ARCH}>"
33+
--format lcov --instr-profile coverage.profdata
2934
"--object;$<JOIN:$<TARGET_OBJECTS:QtPokit>,;--object;>"
3035
"$<$<TARGET_EXISTS:cli-lib>:--object;$<JOIN:$<TARGET_OBJECTS:cli-lib>,;--object;>>"
3136
--sources "${LLVM_COV_SOURCES}" > coverage.info

0 commit comments

Comments
 (0)