Skip to content

CI and Testing

Open-Lotto Wiki edited this page Jun 5, 2026 · 1 revision

CI & Testing


CI Pipeline

The CI pipeline runs on every push and pull request. It has 6 jobs:

Job Compiler(s) What it checks
build-and-test GCC + Clang (matrix) Release build compiles and all CTest tests pass
format-check — All source files comply with .clang-format
sanitizers GCC + Clang (matrix) Debug build with ASan + UBSan finds no issues
static-analysis — cppcheck + clang-tidy report no errors
coverage GCC Line coverage ≥ 70% (lcov)

A pull request must pass all 6 jobs before merge.


CTest Test Suite

16 tests are registered with CTest:

Test name Type Description
unit_combogen Unit 23 cases: uniqueness, range, boundaries, error handling
unit_plugin_loader Unit Plugin discovery and symbol resolution
unit_export Unit CSV and JSON output correctness
cli_lotto_success CLI integration Exit 0 for valid Lotto run
cli_eurojackpot_success CLI integration Exit 0 for valid Eurojackpot run
cli_list_games_success CLI integration --list-games exits 0
cli_*_fail (9 tests) CLI integration Invalid arguments exit non-zero (WILL_FAIL)

Running tests locally

# Run all tests
ctest --test-dir build --output-on-failure

# Run a specific test
ctest --test-dir build -R unit_combogen --output-on-failure

# List all registered tests
ctest --test-dir build -N

Code Quality Gates

clang-format

The project uses LLVM style with a 100-character column limit (.clang-format).

# Check (non-destructive)
clang-format -n -Werror $(find src plugins include tests -name "*.c" -o -name "*.h")

# Fix all files in-place
clang-format -i $(find src plugins include tests -name "*.c" -o -name "*.h")

Or use the helper script:

scripts/run_format_check.sh

cppcheck

scripts/run_cppcheck.sh

clang-tidy

The .clang-tidy config enables: clang-analyzer, bugprone, cert, misc, performance, portability.

scripts/run_clang_tidy.sh

Sanitizers (ASan + UBSan)

scripts/run_sanitizers.sh

Or build manually:

cmake -S . -B build-sanitizer \
  -DCMAKE_BUILD_TYPE=Debug \
  -DBUILD_TESTING=ON \
  -DCMAKE_C_FLAGS="-fsanitize=address,undefined -fno-sanitize-recover=undefined -g"
cmake --build build-sanitizer -j
ctest --test-dir build-sanitizer --output-on-failure

Coverage

scripts/run_coverage.sh

Generates an HTML report via lcov. The CI enforces a minimum threshold of 70%.


Pre-Commit Hook

Install once to run all 4 quality gates automatically before every commit:

scripts/install-git-hooks.sh

The pre-commit hook runs in order:

  1. scripts/run_format_check.sh
  2. scripts/run_cppcheck.sh
  3. scripts/run_clang_tidy.sh
  4. scripts/run_sanitizers.sh

If any gate fails, the commit is blocked.


Benchmarks

Throughput benchmarks are in tests/benchmark.c:

Metric Approximate value
Eurojackpot draws/sec ~195 k
Lotto 6aus49 draws/sec ~241 k

Run benchmarks:

scripts/run_benchmarks.sh
# or
./build/benchmark

Results are written to build/benchmark_results.json.

Clone this wiki locally