Skip to content

Commit

Permalink
Enabled coverage report for Clang builds
Browse files Browse the repository at this point in the history
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 <git@colby.id.au>
Date:   Wed Oct 9 18:28:47 2024 +1100

    Remove the diagnostic `--help` command

commit 3286c55
Author: Paul Colby <git@colby.id.au>
Date:   Tue Oct 8 23:43:16 2024 +1100

    Correct workflow syntax

commit 45587d7
Author: Paul Colby <git@colby.id.au>
Date:   Tue Oct 8 23:39:17 2024 +1100

    Correct workflow syntax

commit 89e5c3e
Author: Paul Colby <git@colby.id.au>
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 <git@colby.id.au>
Date:   Tue Oct 8 23:34:03 2024 +1100

    Choose an arch when using universal builds

commit aac9e55
Author: Paul Colby <git@colby.id.au>
Date:   Tue Oct 8 22:28:01 2024 +1100

    Try the prefix path given by brew

commit 2c54dec
Author: Paul Colby <git@colby.id.au>
Date:   Tue Oct 8 22:23:17 2024 +1100

    Handle '@' char

commit d241b35
Author: Paul Colby <git@colby.id.au>
Date:   Tue Oct 8 22:08:51 2024 +1100

    Try the common path

commit 048b176
Author: Paul Colby <git@colby.id.au>
Date:   Tue Oct 8 22:05:22 2024 +1100

    Correct YAML syntax

commit 606d20e
Author: Paul Colby <git@colby.id.au>
Date:   Tue Oct 8 21:57:10 2024 +1100

    Look closer for llvm

commit 2fbe208
Author: Paul Colby <git@colby.id.au>
Date:   Tue Oct 8 21:41:16 2024 +1100

    Try looking up the path to LLVM

commit db986d4
Author: Paul Colby <git@colby.id.au>
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 <git@colby.id.au>
Date:   Tue Oct 8 21:13:25 2024 +1100

    Get some versoin info

commit 4121f0c
Author: Paul Colby <git@colby.id.au>
Date:   Tue Oct 8 20:52:41 2024 +1100

    Tell CMake where to find llvm-profdata and llvm-cov

commit 1a80658
Author: Paul Colby <git@colby.id.au>
Date:   Tue Oct 8 20:22:28 2024 +1100

    Find where (if anyway) llvm-profdata and llvm-cov are

commit 86cc54f
Author: Paul Colby <git@colby.id.au>
Date:   Tue Oct 8 19:12:54 2024 +1100

    Try llvm-cov on CI
  • Loading branch information
pcolby committed Oct 9, 2024
1 parent 086a070 commit cc8b409
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ jobs:
- 6.8.0
env:
- { cc: clang, cxx: clang++, coverage: false }
- { cc: clang, cxx: clang++, coverage: true }
- { cc: gcc, cxx: g++, coverage: false }
- { cc: gcc, cxx: g++, coverage: true }
steps:
- name: Upgrade OS
run: |
sudo apt-mark hold grub-efi-amd64-signed
sudo apt update && sudo apt upgrade
sudo apt install lcov libfuse2
sudo apt install lcov libfuse2 llvm
- uses: actions/setup-python@v5
with:
python-version: '>=3.9'
Expand Down Expand Up @@ -167,6 +168,7 @@ jobs:
os: [ 'macos-13', 'macos-14', 'macos-15' ]
env:
- { cc: clang, cxx: clang++, coverage: false }
- { cc: clang, cxx: clang++, coverage: true }
- { cc: gcc-14, cxx: g++-14, coverage: false }
- { cc: gcc-14, cxx: g++-14, coverage: true }
exclude:
Expand Down Expand Up @@ -213,6 +215,8 @@ jobs:
- { qt: '6.6.3', env: { cc: gcc-14 } }
- { qt: '6.7.3', env: { cc: gcc-14 } }
- { qt: '6.8.0', env: { cc: gcc-14 } }
# Exclude code coverage builds with Clang on macOS 13, since the runner's llvm-cov does not support --source.
- { os: macos-13, env: { cc: clang, coverage: true } }
steps:
- uses: actions/checkout@v4
- name: Install lcov
Expand Down Expand Up @@ -259,6 +263,8 @@ jobs:
cmake -D CMAKE_BUILD_TYPE=Release \
-D CODECOV_GCOV=${{ startsWith(matrix.env.cc, 'gcc') && '/usr/local/bin/gcov-14' || '/usr/bin/gcov'}} \
-D ENABLE_COVERAGE=${{ matrix.env.coverage }} \
-D LLVM_COV=/Library/Developer/CommandLineTools/usr/bin/llvm-cov \
-D LLVM_PROFDATA=/Library/Developer/CommandLineTools/usr/bin/llvm-profdata \
-D QT_INSTALL_DOCS="$RUNNER_WORKSPACE/Qt/Docs/Qt-${{ matrix.qt }}" \
-S "$GITHUB_WORKSPACE" -B "$RUNNER_TEMP"
echo "dokitVersion=$(cat "$RUNNER_TEMP/version.txt")" | tee -a "$GITHUB_OUTPUT"
Expand Down
7 changes: 6 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ if (ENABLE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
"${PROJECT_SOURCE_DIR}/include/*.h"
"${PROJECT_SOURCE_DIR}/src/*.cpp"
"${PROJECT_SOURCE_DIR}/src/*.h")
if (APPLE AND CMAKE_OSX_ARCHITECTURES MATCHES ".*;.*")
list(GET CMAKE_OSX_ARCHITECTURES 0 LLVM_COV_ARCH)
endif()
add_custom_target(
coverage
COMMAND ${LLVM_PROFDATA} merge --output coverage.profdata "${LLVM_PROFILE_FILES}"
COMMAND ${LLVM_PROFDATA} show coverage.profdata
COMMAND ${LLVM_COV} export --format lcov --instr-profile coverage.profdata
COMMAND ${LLVM_COV} export
"$<$<BOOL:${LLVM_COV_ARCH}>:--arch;${LLVM_COV_ARCH}>"
--format lcov --instr-profile coverage.profdata
"--object;$<JOIN:$<TARGET_OBJECTS:QtPokit>,;--object;>"
"$<$<TARGET_EXISTS:cli-lib>:--object;$<JOIN:$<TARGET_OBJECTS:cli-lib>,;--object;>>"
--sources "${LLVM_COV_SOURCES}" > coverage.info
Expand Down

0 comments on commit cc8b409

Please sign in to comment.