Skip to content

Commit

Permalink
[CI] Implement E2E tests parallelization and nightly runs (#5480)
Browse files Browse the repository at this point in the history
* [CI] Implement E2E tests parallelization and nightly runs

* Resolve comments
  • Loading branch information
testableapple authored Nov 22, 2024
1 parent b568c6b commit e838cc2
Show file tree
Hide file tree
Showing 27 changed files with 323 additions and 288 deletions.
18 changes: 18 additions & 0 deletions .github/actions/allure-launch/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Allure Launch'
description: 'Launches Allure TestOps job'
inputs:
allure-token:
description: 'ALLURE_TOKEN'
required: true
cron:
description: 'Is this a cron check?'
default: 'false'
runs:
using: "composite"
steps:
- name: Launch Allure TestOps
run: bundle exec fastlane allure_launch cron:${{ inputs.cron }}
shell: bash
env:
ALLURE_TOKEN: ${{ inputs.allure-token }}
GITHUB_EVENT: ${{ toJson(github.event) }}
10 changes: 10 additions & 0 deletions .github/actions/setup-java/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: 'Setup Java'
description: 'Setup Java'
runs:
using: "composite"
steps:
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 17
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Ruby Cache'
description: 'Cache Ruby dependencies'
name: 'Setup Ruby'
description: 'Setup Ruby and cache bundler'
runs:
using: "composite"
steps:
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/apk-s3-distribute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: adopt
java-version: 17
- uses: ./.github/actions/setup-java
- name: Prepare environment
run: |
git fetch --unshallow
Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/app-distribute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: adopt
java-version: 17
- uses: ./.github/actions/setup-java
- name: Prepare environment
run: |
git fetch --unshallow
Expand Down Expand Up @@ -44,11 +40,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: adopt
java-version: 17
- uses: ./.github/actions/setup-java
- name: Prepare environment
run: |
git fetch --unshallow
Expand Down
30 changes: 5 additions & 25 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ jobs:
steps:
- name: Check out code
uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: adopt
java-version: 17
- uses: ./.github/actions/setup-java
- name: Build
run: ./gradlew assembleDebug :stream-chat-android-ui-uitests:assembleDebugAndroidTest

Expand All @@ -31,11 +27,7 @@ jobs:
steps:
- name: Check out code
uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: adopt
java-version: 17
- uses: ./.github/actions/setup-java
- name: Build
run: ./gradlew assembleRelease

Expand All @@ -45,11 +37,7 @@ jobs:
steps:
- name: Check out code
uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: adopt
java-version: 17
- uses: ./.github/actions/setup-java
- name: Unit tests
run: ./scripts/ci-unit-tests.sh
- name: Upload testDebugUnitTest results
Expand All @@ -65,11 +53,7 @@ jobs:
steps:
- name: Check out code
uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: adopt
java-version: 17
- uses: ./.github/actions/setup-java
- name: build demo debug
run: ./gradlew stream-chat-android-ui-components-sample:assembleDemoDebug
- name: Upload artifact to Emerge
Expand All @@ -85,11 +69,7 @@ jobs:
steps:
- name: Check out code
uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: adopt
java-version: 17
- uses: ./.github/actions/setup-java
- name: build debug
run: ./gradlew stream-chat-android-compose-sample:assembleDebug
- name: Upload artifact to Emerge
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/check-entities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ jobs:
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: adopt
java-version: 17
- uses: ./.github/actions/setup-java
- name: Find touched DB Entities
id: touchedEntities
continue-on-error: true
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/clean-detekt-baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ jobs:
with:
ref: develop
token: ${{ secrets.STREAM_PUBLIC_BOT_TOKEN }}
- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: adopt
java-version: 17
- uses: ./.github/actions/setup-java
- uses: tibdex/[email protected]
id: generate-token
with:
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/e2e-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: E2E Build

on:
workflow_call:
inputs:
app:
required: true
type: string

jobs:
build:
name: ${{ inputs.app }} apks
runs-on: ubuntu-24.04
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/setup-java
- uses: ./.github/actions/enable-kvm
- uses: ./.github/actions/setup-ruby
- uses: ./.github/actions/gradle-cache
with:
key-prefix: gradle-test
- name: Build apks
run: bundle exec fastlane build_e2e_test
- name: Upload apks
uses: actions/[email protected]
with:
name: apks
path: |
stream-chat-android-${{ inputs.app }}-sample/build/outputs/apk/e2e/debug/*.apk
stream-chat-android-${{ inputs.app }}-sample/build/outputs/apk/androidTest/e2e/debug/*.apk
86 changes: 86 additions & 0 deletions .github/workflows/e2e-test-cron.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: E2E Tests Nightly

on:
schedule:
# Runs "At 01:00 every night except weekends"
- cron: '0 1 * * 1-5'

workflow_dispatch:

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build-compose-apks:
name: Build
uses: ./.github/workflows/e2e-build.yml
with:
app: compose

run-compose-tests-nightly:
name: Test compose
runs-on: ubuntu-24.04
needs: build-compose-apks
strategy:
matrix:
include:
- android_api_level: 35
- android_api_level: 34
- android_api_level: 33
- android_api_level: 32
- android_api_level: 31
- android_api_level: 29
- android_api_level: 28
fail-fast: false
env:
ANDROID_API_LEVEL: ${{ matrix.android_api_level }}
steps:
- name: Connect Bot
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }}
- uses: actions/[email protected]
- uses: actions/[email protected]
continue-on-error: true
with:
name: apks
- uses: ./.github/actions/setup-java
- uses: ./.github/actions/enable-kvm
- uses: ./.github/actions/setup-ruby
- uses: ./.github/actions/allure-launch
with:
allure-token: ${{ secrets.ALLURE_TOKEN }}
cron: true
- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.ANDROID_API_LEVEL }}
disable-animations: true
profile: pixel
arch : x86_64
emulator-options: ${{ vars.EMULATOR_OPTIONS }}
script: bundle exec fastlane run_e2e_test
- name: Allure TestOps Upload
run: bundle exec fastlane allure_upload
if: success() || failure()
env:
ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }}
LAUNCH_ID: ${{ env.LAUNCH_ID }}
- name: Allure TestOps Launch Removal
run: bundle exec fastlane allure_launch_removal
if: cancelled()
env:
ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }}
LAUNCH_ID: ${{ env.LAUNCH_ID }}
- name: Upload test results
uses: actions/[email protected]
if: failure()
with:
name: test_report
path: |
./**/build/reports/androidTests/*
fastlane/stream-chat-test-mock-server/logs/*
78 changes: 78 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: E2E Tests

on:
pull_request:

workflow_dispatch:

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PR_NUM: ${{ github.event.pull_request.number }}

jobs:
build-compose-apks:
name: Build
uses: ./.github/workflows/e2e-build.yml
with:
app: compose

run-compose-tests:
name: Test compose
runs-on: ubuntu-24.04
needs: build-compose-apks
strategy:
matrix:
include:
- batch: 0
- batch: 1
env:
ANDROID_API_LEVEL: 35
steps:
- name: Connect Bot
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }}
- uses: actions/[email protected]
- uses: actions/[email protected]
continue-on-error: true
with:
name: apks
- uses: ./.github/actions/setup-java
- uses: ./.github/actions/enable-kvm
- uses: ./.github/actions/setup-ruby
- uses: ./.github/actions/allure-launch
with:
allure-token: ${{ secrets.ALLURE_TOKEN }}
- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.ANDROID_API_LEVEL }}
disable-animations: true
profile: pixel
arch : x86_64
emulator-options: ${{ vars.EMULATOR_OPTIONS }}
script: bundle exec fastlane run_e2e_test batch:${{ matrix.batch }} batch_count:${{ strategy.job-total }}
- name: Allure TestOps Upload
if: success() || failure()
run: bundle exec fastlane allure_upload
env:
ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }}
LAUNCH_ID: ${{ env.LAUNCH_ID }}
- name: Allure TestOps Launch Removal
if: cancelled()
run: bundle exec fastlane allure_launch_removal
env:
ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }}
LAUNCH_ID: ${{ env.LAUNCH_ID }}
- name: Upload test results
uses: actions/[email protected]
if: failure()
with:
name: test_report
path: |
./**/build/reports/androidTests/*
fastlane/stream-chat-test-mock-server/logs/*
Loading

0 comments on commit e838cc2

Please sign in to comment.