Skip to content

Commit

Permalink
[CI] Implement E2E testing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
testableapple authored and JcMinarro committed Nov 15, 2024
1 parent b85f643 commit 4e11fe9
Show file tree
Hide file tree
Showing 21 changed files with 1,037 additions and 9 deletions.
11 changes: 11 additions & 0 deletions .github/actions/enable-kvm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: 'Enable KVM'
description: 'Enables hardware accelerated Android virtualization on Actions Linux larger hosted runners'
runs:
using: "composite"
steps:
- name: Enable KVM group perms
shell: bash
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
2 changes: 1 addition & 1 deletion .github/actions/gradle-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
runs:
using: "composite"
steps:
- uses: actions/cache@v3.0.11
- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
Expand Down
9 changes: 9 additions & 0 deletions .github/actions/ruby-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: 'Ruby Cache'
description: 'Cache Ruby dependencies'
runs:
using: "composite"
steps:
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true
6 changes: 3 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: adopt
distribution: adopt
java-version: 17
- name: Unit tests
run: ./scripts/ci-unit-tests.sh
Expand Down Expand Up @@ -77,8 +77,8 @@ jobs:
with:
artifact_path: ./stream-chat-android-ui-components-sample/build/outputs/apk/demo/debug/stream-chat-android-ui-components-sample-demo-debug.apk
emerge_api_key: ${{ secrets.EMERGE_TOOLS_API_KEY }}
build_type: debug
build_type: debug

size_check_compose:
name: Size Check Compose
runs-on: ubuntu-22.04
Expand Down
114 changes: 114 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
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-apks:
name: Build
runs-on: ubuntu-24.04
steps:
- uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 17
- uses: ./.github/actions/enable-kvm
- uses: ./.github/actions/ruby-cache
- 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-compose-sample/build/outputs/apk/e2e/debug/*.apk
stream-chat-android-compose-sample/build/outputs/apk/androidTest/e2e/debug/*.apk
allure_testops_launch:
name: Launch Allure TestOps
runs-on: ubuntu-24.04
needs: build-apks
outputs:
launch_id: ${{ steps.get_launch_id.outputs.launch_id }}
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/ruby-cache
- name: Launch Allure TestOps
run: bundle exec fastlane allure_launch
env:
ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }}
GITHUB_EVENT: ${{ toJson(github.event) }}
- id: get_launch_id
run: echo "launch_id=${{env.LAUNCH_ID}}" >> $GITHUB_OUTPUT
if: env.LAUNCH_ID != ''

run-tests:
name: Test
runs-on: ubuntu-24.04
needs:
- build-apks
- allure_testops_launch
env:
LAUNCH_ID: ${{ needs.allure_testops_launch.outputs.launch_id }}
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
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 17
- uses: ./.github/actions/enable-kvm
- uses: ./.github/actions/ruby-cache
- uses: ./.github/actions/gradle-cache
with:
key-prefix: gradle-test
- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
disable-animations: true
profile: pixel
arch : x86_64
emulator-options: -no-snapshot-save -no-window -no-audio -no-boot-anim -gpu swiftshader_indirect -camera-back none -camera-front none
script: bundle exec fastlane run_e2e_test
- name: Allure TestOps Upload
if: env.LAUNCH_ID != '' && (success() || failure())
run: bundle exec fastlane allure_upload launch_id:$LAUNCH_ID
env:
ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }}
- name: Allure TestOps Launch Removal
if: env.LAUNCH_ID != '' && cancelled()
run: bundle exec fastlane allure_launch_removal launch_id:$LAUNCH_ID
env:
ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }}
- 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/*
11 changes: 10 additions & 1 deletion .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- name: Detekt
if: always()
run: ./gradlew detekt

vale:
name: Vale doc linter
runs-on: ubuntu-latest
Expand Down Expand Up @@ -106,4 +107,12 @@ jobs:
if: failure()
with:
name: testDebugUnitTest
path: ./**/build/reports/tests/testDebugUnitTest
path: ./**/build/reports/tests/testDebugUnitTest

rubocop:
name: Rubocop
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/ruby-cache
- run: bundle exec fastlane rubocop
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,14 @@ docusaurus/shared

.sign/keystore.properties
.sign/release.keystore

# fastlane
!fastlane/.env
fastlane/fastlane.log
fastlane/report.xml
fastlane/screenshots
fastlane/test_output
fastlane/allurectl
fastlane/recordings
allure-results
stream-chat-test-mock-server
24 changes: 24 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

source 'https://rubygems.org'

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

gem 'fastlane', '2.225.0'
gem 'json'
gem 'rubocop', '1.38', group: :rubocop_dependencies
gem 'sinatra', group: :sinatra_dependencies

eval_gemfile('fastlane/Pluginfile')

group :rubocop_dependencies do
gem 'rubocop-performance'
gem 'rubocop-require_tools'
end

group :sinatra_dependencies do
gem 'eventmachine'
gem 'faye-websocket'
gem 'puma'
gem 'rackup'
end
Loading

0 comments on commit 4e11fe9

Please sign in to comment.