Skip to content

Commit f6a70e7

Browse files
committed
ci: use sonarqube-scan-action
Fixes #153
1 parent bb8e89a commit f6a70e7

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

.github/workflows/static-analysis.yml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ jobs:
3232
key: ${{ github.job }}
3333
max-size: 2G
3434

35-
- uses: lukka/run-cmake@af1be47fd7c933593f687731bc6fdbee024d3ff4 # v10.8
35+
- name: Build for coverage
36+
uses: lukka/run-cmake@af1be47fd7c933593f687731bc6fdbee024d3ff4 # v10.8
3637
with:
3738
configurePreset: "Coverage"
3839
buildPreset: "Coverage"
@@ -41,25 +42,25 @@ jobs:
4142
env:
4243
GTEST_OUTPUT: "xml:${{ github.workspace }}/testresults/"
4344

44-
- name: Convert Results
45+
- name: Collect coverage
4546
run: |
46-
{ echo '<testExecutions version="1">'; xsltproc .github/formatters/gtest-to-generic-execution.xslt ${{ github.workspace }}/testresults/*.xml; echo '</testExecutions>'; } | tee execution.xml > /dev/null
47-
gcovr --sonarqube=coverage.xml --exclude-lines-by-pattern '.*assert\(.*\);|.*really_assert\(.*\);|.*std::abort();' --exclude-unreachable-branches --exclude-throw-branches -j "$(nproc)"
48-
cp .build/Coverage/compile_commands.json compile_commands.json
47+
gcovr --sonarqube=coverage.xml --exclude-lines-by-pattern '.*assert\(.*\);|.*really_assert\(.*\);|.*std::abort();' --exclude-unreachable-branches --exclude-throw-branches -j "$(nproc)" --exclude=.*/example/.* --exclude=.*/external/.* --exclude=.*/test/.*
4948
50-
- name: Prepare dependencies for sonar-scanner
51-
run: apt-get update && apt-get install -y --no-install-recommends curl
49+
- uses: philips-software/sonarqube-issue-conversion@574a39dedf13464c712b9d36be4bac33241884d8 # v1.0.1
50+
with:
51+
input: ${{ github.workspace }}/testresults/*.xml
52+
output: execution.xml
53+
transformation: gtest-to-generic-execution
5254

53-
- name: Install sonar-scanner and build-wrapper
54-
uses: sonarsource/sonarqube-github-c-cpp@e51317d858d1117fe6c451aa441841cb3e3ff358 # v2.1.0
55-
env:
56-
SONAR_HOST_URL: ${{ env.SONAR_SERVER_URL }}
55+
- name: Convert results
56+
run: |
57+
jq -s 'reduce .[] as $item ({}; . * $item)' reports/mull/*.json > reports/mull/merged-mutation.json
58+
jq --arg workspace "$GITHUB_WORKSPACE" -f .github/formatters/mutation-report-to-generic-issue.jq reports/mull/merged-mutation.json > mutation-sonar.json
59+
cp build/coverage/compile_commands.json compile_commands.json
5760
58-
- name: Run sonar-scanner
61+
- uses: sonarsource/sonarqube-scan-action@bfd4e558cda28cda6b5defafb9232d191be8c203 # v4.2.1
5962
env:
60-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6163
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
62-
run: sonar-scanner -D sonar.host.url="${{ env.SONAR_SERVER_URL }}"
6364

6465
codeql:
6566
name: CodeQL

0 commit comments

Comments
 (0)