From d2700939e9b0ce93bdb316dffe7da3dd1b984f44 Mon Sep 17 00:00:00 2001 From: Steven Laver Date: Fri, 25 Oct 2024 13:11:54 -0700 Subject: [PATCH] Split the build-and-test GitHub action into separate jobs --- .github/workflows/android.yml | 163 ++++++++++++++++++----------- .github/workflows/react-native.yml | 4 +- 2 files changed, 103 insertions(+), 64 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 5becb50c..31995d85 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -16,18 +16,64 @@ env: AVD_ANDROID_TARGET: 'google_atd' jobs: - build-and-test: + build: runs-on: ubuntu-latest - timeout-minutes: 30 + timeout-minutes: 15 steps: - ########################################################################## - # Setup - ########################################################################## + - uses: actions/checkout@v4 - - uses: solana-mobile/gha-free-disk-space-for-android-build-and-test@v1 + - name: set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' - - uses: actions/checkout@v4 + - name: Setup Gradle w/ cache + uses: gradle/actions/setup-gradle@v4 + + - name: Build with Gradle + run: ./gradlew build assembleAndroidTest + + # Upload build intermediates to workflow artifacts + - uses: actions/upload-artifact@v4 + with: + name: build-intermediates + path: | + **/.gradle + **/build + include-hidden-files: true # needed for files within dot directories + if-no-files-found: error + retention-days: 1 + + # Upload libraries to workflow artifacts + - uses: actions/upload-artifact@v4 + if: ${{ github.event_name != 'pull_request' }} + with: + name: libraries + path: seedvault/build/outputs/aar/*.aar + if-no-files-found: error + retention-days: 5 + + # Upload javadoc to workflow artifacts + - uses: actions/upload-artifact@v4 + if: ${{ github.event_name != 'pull_request' }} + with: + name: seedvault-javadoc + path: | + seedvault/build/docs/* + !seedvault/build/docs/**/*.zip + if-no-files-found: error + retention-days: 1 + + + test: + runs-on: ubuntu-latest + needs: build + timeout-minutes: 15 + + steps: + - uses: solana-mobile/gha-free-disk-space-for-android-build-and-test@v1 - name: Enable KVM for Android Virtual Device acceleration run: | @@ -35,14 +81,22 @@ jobs: sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + name: build-intermediates + - name: set up JDK 17 uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' - - name: Gradle cache + - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 + with: + cache-disabled: true # no caching - all useful intermediates copied from build job - name: AVD cache uses: actions/cache@v4 @@ -67,41 +121,6 @@ jobs: disable-animations: false script: echo "Generated AVD snapshot for caching." - ########################################################################## - # Build - ########################################################################## - - - name: Build with Gradle - run: ./gradlew build assembleAndroidTest - - ########################################################################## - # Upload build artifacts - ########################################################################## - - # Upload libraries to workflow artifacts - - uses: actions/upload-artifact@v4 - if: ${{ github.event_name != 'pull_request' }} - with: - name: libraries - path: seedvault/build/outputs/aar/*.aar - if-no-files-found: error - retention-days: 5 - - # Upload javadoc to workflow artifacts - - uses: actions/upload-artifact@v4 - if: ${{ github.event_name != 'pull_request' }} - with: - name: seedvault-javadoc - path: | - seedvault/build/docs/* - !seedvault/build/docs/**/*.zip - if-no-files-found: error - retention-days: 1 - - ########################################################################## - # Test - ########################################################################## - - name: run CTS test automation uses: reactivecircus/android-emulator-runner@v2 with: @@ -120,10 +139,8 @@ jobs: ./gradlew :SeedVaultSimulator:installDebug ./gradlew :cts:connectedGenericDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.solanamobile.seedvault.cts.SeedVaultSimulatorSetup ./gradlew :cts:connectedGenericDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.solanamobile.seedvault.cts.RunCtsTestsOnSimulator - - ########################################################################## - # Upload test artifacts - ########################################################################## + ./gradlew :cts:connectedPrivilegedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.solanamobile.seedvault.cts.SeedVaultSimulatorSetup + ./gradlew :cts:connectedPrivilegedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.solanamobile.seedvault.cts.RunCtsTestsOnSimulator # Upload test results to workflow artifacts - uses: actions/upload-artifact@v4 @@ -134,26 +151,14 @@ jobs: if-no-files-found: error retention-days: 5 - ########################################################################## - # Publish to Maven Central - ########################################################################## - - - name: Publish to Maven Central (release only) - if: ${{ github.event_name == 'release' && startsWith(github.event.release.tag_name, 'v') }} # (only for releases that start with 'v') - env: - ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_PRIVATE_KEY }} - ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_PRIVATE_KEY_PASSWORD }} - ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_USERNAME }} - ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_PASSWORD }} - TAG: ${{ github.event.release.tag_name }} - run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -P version=${TAG:1} --no-configuration-cache # Note: only runs on 'push' events for main publish-to-gh-pages: runs-on: ubuntu-latest - needs: build-and-test + needs: test # run only after tests pass concurrency: publish-to-gh-pages if: ${{ github.event_name == 'push' && github.event.push.base_ref == 'main' }} + steps: - name: Update seedvault javadoc uses: solana-mobile/gha-commit-artifact-to-branch@v2 @@ -165,10 +170,44 @@ jobs: commit-message: 'Update seedvault javadoc' + # Note: only runs on 'release' events + publish-to-maven: + runs-on: ubuntu-latest + needs: test # run only after tests pass + if: ${{ github.event_name == 'release' && startsWith(github.event.release.tag_name, 'v') }} # (only for releases that start with 'v') + + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + name: build-intermediates + + - name: set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + with: + cache-disabled: true # no caching - all useful intermediates copied from build job + + - name: Publish to Maven Central (release only) + env: + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_PRIVATE_KEY }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_PRIVATE_KEY_PASSWORD }} + ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_USERNAME }} + ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_PASSWORD }} + TAG: ${{ github.event.release.tag_name }} + run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -P version=${TAG:1} --no-configuration-cache + + # Note: only runs on 'release' events upload-to-release: runs-on: ubuntu-latest - needs: build-and-test + needs: test # run only after tests pass permissions: contents: write # needed for uploading files to releases if: ${{ github.event_name == 'release' }} diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 25cdd3f0..7c591593 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -3,10 +3,10 @@ name: React-Native CI on: push: branches: [ main, next ] - paths: [ 'fakewalletreact/**', 'js/**' ] + paths: [ '.github/**', 'fakewalletreact/**', 'js/**' ] pull_request: branches: [ main, next ] - paths: [ 'fakewalletreact/**', 'js/**' ] + paths: [ '.github/**', 'fakewalletreact/**', 'js/**' ] release: types: [ published ]