Skip to content

Commit d196008

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

4 files changed

Lines changed: 65 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,64 @@ 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+
steps:
319+
- name: Checkout
320+
uses: actions/checkout@v5
321+
with:
322+
fetch-depth: 0
323+
324+
- name: Install dependencies
325+
shell: bash
326+
run: |
327+
sudo apt-get update
328+
sudo apt-get install -y \
329+
cmake \
330+
ninja-build \
331+
gcc-14 \
332+
g++-14 \
333+
lcov
334+
335+
- name: Configure
336+
shell: bash
337+
env:
338+
CC: gcc-14
339+
CXX: g++-14
340+
run: |
341+
cmake -B build -G Ninja \
342+
-DCMAKE_BUILD_TYPE=Debug \
343+
-DCMAKE_C_STANDARD=17 \
344+
-DCMAKE_CXX_STANDARD=23 \
345+
-DCMAKE_C_COMPILER="$CC" \
346+
-DCMAKE_CXX_COMPILER="$CXX" \
347+
-DCMAKE_C_FLAGS="--coverage" \
348+
-DCMAKE_CXX_FLAGS="--coverage" \
349+
-DCMAKE_EXE_LINKER_FLAGS="--coverage" \
350+
-DCMAKE_SHARED_LINKER_FLAGS="--coverage"
351+
352+
- name: Build
353+
run: cmake --build build --parallel
354+
355+
- name: Test
356+
run: ctest --test-dir build --output-on-failure
357+
358+
- name: Capture coverage
359+
shell: bash
360+
run: |
361+
lcov --directory build --capture --output-file coverage.info
362+
lcov --remove coverage.info '/usr/*' '*/test/*' '*/_deps/*' --output-file coverage.info
363+
lcov --list coverage.info
364+
365+
- name: Upload coverage reports to Codecov
366+
uses: codecov/codecov-action@v5
367+
with:
368+
files: coverage.info
369+
fail_ci_if_error: true
370+
env:
371+
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)