Skip to content

Commit 9c83437

Browse files
SCCPPGHA-15 Use unified sonarqube-scan-action (#11)
Co-authored-by: Antonio Aversa <[email protected]>
1 parent a2dae33 commit 9c83437

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

.github/workflows/build.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,24 @@ jobs:
2525
curl -L https://github.com/OpenCppCoverage/OpenCppCoverage/releases/download/release-0.9.9.0/OpenCppCoverageSetup-x64-0.9.9.0.exe -o OpenCppCoverageSetup.exe
2626
Start-Process -FilePath .\OpenCppCoverageSetup.exe -ArgumentList "/SUPRESSMSGBOXES /NORESTART /VERYSILENT" -NoNewWindow -Wait
2727
28-
- name: Install sonar-scanner and build-wrapper
29-
uses: sonarsource/sonarcloud-github-c-cpp@v3
28+
- name: Install Build Wrapper
29+
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v4
3030

31-
- name: Run build-wrapper
31+
- name: Run Build Wrapper
3232
run: |
33-
build-wrapper-win-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} msbuild sonar_scanner_example.vcxproj /t:rebuild /nodeReuse:false
33+
build-wrapper-win-x86-64.exe --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} msbuild sonar_scanner_example.vcxproj /t:rebuild /nodeReuse:false
3434
- name: Build tests
3535
run: |
3636
msbuild test1\test1.vcxproj
3737
msbuild test2\test2.vcxproj
3838
- name: Run tests with coverage
3939
run: |
4040
&"C:\Program Files\OpenCppCoverage\OpenCppCoverage.exe" --cover_children --sources=$(pwd) --modules test*\*\test*.dll "--export_type=cobertura:cobertura.xml" -- vstest.console.exe test1\*\test1.dll test2\*\test2.dll
41-
- name: Run sonar-scanner
41+
- name: SonarQube Scan
42+
uses: SonarSource/sonarqube-scan-action@v4
4243
env:
43-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4444
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }} # Put the name of your token here
45-
run: >
46-
sonar-scanner
47-
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"
48-
--define sonar.cfamily.cobertura.reportPaths="cobertura.xml"
45+
with:
46+
args: >
47+
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"
48+
--define sonar.cfamily.cobertura.reportPaths="cobertura.xml"

README.adoc

+11-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
image:{img-build-status}[Build Status, link={uri-build-status}]
99
image:{img-qg-status}[Quality Gate Status,link={uri-qg-status}]
1010

11-
*The test coverage shown here works on both SonarQube and SonarCloud. This project is analysed on https://sonarcloud.io/dashboard?id=sonarsource-cfamily-examples_windows-msbuild-opencppcoverage-gh-actions-sc[SonarCloud]!*
11+
*The test coverage shown here works on both SonarQube Server and Cloud. This project is analysed on https://sonarcloud.io/dashboard?id=sonarsource-cfamily-examples_windows-msbuild-opencppcoverage-gh-actions-sc[SonarQube Cloud]!*
1212

1313
:note-caption: :information_source:
1414
NOTE: This simple example aims at demonstrating code coverage in action. It explains how to add coverage on a project for which the analysis is already configured. Analysis configuration examples are available https://github.com/sonarsource-cfamily-examples?q=topic%3Amsbuild[here]. +
@@ -18,25 +18,25 @@ To get coverage and feed it to the sonar-scanner, use the following procedure:
1818

1919
. Build and run your tests using `vstest.console.exe`, wrapping the call with `OpenCppCoverage.exe`
2020
. Point the property `sonar.cfamily.cobertura.reportPaths` to the path that will contain your XML coverage report
21-
. Run `sonar-scanner` as the final step
21+
. Run the SonarQube scan using https://github.com/SonarSource/sonarqube-scan-action[the SonarSource/sonarqube-scan-action action] as final step
2222

2323
You can take a look at the link:sonar-project.properties[sonar-project.properties] and link:.github/workflows/build.yml[build.yml] to see it in practice.
2424

2525
= Documentation
2626

27-
- https://docs.sonarcloud.io/advanced-setup/languages/c-c-objective-c/[Documentation overview of the C, C++ and Objective-C analyzer]
28-
- https://docs.sonarcloud.io/getting-started/github/[Documentation of using SonarCloud with GitHub]
29-
- https://docs.sonarcloud.io/advanced-setup/languages/c-family/prerequisites/#generating-a-compilation-database[Generating a compilation database (compile_commands.json)]
30-
- https://docs.sonarsource.com/sonarcloud/advanced-setup/languages/c-family/running-the-analysis/[Running the analysis in Compilation Database mode]
31-
- https://docs.sonarcloud.io/enriching/test-coverage/test-coverage-parameters/[Test coverage parameters]
32-
- https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/github-actions-for-sonarcloud/[GitHub Action for C and C++ usage]
27+
- https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/languages/c-family/overview/[C/C++/Objective-C analysis overview]
28+
- https://docs.sonarsource.com/sonarqube-cloud/getting-started/github/[Getting started with GitHub]
29+
- https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/languages/c-family/prerequisites/#generating-a-compilation-database[Generating a compilation database]
30+
- https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/languages/c-family/running-the-analysis/[Running the CFamily analysis]
31+
- https://docs.sonarsource.com/sonarqube-cloud/enriching/test-coverage/test-coverage-parameters/[Test coverage parameters]
32+
- https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/ci-based-analysis/github-actions-for-sonarcloud/[Analyze your repository with GitHub Actions]
3333

3434
= Code Description
3535

3636
An example of a flawed C++ code. The https://github.com/sonarsource-cfamily-examples/code[code repository] can be https://github.com/sonarsource-cfamily-examples/automatic-analysis-sc[analyzed automatically], but it can also be compiled with different build systems using different CI pipelines on Linux, macOS, and Windows.
3737

3838
The https://github.com/sonarsource-cfamily-examples/code[code repository] is forked into other repositories in https://github.com/sonarsource-cfamily-examples[this collection] to add a specific build system, platform, and CI.
39-
The downstream repositories are analyzed either with https://www.sonarqube.org/[SonarQube] or https://sonarcloud.io/[SonarCloud].
39+
The downstream repositories are analyzed either with https://www.sonarqube.org/[SonarQube Server] or https://sonarcloud.io/[SonarQube Cloud].
4040

4141
You can find examples for:
4242

@@ -63,8 +63,8 @@ Running on the following CI services:
6363

6464
Configured for analysis on:
6565

66-
* https://github.com/sonarsource-cfamily-examples?q=-sq[SonarQube]
67-
* https://github.com/sonarsource-cfamily-examples?q=-sc[SonarCloud]
66+
* https://github.com/sonarsource-cfamily-examples?q=-sq[SonarQube Server]
67+
* https://github.com/sonarsource-cfamily-examples?q=-sc[SonarQube Cloud]
6868

6969
You can find also a few examples demonstrating:
7070

0 commit comments

Comments
 (0)