Skip to content

Add code coverage and static analysis to CI pipeline #15

Description

@dennisklein

Summary

Enhance the CI/CD pipeline with code coverage reporting, static analysis, and extended compatibility testing.

Proposed Enhancements

Code Coverage Reporting

  • Add gcov/lcov configuration to CMakeLists.txt

    option(ENABLE_COVERAGE "Enable code coverage" OFF)
    if(ENABLE_COVERAGE)
      target_compile_options(${target} PRIVATE --coverage)
      target_link_options(${target} PRIVATE --coverage)
    endif()
  • Add coverage job to GitHub Actions

    coverage:
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v4
        - name: Build with coverage
          run: |
            cmake -B build -DENABLE_COVERAGE=ON -DBUILD_TESTING=ON
            cmake --build build
        - name: Run tests
          run: ctest --test-dir build
        - name: Generate coverage report
          run: |
            lcov --capture --directory build --output-file coverage.info
            lcov --remove coverage.info '/usr/*' --output-file coverage.info
        - name: Upload to Codecov
          uses: codecov/codecov-action@v4
          with:
            files: ./coverage.info

Static Analysis

  • Add clang-tidy checks

    static-analysis:
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v4
        - name: Install tools
          run: sudo apt-get install -y clang-tidy cppcheck
        - name: Run clang-tidy
          run: |
            cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
            clang-tidy main.cpp --checks='*' -p build
        - name: Run cppcheck
          run: cppcheck --enable=all --error-exitcode=1 main.cpp
  • Create .clang-tidy configuration

    Checks: >
      *,
      -fuchsia-*,
      -google-*,
      -abseil-*,
      -modernize-use-trailing-return-type

Extended Slurm Version Testing

  • Add Slurm 22.05 LTS to build matrix

  • Add Slurm 25.x when available

  • Test against both Apptainer and SingularityCE

    strategy:
      matrix:
        slurm-version: ['22.05', '23.11', '24.11']
        container-runtime: ['apptainer', 'singularity-ce']

Additional CI Jobs

  • Add linting job (check formatting, shell scripts with shellcheck)
  • Add dependency scanning (Dependabot or similar)
  • Add SBOM generation
  • Add security scanning (e.g., Snyk, Trivy)

Workflow Improvements

  • Add concurrency control to avoid redundant builds

    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
      cancel-in-progress: true
  • Add caching for Docker layers and build artifacts

  • Add job summaries with test results and coverage badges

  • Configure branch protection rules requiring status checks

Documentation

  • Add badges to README.md
    • Build status ✓ (already present)
    • Runtime tests ✓ (already present)
    • Code coverage (new)
    • Static analysis status (new)

Benefits

  • Higher code quality through automated checks
  • Visibility into test coverage
  • Early detection of compatibility issues
  • Better confidence in changes

Implementation Order

  1. Code coverage (most valuable)
  2. Static analysis with clang-tidy
  3. Extended Slurm version testing
  4. Additional security scanning

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions