Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit 48d9e10

Browse files
committed
SCSCANGHA-25 Replace the Docker action by a composite action forwarding to the SonarQube action
1 parent 982992a commit 48d9e10

10 files changed

Lines changed: 76 additions & 188 deletions

File tree

.github/workflows/qa.yml

Lines changed: 33 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ jobs:
1111
argsInputTest:
1212
name: >
1313
'args' input
14-
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
os: [ ubuntu-latest, windows-latest, macos-latest ]
17+
runs-on: ${{ matrix.os }}
1518
steps:
1619
- uses: actions/checkout@v4
1720
with:
@@ -28,7 +31,10 @@ jobs:
2831
projectBaseDirInputTest:
2932
name: >
3033
'projectBaseDir' input
31-
runs-on: ubuntu-latest
34+
strategy:
35+
matrix:
36+
os: [ ubuntu-latest, windows-latest, macos-latest ]
37+
runs-on: ${{ matrix.os }}
3238
steps:
3339
- uses: actions/checkout@v4
3440
with:
@@ -45,118 +51,51 @@ jobs:
4551
- name: Assert
4652
run: |
4753
./test/assertFileContains ./output.properties "sonar.projectBaseDir=.*/baseDir"
48-
sonarTokenRequiredTest:
54+
scannerVersionTest:
4955
name: >
50-
'SONAR_TOKEN' env var required
51-
runs-on: ubuntu-latest
56+
'scannerVersion' input
57+
runs-on: ubuntu-latest # assumes default RUNNER_ARCH for linux is X64
5258
steps:
5359
- uses: actions/checkout@v4
5460
with:
5561
token: ${{ secrets.GITHUB_TOKEN }}
56-
- name: Run action without SONAR_TOKEN
62+
- name: Run action with scannerVersion
5763
uses: ./
5864
with:
65+
scannerVersion: 6.1.0.4477
5966
args: -Dsonar.scanner.internal.dumpToFile=./output.properties
60-
continue-on-error: true
61-
- name: Previous should have failed
62-
if: ${{ steps.runTest.outcome == 'success'}}
63-
run: |
64-
echo "Expected previous step to fail"
65-
exit 1
66-
dontFailGradleTest:
67-
name: >
68-
Don't fail on Gradle project
69-
runs-on: ubuntu-latest
70-
steps:
71-
- uses: actions/checkout@v4
72-
with:
73-
token: ${{ secrets.GITHUB_TOKEN }}
74-
- name: Run action on Gradle project
75-
id: runTest
76-
uses: ./
77-
continue-on-error: true
7867
env:
79-
SONAR_TOKEN: FAKE_TOKEN
80-
with:
81-
projectBaseDir: ./test/gradle-project
82-
args: -Dsonar.scanner.internal.dumpToFile=./output.properties
68+
NO_CACHE: true # force install-sonar-scanner-cli.sh execution
69+
SONAR_HOST_URL: http://not_actually_used
70+
SONAR_SCANNER_JSON_PARAMS: '{"sonar.scanner.internal.dumpToFile": "./output.properties"}'
8371
- name: Assert
8472
run: |
85-
./test/assertFileExists ./output.properties
86-
dontFailGradleKotlinTest:
73+
./test/assertFileExists "$RUNNER_TEMP/sonarscanner/sonar-scanner-cli-6.1.0.4477-linux-x64.zip"
74+
scannerBinariesUrlTest:
8775
name: >
88-
Don't fail on Kotlin Gradle project
89-
runs-on: ubuntu-latest
76+
'scannerBinariesUrl' input with invalid URL
77+
runs-on: ubuntu-latest # assumes default RUNNER_ARCH for linux is X64
9078
steps:
9179
- uses: actions/checkout@v4
9280
with:
9381
token: ${{ secrets.GITHUB_TOKEN }}
94-
- name: Run action on Kotlin Gradle project
82+
- name: Run action with scannerBinariesUrl
9583
id: runTest
9684
uses: ./
9785
continue-on-error: true
98-
env:
99-
SONAR_TOKEN: FAKE_TOKEN
10086
with:
101-
projectBaseDir: ./test/gradle-project-kotlin
102-
args: -Dsonar.scanner.internal.dumpToFile=./output.properties
103-
- name: Assert
104-
run: |
105-
./test/assertFileExists ./output.properties
106-
dontFailMavenTest:
107-
name: >
108-
Don't fail on Maven project
109-
runs-on: ubuntu-latest
110-
steps:
111-
- uses: actions/checkout@v4
112-
with:
113-
token: ${{ secrets.GITHUB_TOKEN }}
114-
- name: Run action on Maven project
115-
id: runTest
116-
uses: ./
117-
continue-on-error: true
87+
scannerVersion: 6.2.1.4610
88+
scannerBinariesUrl: https://invalid_uri/Distribution/sonar-scanner-cli
11889
env:
119-
SONAR_TOKEN: FAKE_TOKEN
120-
with:
121-
projectBaseDir: ./test/maven-project
122-
args: -Dsonar.scanner.internal.dumpToFile=./output.properties
123-
- name: Assert
124-
run: |
125-
./test/assertFileExists ./output.properties
126-
runnerDebugUsedTest:
127-
name: >
128-
'RUNNER_DEBUG' is used
129-
runs-on: ubuntu-latest
130-
steps:
131-
- uses: actions/checkout@v4
132-
with:
133-
token: ${{ secrets.GITHUB_TOKEN }}
134-
- name: Run action with debug mode
135-
uses: ./
136-
with:
137-
args: -Dsonar.scanner.internal.dumpToFile=./output.properties
138-
env:
139-
RUNNER_DEBUG: 1
140-
SONAR_TOKEN: FAKE_TOKEN
141-
- name: Assert
90+
NO_CACHE: true # force install-sonar-scanner-cli.sh execution
91+
SONAR_HOST_URL: http://not_actually_used
92+
SONAR_SCANNER_JSON_PARAMS: '{"sonar.scanner.internal.dumpToFile": "./output.properties"}'
93+
- name: Fail if action succeeded
94+
if: steps.runTest.outcome == 'success'
95+
run: exit 1
96+
- name: Assert Sonar Scanner CLI was not downloaded
14297
run: |
143-
./test/assertFileContains ./output.properties "sonar.verbose=true"
144-
overrideSonarcloudUrlTest:
145-
name: >
146-
'SONARCLOUD_URL' is used
147-
runs-on: ubuntu-latest
148-
steps:
149-
- uses: actions/checkout@v4
150-
with:
151-
token: ${{ secrets.GITHUB_TOKEN }}
152-
- name: Run action with SONARCLOUD_URL
153-
uses: ./
154-
with:
155-
args: -Dsonar.scanner.internal.dumpToFile=./output.properties
156-
env:
157-
SONARCLOUD_URL: mirror.sonarcloud.io
158-
SONAR_TOKEN: FAKE_TOKEN
159-
- name: Assert
98+
./test/assertFileDoesntExist "$RUNNER_TEMP/sonarscanner/sonar-scanner-cli-6.2.1.4610-linux-x64.zip"
99+
- name: Assert Sonar Scanner CLI was not executed
160100
run: |
161-
./test/assertFileContains ./output.properties "sonar.host.url=mirror.sonarcloud.io"
162-
./test/assertFileContains ./output.properties "sonar.scanner.sonarcloudUrl=mirror.sonarcloud.io"
101+
./test/assertFileDoesntExist ./output.properties

