From c56143500abb68456571d2fb26ab88fba133da2f Mon Sep 17 00:00:00 2001 From: Reynold Morel Date: Tue, 16 Jul 2024 16:06:29 -0400 Subject: [PATCH 1/2] Adding jacoco test reports to SonarQube analysis --- .github/workflows/build_and_test.yml | 36 +++++++++++++++++++++------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index ca2f6c05861..24f0f435e86 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -11,7 +11,7 @@ on: - "**" jobs: - build-rskj: + build: runs-on: ubuntu-latest container: image: openjdk:8-jdk @@ -94,12 +94,18 @@ jobs: path: | rskj-core/build - - name: Download test reports + - name: Download test results uses: actions/download-artifact@v4 with: - name: test-report + name: test-results path: | rskj-core/build/test-results/ + + - name: Download test reports + uses: actions/download-artifact@v4 + with: + name: test-reports + path: | rskj-core/build/reports/ - name: Run SonarQube analysis @@ -111,6 +117,7 @@ jobs: GH_REF: ${{ github.ref }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | + ls rskj-core/build/ if [ "$GH_EVENT" = pull_request ]; then ./gradlew sonarqube --no-daemon -x build -x test \ -Dsonar.pullrequest.base="$GH_PR_BASE_REF" \ @@ -119,6 +126,8 @@ jobs: -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 ./gradlew sonarqube --no-daemon -x build -x test \ @@ -126,12 +135,14 @@ jobs: -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 mining-tests: - needs: build-rskj + needs: build runs-on: ubuntu-latest services: bitcoind1: @@ -219,7 +230,7 @@ jobs: | cut -d = -f 2- | paste -sd - -) echo "Using RskJ version $version at ../rskj-core/build/libs/rskj-core-$version-all.jar" java -Drsk.conf.file=./rsk-integration-test.conf -cp ../rskj-core/build/libs/rskj-core-"$version"-all.jar co.rsk.Start --regtest & rskpid=$! - + tries=0 MAX_TRIES=10 while [ $tries -lt $MAX_TRIES ]; do @@ -228,16 +239,17 @@ jobs: tries=$((tries+1)) sleep 1 done - + if [ $tries -eq $MAX_TRIES ]; then echo "RskJ unreachable after $MAX_TRIES attempts. Aborting." >&2 exit 1 fi - + npm test kill $rskpid unit-tests: + needs: build runs-on: ubuntu-latest container: image: openjdk:8-jdk @@ -270,12 +282,18 @@ jobs: run: | ./gradlew --no-daemon --stacktrace test - - name: Persist test reports for sonar + - name: Persist test results for sonar uses: actions/upload-artifact@v4 with: - name: test-report + name: test-results path: | rskj-core/build/test-results/ + + - name: Persist test reports for sonar + uses: actions/upload-artifact@v4 + with: + name: test-reports + path: | rskj-core/build/reports/ integration-tests: From 13fb6e925f74c769cf1a6819e78dd87b2f827ade Mon Sep 17 00:00:00 2001 From: rmoreliovlabs <89464501+rmoreliovlabs@users.noreply.github.com> Date: Wed, 17 Jul 2024 08:29:05 -0400 Subject: [PATCH 2/2] Addressing comments Co-authored-by: Vovchyk --- .github/workflows/build_and_test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 24f0f435e86..09148c9a40c 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -117,7 +117,6 @@ jobs: GH_REF: ${{ github.ref }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | - ls rskj-core/build/ if [ "$GH_EVENT" = pull_request ]; then ./gradlew sonarqube --no-daemon -x build -x test \ -Dsonar.pullrequest.base="$GH_PR_BASE_REF" \