Skip to content

Commit 16e0648

Browse files
SCCPPGHA-15 Use unified sonarqube-scan-action (#14)
1 parent 5c1aa58 commit 16e0648

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
uses: KyleMayes/install-llvm-action@v1.6.1
2020
with:
2121
version: "15.0.6"
22-
- name: Install sonar-scanner and build-wrapper
23-
uses: sonarsource/sonarcloud-github-c-cpp@v3
24-
- name: Run build-wrapper
22+
- name: Install Build Wrapper
23+
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v4
24+
- name: Run Build Wrapper
2525
run: |
2626
mkdir build
2727
cmake -S . -B build
@@ -38,11 +38,11 @@ jobs:
3838
- name: Collect the coverage
3939
run: |
4040
llvm-cov show --show-branches=count --instr-profile merged.profdata build/coverage_test1 -object build/coverage_test2 > coverage.txt
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" \
45+
with:
46+
args: >
47+
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"
4848
--define sonar.cfamily.llvm-cov.reportPath=coverage.txt

README.adoc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
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.
12-
In SonarQube import of branch coverage information from llvm-cov report is available only starting from SonarQube version `10.0`.
13-
This project is analysed on https://sonarcloud.io/dashboard?id=sonarsource-cfamily-examples_linux-cmake-llvm-cov-gh-actions-sc[SonarCloud]!*
11+
*The test coverage shown here works on both SonarQube Server and Cloud.
12+
In SonarQube Server, the import of branch coverage information from llvm-cov report is available only starting from version `10.0`.
13+
This project is analysed on https://sonarcloud.io/dashboard?id=sonarsource-cfamily-examples_linux-cmake-llvm-cov-gh-actions-sc[SonarQube Cloud]!*
1414

1515
:note-caption: :information_source:
1616
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>>. +
@@ -25,24 +25,24 @@ To get coverage and feed it to the sonar-scanner, use the following procedure.
2525
. Run `llvm-cov show --show-branches=count` on all the test executable files (or all object files you are interested in).
2626
. Save the output (the source files annotated with coverage counters) into a file
2727
. Point the property `sonar.cfamily.llvm-cov.reportPath` to the file with coverage report.
28-
. Run `sonar-scanner` as the final step
28+
. Run the SonarQube scan using https://github.com/SonarSource/sonarqube-scan-action[the SonarSource/sonarqube-scan-action action] as final step
2929

3030
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.
3131

3232
= Documentation
3333

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

4040
= Code Description
4141

4242
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.
4343

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

4747
You can find examples for:
4848

@@ -69,8 +69,8 @@ Running on the following CI services:
6969

7070
Configured for analysis on:
7171

72-
* https://github.com/sonarsource-cfamily-examples?q=-sq[SonarQube]
73-
* https://github.com/sonarsource-cfamily-examples?q=-sc[SonarCloud]
72+
* https://github.com/sonarsource-cfamily-examples?q=-sq[SonarQube Server]
73+
* https://github.com/sonarsource-cfamily-examples?q=-sc[SonarQube Cloud]
7474

7575
You can find also a few examples demonstrating:
7676

0 commit comments

Comments
 (0)