mirror of
https://github.com/SonarSource/sonarqube-scan-action.git
synced 2025-12-13 18:01:15 +00:00
SQSCANGHA-92 Validate scanner version (#189)
Co-authored-by: Julien HENRY <julien.henry@sonarsource.com>
This commit is contained in:
parent
73bc64cb64
commit
2500896589
3 changed files with 29 additions and 0 deletions
23
.github/workflows/qa-main.yml
vendored
23
.github/workflows/qa-main.yml
vendored
|
|
@ -809,3 +809,26 @@ jobs:
|
||||||
[ -f "$SONAR_SSL_FOLDER/truststore.p12" ] || exit 1
|
[ -f "$SONAR_SSL_FOLDER/truststore.p12" ] || exit 1
|
||||||
TRUSTSTORE_P12_MOD_TIME_T3=$(stat -c %Y "$SONAR_SSL_FOLDER/truststore.p12")
|
TRUSTSTORE_P12_MOD_TIME_T3=$(stat -c %Y "$SONAR_SSL_FOLDER/truststore.p12")
|
||||||
[ "$TRUSTSTORE_P12_MOD_TIME_T2" != "$TRUSTSTORE_P12_MOD_TIME_T3" ] || exit 1
|
[ "$TRUSTSTORE_P12_MOD_TIME_T2" != "$TRUSTSTORE_P12_MOD_TIME_T3" ] || exit 1
|
||||||
|
scannerVersionValidationTest:
|
||||||
|
name: >
|
||||||
|
'scannerVersion' input validation
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Run action with invalid scannerVersion
|
||||||
|
id: invalid_version
|
||||||
|
uses: ./
|
||||||
|
continue-on-error: true
|
||||||
|
with:
|
||||||
|
scannerVersion: "7.1.0-SNAPSHOT"
|
||||||
|
args: -Dsonar.scanner.internal.dumpToFile=./output.properties
|
||||||
|
env:
|
||||||
|
NO_CACHE: true
|
||||||
|
SONAR_HOST_URL: http://not_actually_used
|
||||||
|
- name: Assert failure of previous step
|
||||||
|
if: steps.invalid_version.outcome == 'success'
|
||||||
|
run: |
|
||||||
|
echo "Action with invalid scannerVersion should have failed but succeeded"
|
||||||
|
exit 1
|
||||||
|
|
@ -30,6 +30,7 @@ runs:
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
INPUT_PROJECTBASEDIR: ${{ inputs.projectBaseDir }}
|
INPUT_PROJECTBASEDIR: ${{ inputs.projectBaseDir }}
|
||||||
|
INPUT_SCANNERVERSION: ${{ inputs.scannerVersion }}
|
||||||
- name: Load Sonar Scanner CLI from cache
|
- name: Load Sonar Scanner CLI from cache
|
||||||
id: sonar-scanner-cli
|
id: sonar-scanner-cli
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
|
if [[ ! "${INPUT_SCANNERVERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
echo "::error title=SonarScanner::Invalid scannerVersion format. Expected format: x.y.z.w (e.g., 7.1.0.4889)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -z "${SONAR_TOKEN}" ]]; then
|
if [[ -z "${SONAR_TOKEN}" ]]; then
|
||||||
echo "::warning title=SonarScanner::Running this GitHub Action without SONAR_TOKEN is not recommended"
|
echo "::warning title=SonarScanner::Running this GitHub Action without SONAR_TOKEN is not recommended"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue