Skip to content

Commit 183e933

Browse files
committed
Add support for Coveralls to CI
This commit provides support for Coveralls CI by leveraging the existing Gcov build configuration, adding configuration so that gcovr generates coverage data in Coveralls JSON format, and adding steps to the CI build job that are activated only if the matrix entry is configured for coverage, which generate coverage data and deliver it to Coveralls. It also adds a coverage badge to the README.
1 parent 5cffcdb commit 183e933

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- {name: "Ubuntu Clang 19", os: ubuntu-24.04, toolchain: "clang-19", clang_version: 19, installed_clang_version: 17, cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" ", asan_options: "new_delete_type_mismatch=0"}
1919
- {name: "Ubuntu Clang 18", os: ubuntu-24.04, toolchain: "clang-18", clang_version: 18, installed_clang_version: 17, cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" "}
2020
- {name: "Ubuntu Clang 17", os: ubuntu-24.04, toolchain: "clang-17", clang_version: 17, installed_clang_version: 17, cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" "}
21-
- {name: "Ubuntu GCC 14", os: ubuntu-24.04, toolchain: "gcc-14", cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" "}
21+
- {name: "Ubuntu GCC 14", os: ubuntu-24.04, toolchain: "gcc-14", cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan;Gcov\" ", coverage: true}
2222
- {name: "Ubuntu GCC 13", os: ubuntu-24.04, toolchain: "gcc-13", cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" "}
2323
- {name: "Ubuntu GCC 12", os: ubuntu-24.04, toolchain: "gcc-12", cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" "}
2424
steps:
@@ -77,6 +77,11 @@ jobs:
7777
sudo apt-get install g++-${GCC_VERSION} gcc-${GCC_VERSION}
7878
find /usr/lib/x86_64-linux-gnu/ -name libstdc++.so*
7979
g++-${GCC_VERSION} --version
80+
- name: Install Gcovr
81+
if: matrix.config.coverage
82+
run: |
83+
set -x
84+
sudo apt-get install gcovr
8085
- name: CMake Configure
8186
run: |
8287
set -x
@@ -107,3 +112,25 @@ jobs:
107112
run: |
108113
set -x
109114
cmake --install .build --config RelWithDebInfo --component beman_optional26_development --verbose
115+
- name: CMake Gcov Build
116+
if: matrix.config.coverage
117+
run: |
118+
set -x
119+
cmake --build .build --config Gcov --target all_verify_interface_header_sets -- -k 0
120+
cmake --build .build --config Gcov --target all -- -k 0
121+
- name: CMake Gcov Test
122+
if: matrix.config.coverage
123+
run: |
124+
set -x
125+
ctest --build-config Gcov --output-on-failure --test-dir .build
126+
- name: Generate Coverage
127+
if: matrix.config.coverage
128+
run: |
129+
set -x
130+
cmake --build .build --config Gcov --target process_coverage -- -k 0
131+
- name: Coveralls
132+
if: matrix.config.coverage
133+
uses: coverallsapp/github-action@main
134+
with:
135+
file: ${{runner.workspace}}/optional26/.build/coverage.json
136+
github-token: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
SPDX-License-Identifier: 2.0 license with LLVM exceptions
55
-->
66

7-
![CI Tests](https://github.com/bemanproject/optional26/actions/workflows/ci.yml/badge.svg)
7+
![CI Tests](https://github.com/bemanproject/optional26/actions/workflows/ci.yml/badge.svg) [![Coverage](https://coveralls.io/repos/github/bemanproject/optional26/badge.svg?branch=main)](https://coveralls.io/github/bemanproject/optional26?branch=main)
88

99
This repository implements `std::optional` extensions targeting C++26. The `beman.optional26` library aims to evaluate
1010
the stability, the usability, and the performance of these proposed changes before they are officially adopted by WG21

cmake/gcovr.cfg.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ html-self-contained = yes
99
print-summary = yes
1010
filter = .*/beman/optional26/.*
1111
exclude = .*\.t\.cpp
12+
coveralls = coverage.json
13+
coveralls-pretty = yes

0 commit comments

Comments
 (0)