Skip to content

Commit e39d98f

Browse files
SCCPPGHA-15 Use unified sonarqube-scan-action (#14)
1 parent a48fad3 commit e39d98f

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ jobs:
2323
- name: install gcovr 5.0
2424
run: |
2525
pip install gcovr==5.0 # 5.1 is not supported
26-
- name: Install sonar-scanner and build-wrapper
27-
uses: sonarsource/sonarcloud-github-c-cpp@v3
28-
- name: Run build-wrapper
26+
- name: Install Build Wrapper
27+
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v4
28+
- name: Run Build Wrapper
2929
run: |
3030
mkdir build
3131
cmake -S . -B build
@@ -37,11 +37,11 @@ jobs:
3737
- name: Collect coverage into one XML report
3838
run: |
3939
gcovr --sonarqube > coverage.xml
40-
- name: Run sonar-scanner
40+
- name: SonarQube Scan
41+
uses: SonarSource/sonarqube-scan-action@v4
4142
env:
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4343
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }} # Put the name of your token here
44-
run: |
45-
sonar-scanner \
46-
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json" \
44+
with:
45+
args: >
46+
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"
4747
--define sonar.coverageReportPaths=coverage.xml

README.adoc

Lines changed: 11 additions & 11 deletions
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 analyzed on https://sonarcloud.io/dashboard?id=sonarsource-cfamily-examples_linux-cmake-gcovr-gh-actions-sc[SonarCloud]!*
11+
*The test coverage shown here works on both SonarQube Server and Cloud. This project is analyzed on https://sonarcloud.io/dashboard?id=sonarsource-cfamily-examples_linux-cmake-gcovr-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 <<code-description,here>>. +
@@ -18,26 +18,26 @@ To get coverage and feed it to the sonar-scanner, use the following procedure.
1818

1919
. Add `--coverage` compilation flag to instrument the binaries
2020
. Run the test binaries to count covered lines
21-
. Run `gcovr --sonarqube` to produce the SonarQube- and SonarCloud-compatible XML coverage report
21+
. Run `gcovr --sonarqube` to produce the SonarQube-compatible XML coverage report
2222
. Point the `sonar.coverageReportPaths` property to the generated coverage-report file
23-
. Run `sonar-scanner` as the final step
23+
. Run the SonarQube scan using https://github.com/SonarSource/sonarqube-scan-action[the SonarSource/sonarqube-scan-action action] as final step
2424

2525
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.
2626

2727
= Documentation
2828

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

3535
= Code Description
3636

3737
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.
3838

3939
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.
40-
The downstream repositories are analyzed either with https://www.sonarqube.org/[SonarQube] or https://sonarcloud.io/[SonarCloud].
40+
The downstream repositories are analyzed either with https://www.sonarqube.org/[SonarQube Server] or https://sonarcloud.io/[SonarQube Cloud].
4141

4242
You can find examples for:
4343

@@ -64,8 +64,8 @@ Running on the following CI services:
6464

6565
Configured for analysis on:
6666

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

7070
You can find also a few examples demonstrating:
7171

0 commit comments

Comments
 (0)