name: CI on: push: branches: [ main, develop ] pull_request: branches: [ main, develop ] jobs: build-and-test: name: Build and Test runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest] include: - os: ubuntu-latest cc: gcc cxx: g++ steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v4 with: python-version: '3.x' - name: Install Meson and Ninja run: | python -m pip install --upgrade pip pip install meson ninja - name: Install dependencies (Ubuntu) if: matrix.os == 'ubuntu-latest' run: | sudo apt-get update sudo apt-get install -y libboost-system-dev libgtest-dev libgmock-dev build-essential - name: Setup build directory run: | meson setup builddir env: CC: ${{ matrix.cc }} CXX: ${{ matrix.cxx }} - name: Compile run: | meson compile -C builddir - name: Run tests run: | meson test -C builddir --verbose - name: Upload test results uses: actions/upload-artifact@v4 if: always() with: name: test-results-${{ matrix.os }} path: builddir/meson-logs/ coverage: name: Code Coverage runs-on: ubuntu-latest needs: build-and-test steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v4 with: python-version: '3.x' - name: Install Meson and Ninja run: | python -m pip install --upgrade pip pip install meson ninja - name: Install dependencies and coverage tools run: | sudo apt-get update sudo apt-get install -y libboost-system-dev libgtest-dev libgmock-dev build-essential lcov - name: Setup build directory with coverage run: | meson setup builddir -Db_coverage=true env: CC: gcc CXX: g++ - name: Compile with coverage run: | meson compile -C builddir - name: Run tests with coverage run: | meson test -C builddir --verbose - name: Generate coverage report run: | # Create coverage directory mkdir -p coverage # Capture coverage data lcov --capture --directory builddir --output-file coverage/coverage.info --ignore-errors mismatch,mismatch,unused # Remove system headers and test files from coverage lcov --remove coverage/coverage.info '/usr/*' '*/test_*' '*/gtest/*' --output-file coverage/coverage_filtered.info --ignore-errors mismatch,mismatch,unused # Generate HTML report genhtml coverage/coverage_filtered.info --output-directory coverage/html # Display coverage summary lcov --summary coverage/coverage_filtered.info --ignore-errors mismatch,mismatch,unused - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 with: file: coverage/coverage_filtered.info flags: unittests name: codecov-umbrella fail_ci_if_error: false - name: Upload coverage HTML report uses: actions/upload-artifact@v4 with: name: coverage-report path: coverage/html/ - name: Coverage Summary run: | echo "## Coverage Report" >> $GITHUB_STEP_SUMMARY echo "Coverage data has been uploaded to Codecov and HTML report is available as an artifact." >> $GITHUB_STEP_SUMMARY lcov --summary coverage/coverage_filtered.info >> $GITHUB_STEP_SUMMARY