From 859d8dca6975f404b515d94b18dbb2d5c2bbaf36 Mon Sep 17 00:00:00 2001 From: Nazaret Garcia Date: Mon, 28 Oct 2024 15:04:34 -0300 Subject: [PATCH 1/3] Add sonarcloud support Updating binaries path --- .github/workflows/build_and_test.yml | 37 ++++++---------------------- sonar-project.properties | 10 ++++++++ 2 files changed, 17 insertions(+), 30 deletions(-) create mode 100644 sonar-project.properties diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index a40d4e4690..253c349def 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -99,7 +99,8 @@ jobs: path: | rskj-core/build/reports/ - - name: Run SonarQube analysis + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@v3.1.0 # Ex: v3.1.0, See the latest version at https://github.com/marketplace/actions/sonarcloud-scan env: GH_EVENT: ${{ github.event_name }} GH_PR_NUMBER: ${{ github.event.pull_request.number }} @@ -107,34 +108,10 @@ 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" ]; 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" \ - -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" - fi - + with: + args: > + -Dsonar.branch.name="$GH_REF" + -Dsonar.verbose=true mining-tests: needs: build @@ -322,4 +299,4 @@ jobs: - name: Run tests run: | - ./gradlew --no-daemon --stacktrace integrationTest + ./gradlew --no-daemon --stacktrace integrationTest \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000000..7f3d451b14 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,10 @@ +sonar.organization=rsksmart +sonar.projectKey=rskj +sonar.host.url=https://sonarcloud.io +sonar.junit.reportPaths=./rskj-core/build/test-results/ +sonar.coverage.jacoco.xmlReportPaths=./rskj-core/build/reports/jacoco/test/jacocoTestReport.xml + +# relative paths to source directories. More details and properties are described +# in https://sonarcloud.io/documentation/project-administration/narrowing-the-focus/ +sonar.sources=. +sonar.java.binaries=**/*.class \ No newline at end of file From 92af22f8e8d77f5b21d2e0f4755f5af466b9ba1b Mon Sep 17 00:00:00 2001 From: Nazaret Garcia Date: Tue, 29 Oct 2024 13:27:18 -0300 Subject: [PATCH 2/3] Updating binaries location --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 7f3d451b14..582a70b462 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -7,4 +7,4 @@ sonar.coverage.jacoco.xmlReportPaths=./rskj-core/build/reports/jacoco/test/jacoc # relative paths to source directories. More details and properties are described # in https://sonarcloud.io/documentation/project-administration/narrowing-the-focus/ sonar.sources=. -sonar.java.binaries=**/*.class \ No newline at end of file +sonar.java.binaries=./rskj-core/build/**/*.class \ No newline at end of file From 6a43f08cb15f13ff06a6a5c04062055bb0339f46 Mon Sep 17 00:00:00 2001 From: Nazaret Garcia Date: Tue, 29 Oct 2024 13:55:20 -0300 Subject: [PATCH 3/3] fix --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 582a70b462..2059a4d864 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -7,4 +7,4 @@ sonar.coverage.jacoco.xmlReportPaths=./rskj-core/build/reports/jacoco/test/jacoc # relative paths to source directories. More details and properties are described # in https://sonarcloud.io/documentation/project-administration/narrowing-the-focus/ sonar.sources=. -sonar.java.binaries=./rskj-core/build/**/*.class \ No newline at end of file +sonar.java.binaries=./rskj-core/build/classes \ No newline at end of file