Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: CI

on:
push:
branches: [master]
pull_request:

# Least privilege: the workflow only needs to read the repository. The repo
# default is `write`, so scope it down explicitly and drop the checkout token
# after fetch, so pull-request-controlled build/test steps never see a
# write-capable token.
permissions:
contents: read

jobs:
build-and-test:
name: build + unit tests (${{ matrix.cc }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
cc: [gcc, clang]
env:
CC: ${{ matrix.cc }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Configure
run: >
cmake -S . -B build
-DCMAKE_BUILD_TYPE=Release
-DBUILD_TESTS=ON -DBUILD_BENCHMARK=OFF -DBUILD_EXAMPLES=OFF
- name: Build
run: cmake --build build -j"$(nproc)"
- name: Unit tests
run: ctest --test-dir build --output-on-failure

sanitizers:
name: ASan + UBSan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Build td_test with ASan + UBSan
run: >
clang -O1 -g -std=gnu11
-fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer
-Isrc tests/unit/td_test.c src/tdigest.c -lm -o td_test_san
- name: Run
env:
# A fuzzed/huge compression can request an enormous capacity; let the
# library's allocation-failure path run instead of aborting the process.
ASAN_OPTIONS: detect_leaks=1:allocator_may_return_null=1
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1
run: ./td_test_san
4 changes: 4 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ endif()
if (BUILD_TESTS)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c99")
add_executable(td_test unit/td_test.c unit/minunit.h)
# minunit.h uses clock_gettime(), which the top-level "-std=c99" hides unless
# _POSIX_C_SOURCE is defined on the command line (before any header is included).
# Without this the td_test build fails with "unknown type name 'clockid_t'".
target_compile_definitions(td_test PRIVATE _POSIX_C_SOURCE=200809L)
target_link_libraries(td_test tdigest m)
enable_testing()
add_test(td_test td_test)
Expand Down
Loading