Skip to content

Commit 2500896

Browse files
SQSCANGHA-92 Validate scanner version (#189)
Co-authored-by: Julien HENRY <[email protected]>
1 parent 73bc64c commit 2500896

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

.github/workflows/qa-main.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,3 +809,26 @@ jobs:
809809
[ -f "$SONAR_SSL_FOLDER/truststore.p12" ] || exit 1
810810
TRUSTSTORE_P12_MOD_TIME_T3=$(stat -c %Y "$SONAR_SSL_FOLDER/truststore.p12")
811811
[ "$TRUSTSTORE_P12_MOD_TIME_T2" != "$TRUSTSTORE_P12_MOD_TIME_T3" ] || exit 1
812+
scannerVersionValidationTest:
813+
name: >
814+
'scannerVersion' input validation
815+
runs-on: ubuntu-latest
816+
steps:
817+
- uses: actions/checkout@v4
818+
with:
819+
token: ${{ secrets.GITHUB_TOKEN }}
820+
- name: Run action with invalid scannerVersion
821+
id: invalid_version
822+
uses: ./
823+
continue-on-error: true
824+
with:
825+
scannerVersion: "7.1.0-SNAPSHOT"
826+
args: -Dsonar.scanner.internal.dumpToFile=./output.properties
827+
env:
828+
NO_CACHE: true
829+
SONAR_HOST_URL: http://not_actually_used
830+
- name: Assert failure of previous step
831+
if: steps.invalid_version.outcome == 'success'
832+
run: |
833+
echo "Action with invalid scannerVersion should have failed but succeeded"
834+
exit 1

action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ runs:
3030
shell: bash
3131
env:
3232
INPUT_PROJECTBASEDIR: ${{ inputs.projectBaseDir }}
33+
INPUT_SCANNERVERSION: ${{ inputs.scannerVersion }}
3334
- name: Load Sonar Scanner CLI from cache
3435
id: sonar-scanner-cli
3536
uses: actions/cache@v4

scripts/sanity-checks.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
set -eo pipefail
44

5+
if [[ ! "${INPUT_SCANNERVERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
6+
echo "::error title=SonarScanner::Invalid scannerVersion format. Expected format: x.y.z.w (e.g., 7.1.0.4889)"
7+
exit 1
8+
fi
9+
510
if [[ -z "${SONAR_TOKEN}" ]]; then
611
echo "::warning title=SonarScanner::Running this GitHub Action without SONAR_TOKEN is not recommended"
712
fi

0 commit comments

Comments
 (0)