diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 8eb14e3d01..f7f7ede65e 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -101,14 +101,24 @@ jobs: - name: Run SonarQube analysis env: + GH_EVENT: ${{ github.event_name }} + GH_PR_NUMBER: ${{ github.event.pull_request.number }} + GH_PR_BASE_REF: ${{ github.base_ref }} + GH_PR_HEAD_REF: ${{ github.head_ref }} GH_REF: ${{ github.ref }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | - ./gradlew -Dorg.gradle.jvmargs=-Xmx5g sonar --no-daemon -x build -x test \ - -Dsonar.branch.name="$GH_REF" \ - -Dsonar.junit.reportPaths=rskj-core/build/test-results/ \ - -Dsonar.coverage.jacoco.xmlReportPaths=rskj-core/build/reports/jacoco/test/jacocoTestReport.xml \ - -Dsonar.token="$SONAR_TOKEN" + if [ "$GH_EVENT" = "pull_request" ]; then # If this is a PR, then add pointers to it + ./gradlew -Dorg.gradle.jvmargs=-Xmx5g sonar --no-daemon -x build -x test \ + -Dsonar.pullrequest.base="$GH_PR_BASE_REF" \ + -Dsonar.pullrequest.branch="$GH_PR_HEAD_REF" \ + -Dsonar.pullrequest.key="$GH_PR_NUMBER" \ + -Dsonar.token="$SONAR_TOKEN" + else + ./gradlew -Dorg.gradle.jvmargs=-Xmx5g sonar --no-daemon -x build -x test \ + -Dsonar.branch.name="$GH_REF" \ + -Dsonar.token="$SONAR_TOKEN" + fi mining-tests: needs: build diff --git a/build.gradle b/build.gradle index 7047a1e84c..66ca08e5b9 100644 --- a/build.gradle +++ b/build.gradle @@ -7,6 +7,8 @@ sonar { property "sonar.projectKey", "rskj" property "sonar.organization", "rsksmart" property "sonar.host.url", "https://sonarcloud.io" + property "sonar.junit.reportPaths", "rskj-core/build/test-results/" + property "sonar.coverage.jacoco.xmlReportPaths", "rskj-core/build/reports/jacoco/test/jacocoTestReport.xml" } }