SCSCANGHA-13 Warning instead of failure for Maven/Gradle projects

This commit is contained in:
antoine.vinot 2024-05-20 15:47:23 +02:00 committed by Antoine Vinot
commit f1d5a2ae70
2 changed files with 20 additions and 22 deletions

View file

@ -63,9 +63,9 @@ jobs:
run: | run: |
echo "Expected previous step to fail" echo "Expected previous step to fail"
exit 1 exit 1
failFastGradleTest: dontFailGradleTest:
name: > name: >
Fail fast on Gradle project Don't fail on Gradle project
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -79,14 +79,13 @@ jobs:
SONAR_TOKEN: FAKE_TOKEN SONAR_TOKEN: FAKE_TOKEN
with: with:
projectBaseDir: ./test/gradle-project projectBaseDir: ./test/gradle-project
- name: Previous should have failed args: -Dsonar.scanner.dumpToFile=./output.properties
if: ${{ steps.runTest.outcome == 'success'}} - name: Assert
run: | run: |
echo "Expected previous step to fail" ./test/assertFileExists ./output.properties
exit 1 dontFailGradleKotlinTest:
failFastGradleKotlinTest:
name: > name: >
Fail fast on Kotlin Gradle project Don't fail on Kotlin Gradle project
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -100,14 +99,13 @@ jobs:
SONAR_TOKEN: FAKE_TOKEN SONAR_TOKEN: FAKE_TOKEN
with: with:
projectBaseDir: ./test/gradle-project-kotlin projectBaseDir: ./test/gradle-project-kotlin
- name: Previous should have failed args: -Dsonar.scanner.dumpToFile=./output.properties
if: ${{ steps.runTest.outcome == 'success'}} - name: Assert
run: | run: |
echo "Expected previous step to fail" ./test/assertFileExists ./output.properties
exit 1 dontFailMavenTest:
failFastMavenTest:
name: > name: >
Fail fast on Maven project Don't fail on Maven project
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -121,11 +119,10 @@ jobs:
SONAR_TOKEN: FAKE_TOKEN SONAR_TOKEN: FAKE_TOKEN
with: with:
projectBaseDir: ./test/maven-project projectBaseDir: ./test/maven-project
- name: Previous should have failed args: -Dsonar.scanner.dumpToFile=./output.properties
if: ${{ steps.runTest.outcome == 'success'}} - name: Assert
run: | run: |
echo "Expected previous step to fail" ./test/assertFileExists ./output.properties
exit 1
runnerDebugUsedTest: runnerDebugUsedTest:
name: > name: >
'RUNNER_DEBUG' is used 'RUNNER_DEBUG' is used
@ -144,3 +141,4 @@ jobs:
- name: Assert - name: Assert
run: | run: |
./test/assertFileContains ./output.properties "sonar.verbose=true" ./test/assertFileContains ./output.properties "sonar.verbose=true"

View file

@ -8,13 +8,13 @@ if [[ -z "${SONAR_TOKEN}" ]]; then
fi fi
if [[ -f "${INPUT_PROJECTBASEDIR%/}/pom.xml" ]]; then if [[ -f "${INPUT_PROJECTBASEDIR%/}/pom.xml" ]]; then
echo "Maven project detected. You should run the goal 'org.sonarsource.scanner.maven:sonar' during build rather than using this GitHub Action." echo "WARNING! Maven project detected. Sonar recommends running the 'org.sonarsource.scanner.maven:sonar-maven-plugin:sonar' goal during the build process instead of using this GitHub Action
exit 1 to get more accurate results."
fi fi
if [[ -f "${INPUT_PROJECTBASEDIR%/}/build.gradle" || -f "${INPUT_PROJECTBASEDIR%/}/build.gradle.kts" ]]; then if [[ -f "${INPUT_PROJECTBASEDIR%/}/build.gradle" || -f "${INPUT_PROJECTBASEDIR%/}/build.gradle.kts" ]]; then
echo "Gradle project detected. You should use the SonarQube plugin for Gradle during build rather than using this GitHub Action." echo "WARNING! Gradle project detected. Sonar recommends using the SonarQube plugin for Gradle during the build process instead of using this GitHub Action
exit 1 to get more accurate results."
fi fi
if [[ -z "${SONARCLOUD_URL}" ]]; then if [[ -z "${SONARCLOUD_URL}" ]]; then