From 8648ecf3cb1f5bff264c83b2784c4a41bb268907 Mon Sep 17 00:00:00 2001 From: "antoine.vinot" Date: Mon, 20 May 2024 16:17:53 +0200 Subject: [PATCH] SQSCANGHA-26 Warning instead of failure for Maven/Gradle projects --- .github/workflows/qa.yml | 22 ++++++++++------------ entrypoint.sh | 8 ++++---- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index 70d3a00..2010d9c 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -61,9 +61,9 @@ jobs: run: | echo "Expected previous step to fail" exit 1 - failFastGradleTest: + dontFailGradleTest: name: > - Fail fast on Gradle project + Don't fail on Gradle project runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -77,14 +77,13 @@ jobs: SONAR_HOST_URL: http://not_actually_used with: projectBaseDir: ./test/gradle-project - - name: Previous should have failed - if: ${{ steps.runTest.outcome == 'success'}} + args: -Dsonar.scanner.dumpToFile=./output.properties + - name: Assert run: | - echo "Expected previous step to fail" - exit 1 - failFastMavenTest: + ./test/assertFileExists ./output.properties + dontFailMavenTest: name: > - Fail fast on Maven project + Don't fail on Maven project runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -98,11 +97,10 @@ jobs: SONAR_HOST_URL: http://not_actually_used with: projectBaseDir: ./test/maven-project - - name: Previous should have failed - if: ${{ steps.runTest.outcome == 'success'}} + args: -Dsonar.scanner.dumpToFile=./output.properties + - name: Assert run: | - echo "Expected previous step to fail" - exit 1 + ./test/assertFileExists ./output.properties runAnalysisTest: runs-on: ubuntu-latest services: diff --git a/entrypoint.sh b/entrypoint.sh index d0b4e1e..dd41007 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -21,13 +21,13 @@ if [[ -n "${SONAR_ROOT_CERT}" ]]; then fi 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." - exit 1 + 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 + to get more accurate results." fi if [[ -f "${INPUT_PROJECTBASEDIR%/}/build.gradle" ]]; then - echo "Gradle project detected. You should use the SonarQube plugin for Gradle during build rather than using this GitHub Action." - exit 1 + echo "WARNING! Gradle project detected. Sonar recommends using the SonarQube plugin for Gradle during the build process instead of using this GitHub Action + to get more accurate results." fi unset JAVA_HOME