name: C++ Tests; Full Static Analysis on: push: branches: - develop - main paths: - '.github/workflows/cpp.yml' - 'cpp/**' - 'python/**' pull_request: branches: - develop - main types: - opened - synchronize - reopened paths: - '.github/workflows/cpp.yml' - 'cpp/**' - 'python/**' env: APT_PACKAGES: libspdlog-dev libpcap-dev libevdev2 libev-dev protobuf-compiler libgtest-dev libgmock-dev jobs: unit_tests: runs-on: ubuntu-24.04 defaults: run: working-directory: cpp steps: - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Install dependencies run: sudo apt-get install ${{ env.APT_PACKAGES }} - name: Build unit tests run: DEBUG=1 make -j $(nproc) test - name: Run unit tests run: (set -o pipefail && bin/piscsi_test | tee piscsi_test_log.txt) - name: Upload logs uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: name: piscsi_test_log.txt path: cpp/piscsi_test_log.txt sonarcloud: runs-on: ubuntu-24.04 if: > (github.event_name == 'push' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot') || (github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' && github.actor != 'dependabot') env: BUILD_WRAPPER_OUT_DIR: "$HOME/.build_wrapper_out" steps: - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 with: fetch-depth: 0 - name: Install dependencies run: sudo apt-get install ${{ env.APT_PACKAGES }} - name: Install Build Wrapper uses: SonarSource/sonarqube-scan-action/install-build-wrapper@a31c9398be7ace6bbfaf30c0bd5d415f843d45e9 # v7.0.0 - name: Generate coverage run: >- (mkdir -p ${{ env.BUILD_WRAPPER_OUT_DIR }} || true) && build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make -j $(nproc) -C cpp coverage - name: Run gcov working-directory: cpp run: gcov --preserve-paths $(find -name '*.gcno') - name: Run sonar-scanner uses: sonarsource/sonarqube-scan-action@a31c9398be7ace6bbfaf30c0bd5d415f843d45e9 # v7.0.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} with: args: | --define sonar.cfamily.compile-commands=${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json --define sonar.projectKey=akuker-PISCSI --define sonar.organization=piscsi --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" --define sonar.cfamily.gcov.reportsPath=. --define sonar.coverage.exclusions="cpp/**/test/**" --define sonar.cpd.exclusions="cpp/**/test/**" --define sonar.inclusions="cpp/**,python/**" --define sonar.python.version=3.9,3.11