Skip to content

Commit 2efbe45

Browse files
SCCPPGHA-15 Use unified sonarqube-scan-action (#12)
1 parent ec98aa4 commit 2efbe45

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

.github/workflows/build.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ jobs:
1515
- uses: actions/checkout@v4
1616
with:
1717
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
18-
- name: Install sonar-scanner
19-
uses: sonarsource/sonarcloud-github-c-cpp@v3
2018
- name: Install Ninja
2119
run: |
2220
wget https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip
@@ -33,10 +31,12 @@ jobs:
3331
-DCMAKE_CXX_COMPILER_CLANG_SCAN_DEPS=clang-scan-deps-${{env.CLANG_VERSION}}
3432
# The project needs to be built so the `.modmap` files are generated
3533
cmake --build build --target all
36-
- name: Run sonar-scanner
34+
- name: SonarQube Scan
35+
uses: SonarSource/sonarqube-scan-action@v4
3736
env:
3837
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3938
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }} # Put the name of your token here
40-
run: |
39+
with:
4140
# Set the property "sonar.cfamily.compile-commands" to the compilation database file
42-
sonar-scanner --define sonar.cfamily.compile-commands=build/compile_commands.json
41+
args: >
42+
--define sonar.cfamily.compile-commands=build/compile_commands.json

README.adoc

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= C++ example project scanned on SonarCloud using compilation database (compile_commands.json)
1+
= C++ example project scanned on SonarQube Cloud using compilation database (compile_commands.json)
22
// URIs:
33
:uri-qg-status: https://sonarcloud.io/dashboard?id=sonarsource-cfamily-examples_linux-cmake-compdb-gh-actions-sc
44
:img-qg-status: https://sonarcloud.io/api/project_badges/measure?project=sonarsource-cfamily-examples_linux-cmake-compdb-gh-actions-sc&metric=alert_status
@@ -8,27 +8,27 @@
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-
*This project is analysed on https://sonarcloud.io/dashboard?id=sonarsource-cfamily-examples_linux-cmake-compdb-gh-actions-sc[SonarCloud]!*
11+
*This project is analysed on https://sonarcloud.io/dashboard?id=sonarsource-cfamily-examples_linux-cmake-compdb-gh-actions-sc[SonarQube Cloud]!*
1212

1313

14-
It is very easy to analyze a C, C++ and Objective-C project with SonarCloud and https://docs.sonarcloud.io/getting-started/github/[GitHub Actions] using compilation database:
14+
It is very easy to analyze a C, C++ and Objective-C project with SonarQube Cloud and https://docs.sonarsource.com/sonarqube-cloud/getting-started/github/[GitHub Actions] using compilation database:
1515

1616
. Create a `sonar-project.properties` file to store your configuration
1717
. In your `.github/workflows/build.yml` file:
18-
.. Install the Sonar Scanner using https://github.com/SonarSource/sonarcloud-github-c-cpp[SonarCloud C and C++ Github Action]
1918
.. Generate the compilation database file (set `CMAKE_EXPORT_COMPILE_COMMANDS` to `ON`)
20-
.. Run `sonar-scanner` with the property `sonar.cfamily.compile-commands` set to your compilation database file
19+
.. Run the SonarQube scan using https://github.com/SonarSource/sonarqube-scan-action[the SonarSource/sonarqube-scan-action action] with the property `sonar.cfamily.compile-commands` set to your compilation database file
2120
. Ensure that your token is stored as a secret in your repository (`SONARCLOUD_TOKEN` in this example project). You can request new tokens using https://sonarcloud.io/account/security/[Account/Security page].
2221

2322
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.
2423

2524
= Documentation
2625

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/ci-based-analysis/github-actions-for-sonarcloud/[GitHub Action for C and C++ usage]
30-
- https://docs.sonarcloud.io/advanced-setup/languages/c-family/prerequisites/#generating-a-compilation-database[Generating a compilation database (compile_commands.json)]
31-
- https://docs.sonarsource.com/sonarcloud/advanced-setup/languages/c-family/running-the-analysis/[Running the analysis in Compilation Database mode]
26+
- https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/languages/c-family/overview/[C/C++/Objective-C analysis overview]
27+
- https://docs.sonarsource.com/sonarqube-cloud/getting-started/github/[Getting started with GitHub]
28+
- https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/ci-based-analysis/github-actions-for-sonarcloud/[Analyze your repository with GitHub Actions]
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+
3232

3333
= Linux\CMake
3434

@@ -46,7 +46,7 @@ make
4646
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.
4747

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

5151
You can find examples for:
5252

@@ -73,8 +73,8 @@ Running on the following CI services:
7373

7474
Configured for analysis on:
7575

76-
* https://github.com/sonarsource-cfamily-examples?q=-sq[SonarQube]
77-
* https://github.com/sonarsource-cfamily-examples?q=-sc[SonarCloud]
76+
* https://github.com/sonarsource-cfamily-examples?q=-sq[SonarQube Server]
77+
* https://github.com/sonarsource-cfamily-examples?q=-sc[SonarQube Cloud]
7878

7979
You can find also a few examples demonstrating:
8080

0 commit comments

Comments
 (0)