From 8dca2b546a3cc8bf58d0f06a28eb1d867f1976a0 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Mon, 16 Oct 2023 20:57:23 +0200 Subject: Added Coverage generation for SonarCloud. Signed-off-by: Toni Uhlig --- .github/workflows/sonarcloud.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to '.github') diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 7ea9dbb63..30442f731 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -16,6 +16,14 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 1 + - uses: actions/checkout@v3 + - name: Set up Python 3.8 for gcovr + uses: actions/setup-python@v4 + with: + python-version: 3.8 + - name: install gcovr 5.0 + run: | + pip install gcovr==5.0 # 5.1 is not supported - name: Install sonar-scanner and build-wrapper uses: SonarSource/sonarcloud-github-c-cpp@v2 - name: Install Prerequisites @@ -29,7 +37,14 @@ jobs: build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config Release - name: Run tests run: | - ./test/run_tests.sh ./libnDPI ./build/nDPId-test + for file in $(ls libnDPI/tests/cfgs/*/pcap/*.pcap libnDPI/tests/cfgs/*/pcap/*.pcapng libnDPI/tests/cfgs/*/pcap/*.cap); do \ + echo -n "${file} "; \ + ./build/nDPId-test "${file}" >/dev/null 2>/dev/null; \ + echo "[ok]"; \ + done + - name: Collect coverage into one XML report + run: | + gcovr --sonarqube > coverage.xml - name: Run sonar-scanner env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -42,4 +57,5 @@ jobs: --define sonar.projectKey=lnslbrty_nDPId \ --define sonar.exclusions=dependencies/uthash/tests/** \ --define sonar.verbose=true \ - --define sonar.python.version=3.8 + --define sonar.python.version=3.8 \ + --define sonar.cfamily.gcov.reportsPath=coverage.xml -- cgit v1.2.3