From 0cca8c014b33f9024b6581eec286097882944a13 Mon Sep 17 00:00:00 2001 From: Nazaret Garcia Date: Sun, 10 Nov 2024 11:05:15 -0300 Subject: [PATCH] Adding pointers to PR --- .github/workflows/build_and_test.yml | 20 +++++++++++++++----- build.gradle | 2 ++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index cd0196e719..840ccd7776 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" } }