Skip to content

Commit 1df913b

Browse files
authored
ci: use sonarqube-scan-action (#154)
Fixes #153
1 parent fb32f43 commit 1df913b

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

.github/workflows/static-analysis.yml

Lines changed: 13 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,23 @@ 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+
cp .build/Coverage/compile_commands.json compile_commands.json
5758
58-
- name: Run sonar-scanner
59+
- uses: sonarsource/sonarqube-scan-action@bfd4e558cda28cda6b5defafb9232d191be8c203 # v4.2.1
5960
env:
60-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6161
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
62-
run: sonar-scanner -D sonar.host.url="${{ env.SONAR_SERVER_URL }}"
6362

6463
codeql:
6564
name: CodeQL

0 commit comments

Comments
 (0)