From bcd0e6c7dd76b55015c6bad95d236fdf642ed11a Mon Sep 17 00:00:00 2001 From: Juraj Piar Date: Thu, 27 Jun 2024 11:11:33 +0100 Subject: [PATCH] fix(ci): persist test reports for sonar --- .github/workflows/build_and_test.yml | 43 ++++++++++++++++++++-------- build.gradle | 9 ------ 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 27feda34231..9cdd671e64a 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -56,10 +56,12 @@ jobs: rskj-core/build smell-test: - needs: build-rskj + needs: unit-tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Java JDK uses: actions/setup-java@v3 @@ -92,28 +94,37 @@ jobs: path: | rskj-core/build - - name: Sonarqube for PRs + - name: Download test reports + uses: actions/download-artifact@v4 + with: + name: test-report + path: | + rskj-core/build/test-results/ + rskj-core/build/reports/ + + - name: Prepare PR flags for SonarQube analysis if: github.event_name == 'pull_request' run: | - pr_number=${{ github.event.pull_request.number }} + pr_number="${{ github.event.pull_request.number }}" extra_flags="-Dsonar.pullrequest.base=${{ github.base_ref }} \ -Dsonar.pullrequest.branch=${{ github.head_ref }} \ -Dsonar.pullrequest.key=$pr_number" + echo EXTRA_FLAGS="$extra_flags" >> $GITHUB_ENV + + - name: Prepare push flags for SonarQube analysis + if: github.event_name != 'pull_request' + run: | + echo EXTRA_FLAGS="-Dsonar.branch.name=${{ github.ref }}" >> $GITHUB_ENV + + - name: Run SonarQube analysis + run: | + extra_flags="${{ env.EXTRA_FLAGS }}" ./gradlew sonarqube --no-daemon -x build -x test \ $extra_flags \ -Dsonar.organization=rsksmart \ -Dsonar.host.url="https://sonarcloud.io" \ -Dsonar.token="${{ secrets.SONAR_TOKEN }}" - - name: Sonarqube for master - if: github.event_name != 'pull_request' - run: | - ./gradlew sonarqube --no-daemon -x build -x test \ - -Dsonar.branch.name="${{ github.ref }}" \ - -Dsonar.organization=rsksmart \ - -Dsonar.host.url="https://sonarcloud.io" \ - -Dsonar.token="${{ secrets.SONAR_TOKEN }}" - mining-tests: needs: build-rskj runs-on: ubuntu-latest @@ -254,6 +265,14 @@ jobs: run: | ./gradlew --no-daemon --stacktrace test + - name: Persist test reports for sonar + uses: actions/upload-artifact@v4 + with: + name: test-report + path: | + rskj-core/build/test-results/ + rskj-core/build/reports/ + integration-tests: runs-on: ubuntu-latest container: diff --git a/build.gradle b/build.gradle index b6d9f595e47..87a3e53a0f3 100644 --- a/build.gradle +++ b/build.gradle @@ -8,12 +8,3 @@ subprojects { version = config.modifier?.trim() ? config.versionNumber + "-" + config.modifier : config.versionNumber } -sonarqube { - properties { - property "sonar.java.binaries", "rskj-core/build/classes/java/main" - property "sonar.scm.provider", "git" - property "sonar.projectBaseDir", project.projectDir - property "sonar.projectKey", "rskj" - property "sonar.organization", "rsksmart" - } -}