Skip to content

Commit e585499

Browse files
committed
Merge branch '18-build-add-code-coverage-report' into staging
2 parents b4f0eb3 + 0b4054e commit e585499

4 files changed

Lines changed: 63 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,62 @@ jobs:
308308
with:
309309
github_token: ${{ secrets.GITHUB_TOKEN }}
310310
publish_dir: ./${{ steps.badge_dir.outputs.dir }}
311-
destination_dir: ${{ steps.badge_dir.outputs.dir }}
311+
destination_dir: ${{ steps.badge_dir.outputs.dir }}
312+
313+
coverage:
314+
name: coverage / ubuntu-24.04 / gcc-14
315+
runs-on: ubuntu-24.04
316+
needs: build
317+
318+
env:
319+
CC: gcc-14
320+
CXX: g++-14
321+
GCOV: gcov-14
322+
323+
steps:
324+
- name: Checkout
325+
uses: actions/checkout@v5
326+
with:
327+
fetch-depth: 0
328+
329+
- name: Install dependencies
330+
shell: bash
331+
run: |
332+
sudo apt-get update
333+
sudo apt-get install -y \
334+
cmake \
335+
ninja-build \
336+
gcc-14 \
337+
g++-14 \
338+
lcov
339+
340+
- name: Configure
341+
shell: bash
342+
run: |
343+
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc-14 \
344+
-DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_C_FLAGS="--coverage -O0 -g" -DCMAKE_CXX_FLAGS="--coverage -O0 -g"
345+
346+
- name: Build
347+
shell: bash
348+
run: |
349+
cmake --build build --parallel
350+
351+
- name: Test
352+
shell: bash
353+
run: |
354+
ctest --test-dir build --output-on-failure
355+
356+
- name: Capture coverage
357+
shell: bash
358+
run: |
359+
lcov --gcov-tool /usr/bin/gcov-14 --directory build --capture --output-file coverage.info
360+
lcov --gcov-tool /usr/bin/gcov-14 --remove coverage.info '/usr/*' '*/test/*' '*/_deps/*' --output-file coverage.info
361+
lcov --gcov-tool /usr/bin/gcov-14 --list coverage.info
362+
363+
- name: Upload coverage reports to Codecov
364+
uses: codecov/codecov-action@v5
365+
with:
366+
files: coverage.info
367+
fail_ci_if_error: true
368+
env:
369+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
[![CI](https://github.com/vargalabs/libdecimal/actions/workflows/ci.yml/badge.svg)](https://github.com/vargalabs/libdecimal/actions/workflows/ci.yml)
3-
[![codecov](https://codecov.io/gh/vargalabs/libdecimal/branch/main/graph/badge.svg)](https://codecov.io/gh/vargalabs/libdecimal)
3+
[![codecov](https://codecov.io/gh/vargalabs/libdecimal/graph/badge.svg?token=F6YCNG3HEY)](https://codecov.io/gh/vargalabs/libdecimal)
44
[![MIT License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
55
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.19323619.svg)](https://doi.org/10.5281/zenodo.19323619)
66
[![GitHub release](https://img.shields.io/github/v/release/vargalabs/libdecimal.svg)](https://github.com/vargalabs/libdecimal/releases)

test/float-conversion.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ namespace test {
2424

2525
template <class float_t>
2626
bool nearly_equal(float_t a, float_t b, float_t eps = static_cast<float_t>(1e-12)) {
27-
if constexpr (std::is_same_v<float_t, long double>)
28-
return std::fabsl(a - b) <= eps;
29-
else
30-
return std::fabs(a - b) <= eps;
27+
return std::fabs(a - b) <= eps;
3128
}
3229
}
3330

test/ops-transcendental.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ TEST_SUITE("transcendental functions::decimal64") {
8888

8989
TEST_CASE("exp at easy points") {
9090
CHECK(test::as_long_double(math::exp(test::dec64_t{"0"})) == doctest::Approx(1.0L));
91-
CHECK(test::as_long_double(math::exp(test::dec64_t{"1"})) == doctest::Approx(std::expl(1.0L)));
91+
CHECK(test::as_long_double(math::exp(test::dec64_t{"1"})) == doctest::Approx(std::exp(1.0L)));
9292
}
9393

9494
TEST_CASE("log at easy points") {
@@ -140,7 +140,7 @@ TEST_SUITE("transcendental functions::decimal128") {
140140

141141
TEST_CASE("exp at easy points") {
142142
CHECK(test::as_long_double(math::exp(test::dec128_t{"0"})) == doctest::Approx(1.0L));
143-
CHECK(test::as_long_double(math::exp(test::dec128_t{"1"})) == doctest::Approx(std::expl(1.0L)));
143+
CHECK(test::as_long_double(math::exp(test::dec128_t{"1"})) == doctest::Approx(std::exp(1.0L)));
144144
}
145145

146146
TEST_CASE("log at easy points") {

0 commit comments

Comments
 (0)