From b624c1c054c62115013c0026f698b1d96fc07374 Mon Sep 17 00:00:00 2001 From: Alexey Alter-Pesotskiy Date: Mon, 25 Nov 2024 18:45:39 +0000 Subject: [PATCH] Test --- .../{snapshot-tests.yaml => snapshot-test.yaml} | 9 ++++----- fastlane/Fastfile | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) rename .github/workflows/{snapshot-tests.yaml => snapshot-test.yaml} (71%) diff --git a/.github/workflows/snapshot-tests.yaml b/.github/workflows/snapshot-test.yaml similarity index 71% rename from .github/workflows/snapshot-tests.yaml rename to .github/workflows/snapshot-test.yaml index 55d46c34644..61d7b53100a 100644 --- a/.github/workflows/snapshot-tests.yaml +++ b/.github/workflows/snapshot-test.yaml @@ -3,6 +3,8 @@ name: Snapshot Tests on: # pull_request: # FIXME: https://github.com/pedrovgs/Shot/issues/326 + push: # TESTING NOW + workflow_dispatch: inputs: record: @@ -19,14 +21,11 @@ jobs: - name: Check out code uses: actions/checkout@v4.2.2 - uses: ./.github/actions/setup-java + - uses: ./.github/actions/setup-ruby - uses: ./.github/actions/gradle-cache with: key-prefix: gradle-test - - name: Enable recording - if: ${{ github.event.inputs.record == 'true' }} - run: echo 'RECORD_SNAPSHOTS_IF_REQUIRED=-Precord' >> $GITHUB_ENV - - name: Snapshot tests uses: reactivecircus/android-emulator-runner@v2 timeout-minutes: 60 @@ -36,7 +35,7 @@ jobs: profile: pixel arch : x86_64 emulator-options: ${{ vars.EMULATOR_OPTIONS }} - script: ./gradlew stream-chat-android-ui-uitests:executeScreenshotTests ${{ env.RECORD_SNAPSHOTS_IF_REQUIRED }} -Pandroid.testInstrumentationRunnerArguments.filter=io.getstream.chat.android.uitests.util.SnapshotTestFilter -Dorg.gradle.jvmargs="--add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.nio.channels=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED" + script: bundle exec fastlane run_snapshot_test record:${{ github.event.inputs.record }} - name: Upload test results if: failure() diff --git a/fastlane/Fastfile b/fastlane/Fastfile index cb24f018640..8f2063b34b2 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -34,6 +34,19 @@ lane :stop_mock_server do Net::HTTP.get_response(URI("http://localhost:#{mock_server_driver_port}/stop")) rescue nil end +lane :run_snapshot_test do |options| + next unless is_check_required(sources: sources_matrix[:ui], force_check: @force_check) + + cmd = [ + './gradlew', + 'stream-chat-android-ui-uitests:executeScreenshotTests', + '-Pandroid.testInstrumentationRunnerArguments.filter=io.getstream.chat.android.uitests.util.SnapshotTestFilter', + '-Dorg.gradle.jvmargs="--add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.nio.channels=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED"' + ] + cmd << '-Precord' unless options[:record].to_s.empty? + sh(cmd.join(' ')) +end + lane :build_and_run_e2e_test do |options| build_e2e_test run_e2e_test(batch: options[:batch], batch_count: options[:batch_count]) @@ -115,7 +128,8 @@ end private_lane :sources_matrix do { - e2e: ['buildSrc', 'stream-chat-android', '.github/workflows/e2e-tests'], + ui: ['stream-chat-android-ui', '.github/workflows/snapshot-test'], + e2e: ['buildSrc', 'stream-chat-android', '.github/workflows/e2e-test'], ruby: ['fastlane', 'Gemfile', 'Gemfile.lock'] } end