Skip to content

Commit 4afec88

Browse files
committed
SCSCANGHA-28 Rebranding
1 parent 48d9e10 commit 4afec88

File tree

6 files changed

+77
-58
lines changed

6 files changed

+77
-58
lines changed

README.md

Lines changed: 76 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,150 @@
1-
# Analyze your code for free with SonarCloud
1+
# Scan your code with SonarQube Cloud [![QA](https://github.com/SonarSource/sonarcloud-github-action/actions/workflows/qa.yml/badge.svg)](https://github.com/SonarSource/sonarcloud-github-action/actions/workflows/qa.yml)
22

3-
This SonarSource project, available as a GitHub Action, scans your projects with SonarCloud, and helps developers produce
4-
[Clean Code](https://www.sonarsource.com/solutions/clean-code/?utm_medium=referral&utm_source=github&utm_campaign=clean-code&utm_content=sonarqube-scan-action).
3+
> [!WARNING]
4+
> This action is deprecated and will be removed in a future release.
5+
> Please use the `sonarqube-scan-action` action instead.
6+
> The `sonarqube-scan-action` is a drop-in replacement for this action.
57
6-
<img src="./images/SonarCloud-72px.png">
8+
This SonarSource project, available as a GitHub Action, scans your projects with SonarQube [Cloud](https://www.sonarsource.com/products/sonarcloud/).
79

8-
[SonarCloud](https://www.sonarsource.com/products/sonarcloud/) is a widely used static analysis solution for continuous code quality and security inspection.
9-
It helps developers identify and fix issues in their code that could lead to bugs, vulnerabilities, or decreased development velocity.
10-
SonarCloud supports the most popular programming languages, including Java, JavaScript, TypeScript, C#, Python, C, C++, and [many more](https://www.sonarsource.com/knowledge/languages/).
10+
![Logo](./images/SQ_Logo_Cloud_Dark_Backgrounds.png#gh-dark-mode-only)
11+
![Logo](./images/SQ_Logo_Cloud_Light_Backgrounds.png#gh-light-mode-only)
12+
13+
SonarQube [Cloud](https://www.sonarsource.com/products/sonarcloud/) (formerly SonarCloud) is a widely used static analysis solution for continuous code quality and security inspection.
14+
15+
It helps developers detect coding issues in 30+ languages, frameworks, and IaC platforms, including Java, JavaScript, TypeScript, C#, Python, C, C++, and [many more](https://www.sonarsource.com/knowledge/languages/).
16+
17+
The solution also provides fix recommendations leveraging AI with Sonar's AI CodeFix capability.
1118

1219
## Requirements
1320

14-
* Create your account on SonarCloud. Sign up for free now if it's not already the case! [SonarCloud Sign up](https://www.sonarsource.com/products/sonarcloud/signup/?utm_medium=referral&utm_source=github&utm_campaign=sc-signup&utm_content=signup-sonarcloud-listing-x-x&utm_term=ww-psp-x)
15-
* The repository to analyze is set up on SonarCloud. [Set it up](https://sonarcloud.io/projects/create) in just one click.
21+
* Create your account on SonarQube Cloud. [Sign up for free](https://www.sonarsource.com/products/sonarcloud/signup/?utm_medium=referral&utm_source=github&utm_campaign=sc-signup&utm_content=signup-sonarcloud-listing-x-x&utm_term=ww-psp-x) now if it's not already the case!
22+
* The repository to analyze is set up on SonarQube Cloud. [Set it up](https://sonarcloud.io/projects/create) in just one click.
1623

1724
## Usage
1825

1926
Project metadata, including the location of the sources to be analyzed, must be declared in the file `sonar-project.properties` in the base directory:
2027

2128
```properties
22-
sonar.organization=<replace with your SonarCloud organization key>
23-
sonar.projectKey=<replace with the key generated when setting up the project on SonarCloud>
29+
sonar.organization=<replace with your SonarQube Cloud organization key>
30+
sonar.projectKey=<replace with the key generated when setting up the project on SonarQube Cloud>
2431

2532
# relative paths to source directories. More details and properties are described
26-
# in https://sonarcloud.io/documentation/project-administration/narrowing-the-focus/
33+
# at https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/analysis-scope/
2734
sonar.sources=.
2835
```
2936

30-
The workflow, usually declared in `.github/workflows/build.yml`, looks like:
37+
The workflow, usually declared under `.github/workflows`, looks like:
3138

3239
```yaml
3340
on:
34-
# Trigger analysis when pushing in master or pull requests, and when creating
35-
# a pull request.
41+
# Trigger analysis when pushing to your main branches, and when creating a pull request.
3642
push:
3743
branches:
44+
- main
3845
- master
46+
- develop
47+
- 'releases/**'
3948
pull_request:
4049
types: [opened, synchronize, reopened]
50+
4151
name: Main Workflow
4252
jobs:
43-
sonarcloud:
53+
sonarqube:
4454
runs-on: ubuntu-latest
4555
steps:
4656
- uses: actions/checkout@v4
4757
with:
48-
# Disabling shallow clone is recommended for improving relevancy of reporting
58+
# Disabling shallow clones is recommended for improving the relevancy of reporting
4959
fetch-depth: 0
50-
- name: SonarCloud Scan
51-
uses: sonarsource/sonarcloud-github-action@<action version> # Ex: v2.1.0, See the latest version at https://github.com/marketplace/actions/sonarcloud-scan
60+
- name: SonarQube Scan
61+
uses: sonarsource/sonarcloud-github-action@<action version> # Ex: v4.0.0, See the latest version at https://github.com/marketplace/actions/sonarcloud-scan
5262
env:
5363
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
5464
```
5565
66+
## Action parameters
67+
5668
You can change the analysis base directory by using the optional input `projectBaseDir` like this:
5769

5870
```yaml
59-
uses: sonarsource/sonarcloud-github-action@<action version> # Ex: v2.1.0, See the latest version at https://github.com/marketplace/actions/sonarcloud-scan
60-
with:
61-
projectBaseDir: my-custom-directory
71+
- uses: sonarsource/sonarcloud-github-action@<action version>
72+
with:
73+
projectBaseDir: app/src
74+
```
75+
76+
In case you need to specify the version of the Sonar Scanner, you can use the `scannerVersion` option:
77+
78+
```yaml
79+
- uses: sonarsource/sonarcloud-github-action@<action version>
80+
with:
81+
scannerVersion: 6.2.0.4584
6282
```
6383

64-
In case you need to add additional analysis parameters, you can use the `args` option:
84+
In case you need to add additional analysis parameters, and you do not wish to set them in the `sonar-project.properties` file, you can use the `args` option:
6585

6686
```yaml
67-
- name: Analyze with SonarCloud
68-
uses: sonarsource/sonarcloud-github-action@<action version> # Ex: v2.1.0, See the latest version at https://github.com/marketplace/actions/sonarcloud-scan
87+
- uses: sonarsource/sonarcloud-github-action@<action version>
6988
with:
70-
projectBaseDir: my-custom-directory
89+
projectBaseDir: app/src
7190
args: >
7291
-Dsonar.organization=my-organization
7392
-Dsonar.projectKey=my-projectkey
7493
-Dsonar.python.coverage.reportPaths=coverage.xml
7594
-Dsonar.sources=lib/
76-
-Dsonar.test.exclusions=tests/**
7795
-Dsonar.tests=tests/
96+
-Dsonar.test.exclusions=tests/**
7897
-Dsonar.verbose=true
7998
```
8099

81-
More information about possible analysis parameters is found in the documentation at:
82-
https://docs.sonarcloud.io/advanced-setup/analysis-parameters
83-
84-
In case you need to specify the version of the Sonar Scanner, you can use the `scannerVersion` option:
100+
You can also specify the URL where to retrieve the SonarScanner CLI from.
101+
The specified URL overrides the default address: `https://binaries.sonarsource.com/Distribution/sonar-scanner-cli`.
102+
This can be useful when the runner executing the action is self-hosted and has regulated or no access to the Internet:
85103

86104
```yaml
87-
uses: sonarsource/sonarcloud-github-action@<action version> # Ex: v2.1.0, See the latest version at https://github.com/marketplace/actions/sonarcloud-scan
88-
with:
89-
scannerVersion: 6.2.0.4584
105+
- uses: sonarsource/sonarcloud-github-action@<action version>
106+
with:
107+
scannerBinariesUrl: https://my.custom.binaries.url.com/Distribution/sonar-scanner-cli/
90108
```
91109

92-
See also example configurations at:
93-
https://github.com/sonarsource/sonarcloud-github-action-samples/
110+
More information about possible analysis parameters can be found in the [Analysis parameters page](https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/analysis-parameters/) of the SonarQube Cloud documentation.
94111

95-
### Secrets
112+
### Environment variables
96113

97-
- `SONAR_TOKEN` – **Required** this is the token used to authenticate access to SonarCloud. You can generate a token on your [Security page in SonarCloud](https://sonarcloud.io/account/security/). You can set the `SONAR_TOKEN` environment variable in the "Secrets" settings page of your repository.
114+
- `SONAR_TOKEN` – **Required** this is the token used to authenticate access to SonarQube. You can read more about security tokens in the [documentation](https://docs.sonarsource.com/sonarqube-cloud/managing-your-account/managing-tokens/). You can set the `SONAR_TOKEN` environment variable in the "Secrets" settings page of your repository, or you can add them at the level of your GitHub organization (recommended).
98115
- *`GITHUB_TOKEN` – Provided by Github (see [Authenticating with the GITHUB_TOKEN](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/authenticating-with-the-github_token)).*
116+
- `SONAR_ROOT_CERT` – Holds an additional certificate (in PEM format) that is used to validate the certificate of a secured proxy to SonarQube Cloud. You can set the `SONAR_ROOT_CERT` environment variable in the "Secrets" settings page of your repository, or you can add them at the level of your GitHub organization (recommended).
99117

100-
## Error cleaning up workspace
118+
Here is an example of how you can pass a certificate (in PEM format) to the Scanner truststore:
101119

102-
In some cases, the checkout action may fail to clean up the workspace. This is a known problem for GitHub actions implemented as a docker container (such as `sonarcloud-github-actions`) when self-hosted runners are used.
103-
Example of the error message: `File was unable to be removed Error: EACCES: permission denied, unlink '/actions-runner/_work//project/.scannerwork/.sonar_lock'`
104-
To work around the problem, `sonarcloud-github-action` attempts to fix the permission of the temporary files that it creates. If that doesn't work, you can manually clean up the workspace by running the following action:
105-
```
106-
- name: Clean the workspace
107-
uses: docker://alpine
108-
with:
109-
args: /bin/sh -c "find \"${GITHUB_WORKSPACE}\" -mindepth 1 ! -name . -prune -exec rm -rf {} +"
120+
```yaml
121+
- uses: sonarsource/sonarcloud-github-action@<action version>
122+
env:
123+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
124+
SONAR_ROOT_CERT: ${{ secrets.SONAR_ROOT_CERT }}
110125
```
111-
You can find more info [here](https://github.com/actions/runner/issues/434).
112126

113-
## Example of pull request analysis
127+
If your source code file names contain special characters that are not covered by the locale range of `en_US.UTF-8`, you can configure your desired locale like this:
114128

115-
<img src="./images/SonarCloud-analysis-in-Checks.png">
129+
```yaml
130+
- uses: sonarsource/sonarcloud-github-action@<action version>
131+
env:
132+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
133+
LC_ALL: "ru_RU.UTF-8"
134+
```
116135

117-
Want to see more examples of SonarCloud in action? You can [explore current Open Source projects in SonarCloud](https://sonarcloud.io/explore/projects?sort=-analysis_date?utm_medium=referral&utm_source=github&utm_campaign=sc-signup&utm_content=signup-sonarcloud-listing-x-x&utm_term=ww-psp-x) that are using the Clean as You Code methodology.
136+
## Alternatives for Java, .NET, and C/C++ projects
118137

119-
## Do not use this GitHub action if you are in the following situations
138+
This GitHub Action will not work for all technologies. If you are in one of the following situations, you should use the following alternatives:
120139

121-
* Your code is built with Maven: run 'org.sonarsource.scanner.maven:sonar' during the build
122-
* Your code is built with Gradle: use the SonarQube plugin for Gradle during the build
123-
* You want to analyze a .NET solution: Follow our interactive tutorial for GitHub Actions after importing your project directly into SonarCloud
124-
* You want to analyze C and C++ code: rely on our [SonarCloud Scan for C and C++](https://github.com/marketplace/actions/sonarcloud-scan-for-c-and-c) and look at [our sample C and C++ project](https://github.com/sonarsource-cfamily-examples?q=gh-actions-sc&type=all&language=&sort=)
140+
* Your code is built with Maven. Read the documentation about our [SonarScanner for Maven](https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/ci-based-analysis/sonarscanner-for-maven/).
141+
* Your code is built with Gradle. Read the documentation about our [SonarScanner for Gradle](https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/ci-based-analysis/sonarscanner-for-gradle/).
142+
* You want to analyze a .NET solution. Read the documentation about our [SonarScanner for .NET](https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/ci-based-analysis/sonarscanner-for-dotnet/introduction/).
143+
* You want to analyze C or C++ code. Starting from SonarQube 10.6, this GitHub Action will scan C and C++ out of the box. If you want to have better control over the scan configuration/setup, you can switch to the [SonarQube Cloud Scan for C and C++](https://github.com/marketplace/actions/sonarcloud-scan-for-c-and-c) GitHub Action - look at [our sample C and C++ project](https://github.com/sonarsource-cfamily-examples?q=gh-actions-sc&type=all&language=&sort=).
125144

126145
## Have questions or feedback?
127146

128-
To provide feedback (requesting a feature or reporting a bug) please post on the [SonarSource Community Forum](https://community.sonarsource.com/) with the tag `sonarcloud`.
147+
To provide feedback (requesting a feature or reporting a bug) please post on the [SonarSource Community Forum](https://community.sonarsource.com/tags/c/help/sc/9/github-actions).
129148

130149
## License
131150

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: SonarCloud Scan
1+
name: SonarQube Cloud Scan
22
description: >
33
Scan your code with SonarQube Cloud to detect coding issues in 30+
44
languages, frameworks, and IaC platforms.
21.4 KB
Loading
22.5 KB
Loading

images/SonarCloud-72px.png

-3.65 KB
Binary file not shown.
-94.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)