Skip to content

SQCPPGHA-13 Use unified sonarqube-scan-action #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: sonarsource/sonarqube-scan-action@master
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v4
env:
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} # SonarQube URL is stored in a GitHub secret
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 changes: 10 additions & 10 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= C++ example project scanned on SonarQube using AutoConfig
= C++ example project scanned on SonarQube Server using AutoConfig

:uri-qg-status: https://next.sonarqube.com/sonarqube/dashboard?id=sonarsource-cfamily-examples_linux-autoconfig-gh-actions-sq_409eae14-979c-4758-b5fb-8513b12efb8c
:img-qg-status: https://next.sonarqube.com/sonarqube/api/project_badges/measure?project=sonarsource-cfamily-examples_linux-autoconfig-gh-actions-sq_409eae14-979c-4758-b5fb-8513b12efb8c&metric=alert_status&token=sqb_f0094f1a85d801462c2cdea480dad9f11958385b
Expand All @@ -9,7 +9,7 @@
image:{img-build-status}[Build Status, link={uri-build-status}]
image:{img-qg-status}[Quality Gate Status,link={uri-qg-status}]

*This project is analysed on https://next.sonarqube.com/sonarqube/dashboard?id=sonarsource-cfamily-examples_linux-autoconfig-gh-actions-sq_409eae14-979c-4758-b5fb-8513b12efb8c[SonarQube]!*
*This project is analysed on https://next.sonarqube.com/sonarqube/dashboard?id=sonarsource-cfamily-examples_linux-autoconfig-gh-actions-sq_409eae14-979c-4758-b5fb-8513b12efb8c[SonarQube Server]!*


It is very easy to analyze a C, C++ and Objective-C project with SonarQube using AutoConfig:
Expand All @@ -18,24 +18,24 @@ It is very easy to analyze a C, C++ and Objective-C project with SonarQube using
. Create a `sonar-project.properties` file to store your configuration
. In your `.github/workflows/build.yml` file:
.. Set the environment variable `SONAR_HOST_URL` to your server url (e.g.: https://example.com:9000)
.. Analyze your code using https://github.com/SonarSource/sonarqube-scan-action[the SonarQube Scan Github Action]
. Ensure that your token is stored as a secret in your repository (`SONARQUBE_TOKEN` in this example project). If you don't have a token yet, you can generate a new one in SonarQube (see https://docs.sonarqube.org/latest/user-guide/user-token/[Generating and Using Tokens]).
.. Analyze your code using https://github.com/SonarSource/sonarqube-scan-action[the SonarSource/sonarqube-scan-action action]
. Ensure that your token is stored as a secret in your repository (`SONARQUBE_TOKEN` in this example project). If you don't have a token yet, you can generate a new one in SonarQube Server (see https://docs.sonarsource.com/sonarqube-server/latest/user-guide/managing-tokens/[Managing your tokens]).


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.

= Documentation

- https://docs.sonarqube.org/latest/analysis/languages/cfamily/[Documentation overview of the C, C++ and Objective-C analyzer]
- https://docs.sonarqube.org/latest/analysis/github-integration/[GitHub Integration in SonarQube]
- https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/languages/c-family/customizing-the-analysis/#autoconfig-specific-properties[Tuning CFamily AutoConfig analysis]
- https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/languages/c-family/overview/[C/C++/Objective-C analysis overview]
- https://docs.sonarsource.com/sonarqube-server/latest/devops-platform-integration/github-integration/introduction/[GitHub Integration]
- https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/languages/c-family/customizing-the-analysis/#autoconfig-specific-properties[AutoConfig-specific properties]

= Code Description

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.

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

You can find examples for:

Expand All @@ -62,8 +62,8 @@ Running on the following CI services:

Configured for analysis on:

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

You can find also a few examples demonstrating:

Expand Down
Loading