Skip to content

Commit 661b924

Browse files
SCCPPGHA-15 Use unified sonarqube-scan-action (#14)
1 parent 50d6598 commit 661b924

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

.github/workflows/build.yml

+8-9
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ 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 and build-wrapper
19-
uses: sonarsource/sonarcloud-github-c-cpp@v3
20-
- name: Run build-wrapper
18+
- name: Install Build Wrapper
19+
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v4
20+
- name: Run Build Wrapper
2121
run: |
2222
build-wrapper-macosx-x86 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} xcodebuild -project macos-xcode.xcodeproj -scheme macos-xcode
2323
- name: Run tests to generate coverage statistics
@@ -27,12 +27,11 @@ jobs:
2727
- name: Collect coverage into one XML report
2828
run: |
2929
bash xccov-to-generic.sh build/Logs/Test/*.xcresult/ > generic-coverage.xml
30-
- name: Run sonar-scanner
30+
- name: SonarQube Scan
31+
uses: SonarSource/sonarqube-scan-action@v4
3132
env:
32-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3333
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }} # Put the name of your token here
34-
run: |
35-
sonar-scanner \
36-
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json" \
34+
with:
35+
args: >
36+
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"
3737
--define sonar.coverageReportPaths=generic-coverage.xml
38-

README.adoc

+12-13
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_macos-xcode-coverage-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_macos-xcode-coverage-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:xcode[here]. +
@@ -18,29 +18,28 @@ Adding code coverage is done the same way regardless of whether you use the Buil
1818
After your build and before running `sonar-scanner`, proceed with the following steps:
1919

2020
. Run the test binaries with `-enableCodeCoverage YES` to count covered lines
21-
. Run link:xccov-to-generic.sh[xccov-to-generic.sh] on the `*.xcresult` files to produce a https://docs.sonarcloud.io/enriching/test-coverage/generic-test-data/[Generic Test Data] format that is compatible with SonarCloud and SonarQube
21+
. Run link:xccov-to-generic.sh[xccov-to-generic.sh] on the `*.xcresult` files to produce a https://docs.sonarcloud.io/enriching/test-coverage/generic-test-data/[Generic Test Data] format that is compatible with SonarQube Server and Cloud
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

2929
- https://github.com/SonarSource/sonar-scanning-examples/blob/master/swift-coverage/swift-coverage-example/xccov-to-sonarqube-generic.sh[Script to create a Generic Test Data format from *.xcresult]
30-
- https://docs.sonarcloud.io/advanced-setup/languages/c-c-objective-c/[Documentation overview of the C, C++ and Objective-C analyzer]
31-
- https://docs.sonarcloud.io/getting-started/github/[Documentation of using SonarCloud with GitHub]
32-
- https://docs.sonarcloud.io/advanced-setup/languages/c-family/prerequisites/#generating-a-compilation-database[Generating a compilation database (compile_commands.json)]
33-
- https://docs.sonarsource.com/sonarcloud/advanced-setup/languages/c-family/running-the-analysis/[Running the analysis in Compilation Database mode]
34-
- https://docs.sonarcloud.io/enriching/test-coverage/test-coverage-parameters/[Test coverage parameters]
35-
- https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/github-actions-for-sonarcloud/[GitHub Action for C and C++ usage]
36-
30+
- https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/languages/c-family/overview/[C/C++/Objective-C analysis overview]
31+
- https://docs.sonarsource.com/sonarqube-cloud/getting-started/github/[Getting started with GitHub]
32+
- https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/languages/c-family/prerequisites/#generating-a-compilation-database[Generating a compilation database]
33+
- https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/languages/c-family/running-the-analysis/[Running the CFamily analysis]
34+
- https://docs.sonarsource.com/sonarqube-cloud/enriching/test-coverage/test-coverage-parameters/[Test coverage parameters]
35+
- https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/ci-based-analysis/github-actions-for-sonarcloud/[Analyze your repository with GitHub Actions]
3736

3837
= Code Description
3938

4039
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.
4140

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

4544
You can find examples for:
4645

@@ -67,8 +66,8 @@ Running on the following CI services:
6766

6867
Configured for analysis on:
6968

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

7372
You can find also a few examples demonstrating:
7473

0 commit comments

Comments
 (0)