From f0966586d93c6a45f787c67b802b4a5d1239535e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BBerko?= Date: Mon, 20 May 2024 08:32:59 +0200 Subject: [PATCH] ci: github acceptance improvements [WPB-8666] [WPB-9133] (#3007) --- .editorconfig | 5 ++ .github/workflows/build-app.yml | 2 +- .github/workflows/gradle-run-ui-tests.yml | 46 ++++++++++++++++--- .github/workflows/gradle-run-unit-tests.yml | 19 ++++++-- .../android/ui/CallActivityViewModelTest.kt | 3 ++ .../android/ui/WireActivityViewModelTest.kt | 16 +++---- 6 files changed, 71 insertions(+), 20 deletions(-) diff --git a/.editorconfig b/.editorconfig index 9db82a18a3e..715420b84eb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,6 +16,11 @@ ij_smart_tabs = false ij_visual_guides = none ij_wrap_on_typing = false +# Specific settings for YAML files +[{*.yml,*.yaml}] +indent_style = space +indent_size = 2 + [{*.gradle.kts,*.kt,*.kts,*.main.kts,*.space.kts}] max_line_length = 140 ij_kotlin_name_count_to_use_star_import = 999 diff --git a/.github/workflows/build-app.yml b/.github/workflows/build-app.yml index 1c35a9b47c2..35e5552eaa3 100644 --- a/.github/workflows/build-app.yml +++ b/.github/workflows/build-app.yml @@ -40,7 +40,7 @@ jobs: cp app/build/outputs/apk/dev/debug/com.wire.*.apk wire-android-${{inputs.flavour}}-pr-${{ github.event.pull_request.number }}.apk - name: Upload APK if: success() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: wire-android-${{inputs.flavour}}-pr-${{ github.event.pull_request.number }}.apk path: ./wire-android-${{inputs.flavour}}-pr-${{ github.event.pull_request.number }}.apk diff --git a/.github/workflows/gradle-run-ui-tests.yml b/.github/workflows/gradle-run-ui-tests.yml index 751e1f2b656..545477f299a 100644 --- a/.github/workflows/gradle-run-ui-tests.yml +++ b/.github/workflows/gradle-run-ui-tests.yml @@ -2,20 +2,33 @@ name: "Run UI Tests" on: merge_group: + push: + branches: + - develop + - release/candidate + - prod + - internal + - main pull_request: types: [ opened, synchronize ] # Don't rerun on `edited` to save time + branches: + - develop + - release/candidate + - prod + - internal + - main workflow_call: concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true jobs: ui-tests: runs-on: buildjet-8vcpu-ubuntu-2204 strategy: matrix: - api-level: [29] + api-level: [ 29 ] steps: - name: Checkout @@ -32,7 +45,7 @@ jobs: cache: gradle - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@216d1ad2b3710bf005dc39237337b9673fd8fcd5 + uses: gradle/actions/wrapper-validation@v3 - name: AVD cache uses: buildjet/cache@v4 @@ -49,6 +62,7 @@ jobs: with: api-level: ${{ matrix.api-level }} target: google_apis + arch: x86_64 force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true @@ -61,9 +75,27 @@ jobs: target: google_apis script: ./gradlew runAcceptanceTests env: - GITHUB_USER: ${{ github.actor }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - + GITHUB_USER: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get commit hash + run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV + + - name: Copy test results to simplified directory + run: | + mkdir -p acceptanceTests/flavors + cp -r app/build/reports/androidTests/connected/debug/flavors/* acceptanceTests/flavors/ + + - name: Zip test results + run: | + zip -r integration-tests-android_${{ env.COMMIT_HASH }}.zip acceptanceTests/flavors/ + + - name: Upload zipped test results + uses: actions/upload-artifact@v4 + with: + name: integration-tests-android_${{ env.COMMIT_HASH }} + path: integration-tests-android_${{ env.COMMIT_HASH }}.zip + - name: Cleanup Gradle Cache # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. # Restoring these files from a GitHub Actions cache might cause problems for future builds. diff --git a/.github/workflows/gradle-run-unit-tests.yml b/.github/workflows/gradle-run-unit-tests.yml index 621e3befdff..935d59349b2 100644 --- a/.github/workflows/gradle-run-unit-tests.yml +++ b/.github/workflows/gradle-run-unit-tests.yml @@ -32,7 +32,7 @@ jobs: cache: gradle - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@216d1ad2b3710bf005dc39237337b9673fd8fcd5 + uses: gradle/actions/wrapper-validation@v3 - name: Test Build Logic run: | @@ -48,15 +48,26 @@ jobs: - name: Install Pip for test result publishing run: sudo apt-get install -y python3-pip + - name: Get commit hash + run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV + + - name: Zip test results + run: | + zip -r unit-tests-android_${{ env.COMMIT_HASH }}.zip **/build/test-results/**/*.xml **/build/outputs/androidTest-results/**/*.xml + + - name: Upload zipped test results + uses: actions/upload-artifact@v4 + with: + name: unit-tests-android_${{ env.COMMIT_HASH }} + path: unit-tests-android_${{ env.COMMIT_HASH }}.zip + # Uploads test results as GitHub artifacts, so publish-test-results can find them later. - name: Upload Test Results uses: actions/upload-artifact@v4 if: always() with: - # This name is referenced in the publish-test-results workflow. name: test-results path: | - **/build/test-results/testDevDebugUnitTest/**/*.xml **/build/test-results/**/*.xml **/build/outputs/androidTest-results/**/*.xml @@ -107,7 +118,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Upload - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Event File path: ${{ github.event_path }} diff --git a/app/src/test/kotlin/com/wire/android/ui/CallActivityViewModelTest.kt b/app/src/test/kotlin/com/wire/android/ui/CallActivityViewModelTest.kt index 3cf1e0fea7f..6f18b93c1ad 100644 --- a/app/src/test/kotlin/com/wire/android/ui/CallActivityViewModelTest.kt +++ b/app/src/test/kotlin/com/wire/android/ui/CallActivityViewModelTest.kt @@ -34,6 +34,7 @@ import io.mockk.coVerify import io.mockk.every import io.mockk.impl.annotations.MockK import kotlinx.coroutines.flow.flowOf +import kotlinx.coroutines.test.advanceUntilIdle import kotlinx.coroutines.test.runTest import org.amshove.kluent.internal.assertEquals import org.junit.jupiter.api.Test @@ -87,6 +88,7 @@ class CallActivityViewModelTest { .arrange() viewModel.switchAccountIfNeeded(userId) + advanceUntilIdle() coVerify(exactly = 1) { arrangement.accountSwitch(any()) } } @@ -100,6 +102,7 @@ class CallActivityViewModelTest { .arrange() viewModel.switchAccountIfNeeded(UserId("anotherUserId", "domain")) + advanceUntilIdle() coVerify(exactly = 1) { arrangement.accountSwitch(any()) } } diff --git a/app/src/test/kotlin/com/wire/android/ui/WireActivityViewModelTest.kt b/app/src/test/kotlin/com/wire/android/ui/WireActivityViewModelTest.kt index 2952d68bddf..b19862723c4 100644 --- a/app/src/test/kotlin/com/wire/android/ui/WireActivityViewModelTest.kt +++ b/app/src/test/kotlin/com/wire/android/ui/WireActivityViewModelTest.kt @@ -863,14 +863,14 @@ class WireActivityViewModelTest { val ongoingCall = Call( CommonTopAppBarViewModelTest.conversationId, CallStatus.ESTABLISHED, - true, - false, - false, - "caller-id", - "ONE_ON_ONE Name", - Conversation.Type.ONE_ON_ONE, - "otherUsername", - "team1" + isMuted = true, + isCameraOn = false, + isCbrEnabled = false, + callerId = "caller-id", + conversationName = "ONE_ON_ONE Name", + conversationType = Conversation.Type.ONE_ON_ONE, + callerName = "otherUsername", + callerTeamName = "team1" ) } }