Skip to content

Commit

Permalink
Merge pull request #2805 from rsksmart/bugfix/skip_sonarqube_forks
Browse files Browse the repository at this point in the history
Bugfix: Skipping SonarQube analysis on prs from forked repos
  • Loading branch information
Vovchyk authored Oct 17, 2024
2 parents d64a6bc + 347cf2b commit 918a94e
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,23 @@ jobs:
GH_PR_HEAD_REF: ${{ github.head_ref }}
GH_REF: ${{ github.ref }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
IS_FORK: ${{ github.event.pull_request.head.repo.fork }}
run: |
if [ "$GH_EVENT" = pull_request ] && [ "${{ github.event.pull_request.head.repo.fork }}" != "true" ]; then
./gradlew -Dorg.gradle.jvmargs=-Xmx5g sonarqube --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.organization=rsksmart \
-Dsonar.projectKey=rskj \
-Dsonar.host.url="https://sonarcloud.io" \
-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 [ "$IS_FORK" != "true" ]; then
./gradlew -Dorg.gradle.jvmargs=-Xmx5g sonarqube --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.organization=rsksmart \
-Dsonar.projectKey=rskj \
-Dsonar.host.url="https://sonarcloud.io" \
-Dsonar.junit.reportPaths=rskj-core/build/test-results/ \
-Dsonar.coverage.jacoco.xmlReportPaths=rskj-core/build/reports/jacoco/test/jacocoTestReport.xml \
-Dsonar.token="$SONAR_TOKEN"
else
echo "Skipping SonarQube analysis for pull request from a forked repo."
fi
else
./gradlew -Dorg.gradle.jvmargs=-Xmx5g sonarqube --no-daemon -x build -x test \
-Dsonar.branch.name="$GH_REF" \
Expand Down

0 comments on commit 918a94e

Please sign in to comment.