Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Make snapshot tests great again #5486

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/e2e-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
key-prefix: gradle-test
- name: Build apks
run: bundle exec fastlane build_e2e_test
timeout-minutes: 30
- name: Upload apks
uses: actions/[email protected]
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-test-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
cron: true
- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
timeout-minutes: 120
with:
api-level: ${{ env.ANDROID_API_LEVEL }}
disable-animations: true
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- batch: 0
- batch: 1
env:
ANDROID_API_LEVEL: 35
ANDROID_API_LEVEL: 34
steps:
- name: Connect Bot
uses: webfactory/[email protected]
Expand All @@ -49,6 +49,7 @@ jobs:
allure-token: ${{ secrets.ALLURE_TOKEN }}
- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
timeout-minutes: 45
with:
api-level: ${{ env.ANDROID_API_LEVEL }}
disable-animations: true
Expand Down
39 changes: 0 additions & 39 deletions .github/workflows/snapshot-record.yaml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/snapshot-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Snapshot Tests

on:
# pull_request: # FIXME: https://github.com/pedrovgs/Shot/issues/326

workflow_dispatch:
inputs:
record:
description: 'Should Snapshots be recorded on CI?'
type: boolean
required: false
default: false

jobs:
run_snapshot_tests:
name: Run
runs-on: ubuntu-24.04
steps:
- name: Check out code
uses: actions/[email protected]
- uses: ./.github/actions/setup-java
- uses: ./.github/actions/setup-ruby
- uses: ./.github/actions/gradle-cache
with:
key-prefix: gradle-test

- name: Snapshot tests
uses: reactivecircus/android-emulator-runner@v2
timeout-minutes: 60
with:
api-level: 27
disable-animations: true
profile: pixel
arch : x86_64
emulator-options: ${{ vars.EMULATOR_OPTIONS }}
script: bundle exec fastlane run_snapshot_test record:${{ github.event.inputs.record }}

- name: Upload test results
if: failure()
uses: actions/[email protected]
continue-on-error: true
with:
name: report
path: ./**/build/reports/*

- name: Create Pull Request
if: ${{ github.event.inputs.record == 'true' }}
uses: peter-evans/create-pull-request@v4
with:
commit-message: "Update screenshots"
title: "Update screenshots"
delete-branch: true
reviewers: GetStream/android-developers-ui
branch: update-screenshots
36 changes: 0 additions & 36 deletions .github/workflows/snapshot-tests.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ object Versions {
internal const val REORDERABLE = "2.4.0"
internal const val ROOM = "2.6.1"
internal const val SHIMMER = "0.5.0"
internal const val SHOT = "5.14.1"
internal const val SHOT = "6.1.0"
internal const val SPOTLESS = "6.20.0"
internal const val STREAM_LOG = "1.3.1"
internal const val STREAM_PUSH = "1.1.9"
Expand Down
16 changes: 15 additions & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Dir.chdir('..') { 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])
Expand Down Expand Up @@ -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
Expand Down
Loading