From 157583e36dba33b25666cc5993d2c2a530032780 Mon Sep 17 00:00:00 2001 From: oir Date: Sun, 15 Nov 2026 11:30:50 -0500 Subject: [PATCH 1/6] expand CI coverage --- .github/workflows/build-test.yml | 69 +++++++++++++++++++++++++++----- tests/meson.build | 2 +- 2 files changed, 59 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index ffd2a51..cebe64b 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -7,9 +7,30 @@ on: branches: [ main ] jobs: build-and-test-for-cpp-meson: - name: "Build and test for C++ with meson" - timeout-minutes: 10 - runs-on: ubuntu-24.04 + name: "Build and test for C++ with ${{ matrix.compiler }}" + timeout-minutes: 15 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - compiler: GCC 13 + os: ubuntu-24.04 + cxx: g++-13 + buildtype: debug + coverage: true + - compiler: GCC 14 + os: ubuntu-24.04 + cxx: g++-14 + buildtype: release + coverage: false + - compiler: Clang 18 + os: macos-15 + cxx: clang++ + buildtype: debug + coverage: false + env: + CXX: ${{ matrix.cxx }} steps: - uses: actions/checkout@v4 with: @@ -18,20 +39,29 @@ jobs: with: python-version: '3.11' - name: "Install tooling" + run: python -m pip install meson ninja + - name: "Install coverage tooling" + if: matrix.coverage run: | - sudo apt-get install lcov ninja-build - g++-13 --version + sudo apt-get install lcov gcov-13 --version lcov --version - pip install meson pytest + - name: "Configure" + shell: bash + run: | + if [ "$RUNNER_OS" = "macOS" ]; then + export CXX="$(brew --prefix llvm@18)/bin/clang++" + fi + "$CXX" --version + meson setup build --buildtype=${{ matrix.buildtype }} --warnlevel=3 \ + -Db_coverage=${{ matrix.coverage }} -Db_ndebug=if-release - name: "Build and test" run: | - CXX=g++-13 meson setup build --buildtype=debug --warnlevel=3 -Db_coverage=true meson compile -C build tests - ./build/tests/test.out - ./build/tests/test-fmtlib.out - ./build/tests/test-stdfmt.out + meson test -C build --no-rebuild --print-errorlogs \ + test.out test-fmtlib.out test-stdfmt.out - name: "Generate coverage" + if: matrix.coverage run: | lcov -c -d build -o cov.info --gcov-tool gcov-13 --ignore-errors mismatch lcov --gcov-tool gcov-13 \ @@ -42,18 +72,24 @@ jobs: -o barkeep.info rm cov.info - name: Coveralls + if: matrix.coverage uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: barkeep.info build-and-test-for-cpp-msvc: name: "Build and test for C++ with MSVC" - timeout-minutes: 5 + timeout-minutes: 15 runs-on: windows-2022 steps: - uses: actions/checkout@v4 with: submodules: false + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: "Install tooling" + run: python -m pip install meson ninja - name: "Build and test" shell: cmd run: | @@ -70,6 +106,17 @@ jobs: /W4 /WX /I. test_package/test_package.cpp /Fe:test_package.exe if errorlevel 1 exit /b 1 .\test_package.exe + if errorlevel 1 exit /b 1 + rem Make Git's grep available while keeping MSVC's link.exe first. + set "PATH=%PATH%;%ProgramFiles%\Git\usr\bin" + set "CXX=cl" + meson setup build --buildtype=debug --warnlevel=3 ^ + "-Dcpp_args=['/utf-8', '/permissive-']" + if errorlevel 1 exit /b 1 + meson compile -C build tests + if errorlevel 1 exit /b 1 + meson test -C build --no-rebuild --print-errorlogs ^ + test.out test-fmtlib.out test-stdfmt.out build-and-test-for-python: name: "Build and test for Python" timeout-minutes: 10 diff --git a/tests/meson.build b/tests/meson.build index 80fdf29..c565be8 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -31,7 +31,7 @@ foreach src : test_sources include_directories : incdir, dependencies : deps + [catch]) tests += [exe] - test(exec_name, exe) + test(exec_name, exe, timeout: 600) endforeach alias_target('tests', tests) From 76ab0a56dff011fac1d78654b7e81729af9308c9 Mon Sep 17 00:00:00 2001 From: oir Date: Sun, 15 Nov 2026 13:15:27 -0500 Subject: [PATCH 2/6] try -werror --- .github/workflows/build-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index cebe64b..21ea069 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -53,7 +53,7 @@ jobs: export CXX="$(brew --prefix llvm@18)/bin/clang++" fi "$CXX" --version - meson setup build --buildtype=${{ matrix.buildtype }} --warnlevel=3 \ + meson setup build --buildtype=${{ matrix.buildtype }} --warnlevel=3 --werror \ -Db_coverage=${{ matrix.coverage }} -Db_ndebug=if-release - name: "Build and test" run: | @@ -110,7 +110,7 @@ jobs: rem Make Git's grep available while keeping MSVC's link.exe first. set "PATH=%PATH%;%ProgramFiles%\Git\usr\bin" set "CXX=cl" - meson setup build --buildtype=debug --warnlevel=3 ^ + meson setup build --buildtype=debug --warnlevel=3 --werror ^ "-Dcpp_args=['/utf-8', '/permissive-']" if errorlevel 1 exit /b 1 meson compile -C build tests From fd9824a84814324a9337b8894f651aaf0e44a2ae Mon Sep 17 00:00:00 2001 From: oir Date: Sun, 15 Nov 2026 13:36:42 -0500 Subject: [PATCH 3/6] address warnings --- tests/demo.cpp | 11 +++++------ tests/test-fmtlib.cpp | 3 ++- tests/test-stdfmt.cpp | 3 ++- tests/test.cpp | 3 ++- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/demo.cpp b/tests/demo.cpp index 8ce51e5..12e4699 100644 --- a/tests/demo.cpp +++ b/tests/demo.cpp @@ -120,7 +120,7 @@ Demo float_counter("float_counter", "Floating point counter", []() { }); for (int i = 0; i < 1010; i++) { std::this_thread::sleep_for(13ms); - work += 0.213; + work += 0.213f; } } }); @@ -269,7 +269,6 @@ Demo three_counters_delim( "Composite display of three counters with custom delimiter", []() { static const std::string blue = "\033[34m"; - static const std::string reset = "\033[0m"; std::atomic squares{0}, cubes{0}, hypercubes{0}; // clang-format off auto counters = bk::Composite( @@ -316,7 +315,7 @@ Demo three_bars( // ... []() { std::atomic linear{0}, quad{0}, cubic{0}; // clang-format off - auto bars = bk::Composite( + auto progress_bars = bk::Composite( {bk::ProgressBar(&linear, { .total = 100, .message = "Linear ", @@ -340,19 +339,19 @@ Demo three_bars( // ... })}, "\n"); // clang-format on - bars->show(); + progress_bars->show(); for (int i = 0; i < 100; i++) { std::this_thread::sleep_for(130ms); linear++; quad += linear; cubic += quad; } - bars->done(); + progress_bars->done(); }); Demo iterable_bar("iterable_bar", "Iterable progress bar", []() { std::vector v(300, 0); - std::iota(v.begin(), v.end(), 1); // 1, 2, 3, ..., 300 + std::iota(v.begin(), v.end(), 1.0f); // 1, 2, 3, ..., 300 float sum = 0; for (auto x : bk::IterableBar(v, {.message = "Summing", .interval = .02})) { std::this_thread::sleep_for(1.s / x); diff --git a/tests/test-fmtlib.cpp b/tests/test-fmtlib.cpp index 4f1600c..4e5872e 100644 --- a/tests/test-fmtlib.cpp +++ b/tests/test-fmtlib.cpp @@ -250,7 +250,8 @@ TEST_CASE("Composite bar-counter", "[composite]") { { // check bar correctness auto bar_part = part.substr(14, 32); - long spaces = std::count(bar_part.begin(), bar_part.end(), ' '); + long spaces = + static_cast(std::count(bar_part.begin(), bar_part.end(), ' ')); CHECK(spaces <= last_spaces); last_spaces = spaces; size_t i = 1; diff --git a/tests/test-stdfmt.cpp b/tests/test-stdfmt.cpp index db4d08f..6a99b09 100644 --- a/tests/test-stdfmt.cpp +++ b/tests/test-stdfmt.cpp @@ -246,7 +246,8 @@ TEST_CASE("Composite bar-counter", "[composite]") { { // check bar correctness auto bar_part = part.substr(14, 32); - long spaces = std::count(bar_part.begin(), bar_part.end(), ' '); + long spaces = + static_cast(std::count(bar_part.begin(), bar_part.end(), ' ')); CHECK(spaces <= last_spaces); last_spaces = spaces; size_t i = 1; diff --git a/tests/test.cpp b/tests/test.cpp index 8904eec..e25046c 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -750,7 +750,8 @@ TEST_CASE("Composite bar-counter", "[composite]") { { // check bar correctness auto bar_part = part.substr(14, 32); - long spaces = std::count(bar_part.begin(), bar_part.end(), ' '); + long spaces = + static_cast(std::count(bar_part.begin(), bar_part.end(), ' ')); CHECK(spaces <= last_spaces); last_spaces = spaces; size_t i = 1; From 39e08249cb309e14c7ebeeb082dc3917b2ccced5 Mon Sep 17 00:00:00 2001 From: oir Date: Sun, 15 Nov 2026 14:01:30 -0500 Subject: [PATCH 4/6] add asan and ubsan --- .github/workflows/build-test.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 21ea069..25dc5bd 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -117,6 +117,32 @@ jobs: if errorlevel 1 exit /b 1 meson test -C build --no-rebuild --print-errorlogs ^ test.out test-fmtlib.out test-stdfmt.out + build-and-test-for-cpp-sanitizers: + name: "Build and test for C++ with ASan and UBSan" + timeout-minutes: 15 + runs-on: ubuntu-24.04 + env: + CXX: clang++-18 + UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1 + steps: + - uses: actions/checkout@v4 + with: + submodules: false + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: "Install tooling" + run: python -m pip install meson ninja + - name: "Configure" + run: | + "$CXX" --version + meson setup build --buildtype=debug --warnlevel=3 --werror \ + -Db_sanitize=address,undefined -Db_lundef=false + - name: "Build and test" + run: | + meson compile -C build tests + meson test -C build --no-rebuild --print-errorlogs \ + test.out test-fmtlib.out test-stdfmt.out build-and-test-for-python: name: "Build and test for Python" timeout-minutes: 10 From 37e69b33b0d87d608dff028adb08f5fcd8679e05 Mon Sep 17 00:00:00 2001 From: oir Date: Sun, 15 Nov 2026 14:47:41 -0500 Subject: [PATCH 5/6] attempt to test api compatibility explicitly --- .github/workflows/build-test.yml | 1 + tests/meson.build | 6 ++++++ tests/test-api-compatibility.cpp | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/test-api-compatibility.cpp diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 25dc5bd..b9f30d8 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -200,5 +200,6 @@ jobs: python/barkeep.cpp \ test_package/test_package.cpp \ tests/demo-fmtlib.cpp tests/demo-stdfmt.cpp tests/demo.cpp \ + tests/test-api-compatibility.cpp \ tests/test-fmtlib.cpp tests/test-stdfmt.cpp tests/test.cpp \ tests/testutil.h diff --git a/tests/meson.build b/tests/meson.build index c565be8..1076c53 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -34,4 +34,10 @@ foreach src : test_sources test(exec_name, exe, timeout: 600) endforeach +compatibility = static_library('test-api-compatibility', + 'test-api-compatibility.cpp', + include_directories : incdir, + dependencies : threads) +tests += [compatibility] + alias_target('tests', tests) diff --git a/tests/test-api-compatibility.cpp b/tests/test-api-compatibility.cpp new file mode 100644 index 0000000..e7624ff --- /dev/null +++ b/tests/test-api-compatibility.cpp @@ -0,0 +1,18 @@ +#include + +// Compile-only examples of downstream subclasses. Keep these types explicit so +// changes to the extension interface fail the C++ builds. +class CustomDisplay : public barkeep::BaseDisplay { + protected: + long render_(bool, const std::string&) override { return render_message_(); } +}; + +class CustomAnimation : public barkeep::AnimationDisplay { + public: + unsigned short& current_frame() { return frame_; } +}; + +class CustomDisplayer : public barkeep::AsyncDisplayer { + public: + long& last_newline_count() { return last_num_newlines_; } +}; From 26ad9b24dea750e58fa574f50eb6ee4b1bcbb669 Mon Sep 17 00:00:00 2001 From: oir Date: Sun, 15 Nov 2026 20:35:51 -0500 Subject: [PATCH 6/6] add more compiler versions to ci --- .github/workflows/build-test.yml | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index b9f30d8..8d3a7d8 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -24,11 +24,21 @@ jobs: cxx: g++-14 buildtype: release coverage: false + - compiler: GCC 15 + os: ubuntu-26.04 + cxx: g++-15 + buildtype: release + coverage: false - compiler: Clang 18 os: macos-15 cxx: clang++ buildtype: debug coverage: false + - compiler: Clang 22 + os: ubuntu-26.04 + cxx: clang++-22 + buildtype: debug + coverage: false env: CXX: ${{ matrix.cxx }} steps: @@ -78,9 +88,19 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: barkeep.info build-and-test-for-cpp-msvc: - name: "Build and test for C++ with MSVC" + name: "Build and test for C++ with ${{ matrix.compiler }}" timeout-minutes: 15 - runs-on: windows-2022 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - compiler: MSVC + os: windows-2022 + vs_version: '[17.0,18.0)' + - compiler: MSVC (VS 2026) + os: windows-2025-vs2026 + vs_version: '[18.0,19.0)' steps: - uses: actions/checkout@v4 with: @@ -95,9 +115,9 @@ jobs: run: | set "BARKEEP_VS_PATH=" set "PATH=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer;%PATH%" - for /f "usebackq delims=" %%i in (`vswhere -latest -version "[17.0,18.0)" -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "BARKEEP_VS_PATH=%%i" + for /f "usebackq delims=" %%i in (`vswhere -latest -version "${{ matrix.vs_version }}" -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "BARKEEP_VS_PATH=%%i" if not defined BARKEEP_VS_PATH ( - echo Visual Studio 2022 C++ tools were not found. + echo Requested Visual Studio C++ tools were not found. exit /b 1 ) call "%BARKEEP_VS_PATH%\Common7\Tools\VsDevCmd.bat" -arch=x64 -host_arch=x64