From 7dba79a7b1d8f55cc42ae5d0c17110d1ccbc17cd Mon Sep 17 00:00:00 2001 From: Volodymyr Kravets Date: Wed, 25 Sep 2024 14:17:49 +0300 Subject: [PATCH] chore: optimise workflow; run unit tests for java21 in workflow --- .github/workflows/build_and_test.yml | 103 ++++++++++++++++++++------- 1 file changed, 78 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 451f25d61..f37ef5fd2 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -99,11 +99,12 @@ jobs: with: fetch-depth: 0 - - name: Setup Java JDK - uses: actions/setup-java@v3 + - name: Setup Java & Gradle + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' + cache: 'gradle' - name: Download rskj uses: actions/download-artifact@v4 @@ -112,19 +113,19 @@ jobs: path: rskj - uses: actions/cache@v4 - name: Cache Gradle - id: cache-gradle + name: Cache Gradle Wrapper + id: cache-gradle-wrapper with: path: | - .gradle/caches - gradle/wrapper - DONT-COMMIT-settings.gradle - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Get gradle wrapper and build dependencies - if: steps.cache-gradle.outputs.cache-hit != 'true' + gradle/wrapper/gradle-wrapper.jar + key: gradle-wrapper-v1 + + - name: Get Gradle wrapper + if: steps.cache-gradle-wrapper.outputs.cache-hit != 'true' + run: | + ./configure.sh + + - name: Set DONT-COMMIT-settings.gradle run: | cat <<'EOF' >DONT-COMMIT-settings.gradle includeBuild('./rskj') { @@ -144,9 +145,6 @@ jobs: } } EOF - if [ -d ".gradle" ]; then rm -rfv .gradle; fi - ./configure.sh - ./gradlew --no-daemon --settings-file DONT-COMMIT-settings.gradle dependencies - name: Build node run: | @@ -161,18 +159,19 @@ jobs: !rskj retention-days: 7 - federator-tests: + federator-tests-java17: runs-on: ubuntu-latest needs: build_federator_node steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup Java JDK - uses: actions/setup-java@v3 + - name: Setup Java & Gradle + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' + cache: 'gradle' - name: Download Build files uses: actions/download-artifact@v4 @@ -186,6 +185,14 @@ jobs: name: rskj path: rskj + - uses: actions/cache/restore@v4 + name: Restore Gradle Wrapper + with: + path: | + gradle/wrapper/gradle-wrapper.jar + key: gradle-wrapper-v1 + fail-on-cache-miss: true + - name: Perform federator tests run: | ./gradlew --no-daemon --stacktrace test @@ -206,16 +213,48 @@ jobs: build/reports/ retention-days: 7 - sonarqube: + federator-tests-java21: runs-on: ubuntu-latest - needs: federator-tests + needs: build_federator_node steps: - - name: Setup Java JDK - uses: actions/setup-java@v3 + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Java & Gradle + uses: actions/setup-java@v4 with: - java-version: '17' + java-version: '21' distribution: 'temurin' + cache: 'gradle' + + - name: Download Build files + uses: actions/download-artifact@v4 + with: + name: build_files + path: ./ + + - name: Download rskj + uses: actions/download-artifact@v4 + with: + name: rskj + path: rskj + + - uses: actions/cache/restore@v4 + name: Restore Gradle Wrapper + with: + path: | + gradle/wrapper/gradle-wrapper.jar + key: gradle-wrapper-v1 + fail-on-cache-miss: true + + - name: Perform federator tests + run: | + ./gradlew --no-daemon --stacktrace test + sonarqube: + runs-on: ubuntu-latest + needs: federator-tests-java17 + steps: - name: Download Build files uses: actions/download-artifact@v4 with: @@ -241,6 +280,21 @@ jobs: path: | build/reports/ + - name: Setup Java & Gradle + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: 'gradle' + + - uses: actions/cache/restore@v4 + name: Restore Gradle Wrapper + with: + path: | + gradle/wrapper/gradle-wrapper.jar + key: gradle-wrapper-v1 + fail-on-cache-miss: true + - name: Run SonarQube analysis env: GH_EVENT: ${{ github.event_name }} @@ -272,4 +326,3 @@ jobs: -Dsonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml \ -Dsonar.token="$SONAR_TOKEN" fi -