From ef12c1d1b344129649fbe1736a9d8107c58aa3b7 Mon Sep 17 00:00:00 2001 From: xxfast Date: Tue, 23 Jan 2024 09:01:44 +1100 Subject: [PATCH] Combine build and test actions --- .github/workflows/build.yml | 63 ++++++++++++++++++++++++++++++------- .github/workflows/test.yml | 62 ------------------------------------ 2 files changed, 52 insertions(+), 73 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 826db89..3036f2a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,18 +39,39 @@ jobs: build: strategy: - fail-fast: true matrix: config: [ - { target: jvm, os: ubuntu-latest }, - { target: apple, os: macos-latest }, + { target: android, os: ubuntu-latest, tasks: testDebugUnitTest testReleaseUnitTest }, + { target: ios, os: macos-latest, tasks: iosX64Test iosSimulatorArm64Test }, + { target: js, os: ubuntu-latest, tasks: jsTest }, + { target: desktop, os: ubuntu-latest, tasks: desktopTest }, ] runs-on: ${{ matrix.config.os }} - timeout-minutes: 60 - needs: - - check - name: Build ${{ matrix.config.target }} + needs: check + steps: + - uses: actions/checkout@v3 + - name: Setup JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup gradle + uses: gradle/gradle-build-action@v2 + + - name: Test ${{ matrix.config.target }} targets + run: ./gradlew ${{ matrix.config.tasks }} + + test: + name: Test on Android + runs-on: ubuntu-latest + timeout-minutes: 60 + needs: check + strategy: + fail-fast: true + matrix: + api-level: [ 25, 33, 34 ] steps: - uses: actions/checkout@v3 @@ -71,8 +92,26 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew build + # API 30+ emulators only have x86_64 system images. + - name: Get AVD info + uses: ./.github/actions/get-avd-info + id: avd-info + with: + api-level: ${{ matrix.api-level }} + + - name: Enable KVM + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + + - name: Instrumentation tests + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + arch: ${{ steps.avd-info.outputs.arch }} + target: ${{ steps.avd-info.outputs.target }} + script: ./gradlew connectedDebugAndroidTest release: name: Release to sonatype @@ -80,6 +119,7 @@ jobs: runs-on: macos-latest needs: - build + - test environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} @@ -118,6 +158,7 @@ jobs: runs-on: ubuntu-latest needs: - build + - test environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} @@ -143,7 +184,7 @@ jobs: uses: JetBrains/writerside-github-action@v4 with: instance: docs/decompose-router - artifact: webHelpKSTORE2-all.zip + artifact: webHelpDECOMPOSE-ROUTER2-all.zip docker-version: 232.10275 - name: Upload documentation @@ -151,7 +192,7 @@ jobs: with: name: docs path: | - artifacts/webHelpKSTORE2-all.zip + artifacts/webHelpDECOMPOSE-ROUTER2-all.zip artifacts/report.json retention-days: 7 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 7655d50..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Test - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -# This allows a subsequently queued workflow run to interrupt previous runs -concurrency: - group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' - cancel-in-progress: true - -jobs: - test: - name: Test on Android - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: true - matrix: - api-level: [25, 33, 34] - - steps: - - uses: actions/checkout@v3 - - - name: Setup JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - cache: gradle - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - - - name: Setup Android SDK - uses: android-actions/setup-android@v2 - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - # API 30+ emulators only have x86_64 system images. - - name: Get AVD info - uses: ./.github/actions/get-avd-info - id: avd-info - with: - api-level: ${{ matrix.api-level }} - - - name: Enable KVM - run: | - echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules - sudo udevadm control --reload-rules - sudo udevadm trigger --name-match=kvm - - - name: Instrumentation tests - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: ${{ matrix.api-level }} - arch: ${{ steps.avd-info.outputs.arch }} - target: ${{ steps.avd-info.outputs.target }} - script: ./gradlew connectedDebugAndroidTest