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

Add e2e tests #242

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
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
105 changes: 105 additions & 0 deletions .github/workflows/pr_android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Build Android on PRs
on:
workflow_dispatch:
pull_request:
types: [opened, reopened, synchronize]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [ 34 ]
newArchEnabled: [ false ]
name: Build for API Level ${{ matrix.api-level }} using ${{matrix.newArchEnabled == true && 'New' || 'Old' }} Architecture
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Java
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
cache: gradle

- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v3

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Run npm install
run: |
npm i -g corepack
npm ci --workspaces --include-workspace-root

- name: Build workspaces
run: npm run build

- name: Run documentation tests
run: npm test

- name: Install & update e2e app with latest react-native-theoplayer
run: |
cd apps/e2e
npm update react-native-theoplayer
npm ci

- name: Enable KVM
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

- name: Gradle cache
uses: gradle/actions/setup-gradle@v3

- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}

- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true' #check previous step output
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: google_apis
arch: x86_64
cores: 2
ram-size: 3072M
force-avd-creation: true
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: echo "Generated AVD snapshot for caching."

- name: Modify gradle.properties for newArchEnabled
working-directory: apps/e2e/android
run: |
# Modify or add the newArchEnabled property in gradle.properties
echo "newArchEnabled=${{ matrix.newArchEnabled }}" >> ./gradle.properties
cat ./gradle.properties

- name: Run e2e tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: google_apis
arch: x86_64
cores: 2
ram-size: 3072M
force-avd-creation: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
npm run test:e2e:android
cat cavy_results.md >> $GITHUB_STEP_SUMMARY
working-directory: apps/e2e
88 changes: 88 additions & 0 deletions .github/workflows/pr_ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build iOS on PRs
on:
workflow_dispatch:
pull_request:
types: [opened, reopened, synchronize]

jobs:
build:
runs-on: macos-latest
strategy:
matrix:
xcode_version: [ '15.4.0' ]
newArchEnabled: [ 0 ]
platform: [iOS, tvOS]
name: Build for ${{ matrix.platform }} using XCode version ${{ matrix.xcode_version }} and ${{matrix.newArchEnabled == 1 && 'New' || 'Old' }} Architecture

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Select Xcode ${{ matrix.xcode_version }}
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.xcode_version }}

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Cache Ruby Gems
uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-

- name: Cache CocoaPods
uses: actions/cache@v4
with:
path: apps/e2e/ios/Pods
key: pods-${{ runner.os }}-${{ hashFiles('Podfile.lock') }}-${{ matrix.newArchEnabled }}
restore-keys: |
pods-${{ runner.os }}-

- name: Run npm install
run: |
npm i -g corepack
npm ci --workspaces --include-workspace-root

- name: Build workspaces
run: npm run build

- name: Run documentation tests
run: npm test

- name: Install & update e2e app with latest react-native-theoplayer
run: |
cd apps/e2e
npm update react-native-theoplayer
npm ci

- name: Install Ruby dependencies
working-directory: apps/e2e
run: bundle install

- name: Run pod install & update dependencies
working-directory: apps/e2e/ios
run: |
RCT_NEW_ARCH_ENABLED=${{ matrix.newArchEnabled }} bundle exec pod install

- name: Start iOS simulator
uses: futureware-tech/simulator-action@v4
with:
model: ${{ matrix.platform == 'iOS' && 'iPhone 15' || 'Apple TV' }}
os: ${{ matrix.platform }}
os_version: '>=14.0'

- name: Run e2e tests
working-directory: apps/e2e
run: npm run test:e2e:${{ matrix.platform == 'iOS' && 'ios' || 'tvos' }}

- name: Summarize results
working-directory: apps/e2e
if: always()
run: cat cavy_results.md >> $GITHUB_STEP_SUMMARY
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Build Web on PRs
on:
push:
branches:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,5 @@ comscore/src/manifest.json
conviva/src/manifest.json
mux/src/manifest.json
nielsen/src/manifest.json
apps/e2e/cavy_results.md
apps/e2e/ios/Pods
2 changes: 2 additions & 0 deletions apps/e2e/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BUNDLE_PATH: "vendor/bundle"
BUNDLE_FORCE_RUBY_PLATFORM: 1
1 change: 1 addition & 0 deletions apps/e2e/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.5
5 changes: 5 additions & 0 deletions apps/e2e/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source "https://rubygems.org"

# Cocoapods 1.15 introduced a bug which breaks the build.
gem 'cocoapods', '>= 1.13', '< 1.15'
gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'
55 changes: 55 additions & 0 deletions apps/e2e/android/app/_BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# To learn about Buck see [Docs](https://buckbuild.com/).
# To run your application with Buck:
# - install Buck
# - `npm start` - to start the packager
# - `cd android`
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
# - `buck install -r android/app` - compile, install and run application
#

load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")

lib_deps = []

create_aar_targets(glob(["libs/*.aar"]))

create_jar_targets(glob(["libs/*.jar"]))

android_library(
name = "all-libs",
exported_deps = lib_deps,
)

android_library(
name = "app-code",
srcs = glob([
"src/main/java/**/*.java",
]),
deps = [
":all-libs",
":build_config",
":res",
],
)

android_build_config(
name = "build_config",
package = "com.reactnativetheoplayer",
)

android_resource(
name = "res",
package = "com.reactnativetheoplayer",
res = "src/main/res",
)

android_binary(
name = "app",
keystore = "//android/keystores:debug",
manifest = "src/main/AndroidManifest.xml",
package_type = "debug",
deps = [
":app-code",
],
)
Loading
Loading