Dockerfile

Lines changed: 0 additions & 32 deletions
This file was deleted.

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ In case you need to add additional analysis parameters, you can use the `args` o
8181
More information about possible analysis parameters is found in the documentation at:
8282
https://docs.sonarcloud.io/advanced-setup/analysis-parameters
8383

84+
In case you need to specify the version of the Sonar Scanner, you can use the `scannerVersion` option:
85+
86+
```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
90+
```
91+
8492
See also example configurations at:
8593
https://github.com/sonarsource/sonarcloud-github-action-samples/
8694

@@ -114,14 +122,11 @@ Want to see more examples of SonarCloud in action? You can [explore current Open
114122
* Your code is built with Gradle: use the SonarQube plugin for Gradle during the build
115123
* You want to analyze a .NET solution: Follow our interactive tutorial for GitHub Actions after importing your project directly into SonarCloud
116124
* 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=)
117-
* You want to analyze Dart code: use [SonarScanner CLI](https://docs.sonarsource.com/sonarcloud/advanced-setup/ci-based-analysis/sonarscanner-cli/) during the build
118125

119126
## Have questions or feedback?
120127

121128
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`.
122129

123130
## License
124131

125-
The Dockerfile and associated scripts and documentation in this project are released under the LGPLv3 License.
126-
127132
Container images built with this project include third-party materials.

action.yml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
11
name: SonarCloud Scan
22
description: >
3-
Scan your code with SonarCloud to detect bugs, vulnerabilities and code smells
4-
in 26+ programming languages.
3+
Scan your code with SonarQube Cloud to detect coding issues in 30+
4+
languages, frameworks, and IaC platforms.
5+
The solution also provides fix recommendations leveraging AI with
6+
Sonar's AI CodeFix capability. (Formerly SonarCloud)
57
branding:
68
icon: check
79
color: green
8-
runs:
9-
using: docker
10-
image: Dockerfile
11-
entrypoint: "/entrypoint.sh"
12-
post-entrypoint: "/cleanup.sh"
1310
inputs:
1411
args:
15-
description: Additional arguments to the sonarcloud scanner
12+
description: Additional arguments to the Sonar Scanner CLI
1613
required: false
1714
projectBaseDir:
1815
description: Set the sonar.projectBaseDir analysis property
1916
required: false
20-
default: .
17+
scannerVersion:
18+
description: Version of the Sonar Scanner CLI to use
19+
required: false
20+
default: 6.2.1.4610
21+
scannerBinariesUrl:
22+
description: URL to download the Sonar Scanner CLI binaries from
23+
required: false
24+
default: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli
25+
runs:
26+
using: "composite"
27+
steps:
28+
- name: Deprecation warning
29+
shell: bash
30+
run: |
31+
echo "::warning title=SonarScanner::This action is deprecated and will be removed in a future release. Please use the sonarqube-scan-action action instead. The sonarqube-scan-action is a drop-in replacement for this action."
32+
- name: SonarQube Cloud Scan
33+
uses: SonarSource/sonarqube-scan-action@v4.1.0
34+
with:
35+
args: ${{ inputs.args }}
36+
projectBaseDir: ${{ inputs.projectBaseDir }}
37+
scannerVersion: ${{ inputs.scannerVersion }}
38+
scannerBinariesUrl: ${{ inputs.scannerBinariesUrl }}

cleanup.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

entrypoint.sh

Lines changed: 0 additions & 34 deletions
This file was deleted.

test/assertFileDoesntExist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
error() { echo -e "\\e[31m✗ $*\\e[0m"; }
4+
5+
if [ -f $1 ]; then
6+
error "File '$1' found"
7+
exit 1
8+
fi

test/gradle-project-kotlin/build.gradle.kts

Whitespace-only changes.

test/gradle-project/build.gradle

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/maven-project/pom.xml

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)