Skip to content

Commit

Permalink
ci: single e2e test
Browse files Browse the repository at this point in the history
export JAVA_HOME="/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home"
  • Loading branch information
sandipndev committed Feb 16, 2024
1 parent 4059f1f commit 660c8bc
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 154 deletions.
2 changes: 1 addition & 1 deletion .detoxrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
emulator: {
type: "android.emulator",
device: {
avdName: "Pixel_API_29_AOSP",
avdName: "Pixel_API_34_AOSP",
},
},
},
Expand Down
36 changes: 4 additions & 32 deletions .github/workflows/adb-test.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,9 @@
name: ADB Test
on: push
on: [push]

jobs:
adb-test:
name: Run Detox tests on Android
runs-on: ["self-hosted", "Linux", "X64"]

runs-on: self-hosted
steps:
- uses: actions/setup-node@v2
with:
node-version: 20
- run: npm i -g yarn

- uses: actions/setup-java@v2
with:
java-version: 17
distribution: temurin
- uses: android-actions/setup-android@v3

- name: Enable KVM group perms
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: run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
arch: x86_64
profile: Nexus 6
avd-name: Pixel_API_29_AOSP
script: |
cd ~/galoy-mobile
yarn install
yarn e2e:test android.emu.debug -d -R 3 --headless
- run: |
echo no | avdmanager create avd --force -n Pixel_API_34_AOSP --abi 'aosp_atd/arm64-v8a' --package 'system-images;android-34;aosp_atd;arm64-v8a'
191 changes: 71 additions & 120 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,29 @@ on:
# pull_request:
# branches: [main]

jobs:
build-e2e-android:
name: Build APK
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

# Github hosted runner doesn't have enough space
runs-on: ["self-hosted", "Linux", "X64"]
jobs:
e2e-ios:
name: E2E Test on iOS
runs-on: self-hosted

steps:
- uses: actions/checkout@v2

# Node, Ruby
- uses: actions/setup-node@v2
with:
node-version: 20
- uses: actions/setup-java@v2
- run: npm i -g yarn
- uses: ruby/setup-ruby@v1
with:
java-version: 17
distribution: temurin
- uses: gradle/actions/setup-gradle@v3
bundler-cache: true

# Caching
- uses: DeterminateSystems/magic-nix-cache-action@v2
- uses: actions/cache@v2
with:
path: |
Expand All @@ -31,54 +37,22 @@ jobs:
restore-keys: |
${{ runner.os }}-deps-
- run: npm i -g yarn
- uses: android-actions/setup-android@v3

# Install Node Modules and Pods
- run: yarn install
- run: yarn e2e:build android.emu.debug
env:
LANG: en_US.UTF-8
LC_ALL: en_US.UTF-8

- uses: actions/upload-artifact@v4
with:
name: built-e2e-apk
path: android/app/build/outputs

test-e2e-android:
name: Run Detox tests on Android
runs-on: ["self-hosted", "Linux", "X64"]
needs: build-e2e-android

steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v4
with:
name: built-e2e-apk
path: android/app/build/outputs
- uses: actions/setup-node@v2
with:
node-version: 20
- uses: actions/setup-java@v2
with:
java-version: 17
distribution: temurin
- uses: gradle/actions/setup-gradle@v3

- uses: android-actions/setup-android@v3
- name: Create and Start Android Emulator
# Metro
- name: Start Metro
run: |
echo "Enabling KVM..."
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
echo "Creating AVD..."
avdmanager create avd -n Pixel_API_29_AOSP -k "system-images;android-34;default;x86_64" --device "Nexus 6" --force
echo "Starting Emulator..."
emulator -avd Pixel_API_29_AOSP -no-audio -no-window -accel off &
yarn start &
echo "METRO_PID=$!" >> $GITHUB_ENV
echo "Will take 3-4 minutes to boot up completely"
# Build
- run: yarn e2e:build ios.sim.debug

- uses: DeterminateSystems/magic-nix-cache-action@v2
# Start Tilt
- name: Tilt CI
run: |
for i in {1..5}; do
Expand All @@ -87,39 +61,25 @@ jobs:
done
exit 1
- uses: actions/cache@v2
with:
path: |
node_modules
ios/Pods
key: ${{ runner.os }}-deps-${{ hashFiles('**/yarn.lock', '**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-deps-
- run: npm i -g yarn
- run: yarn install
- name: Start Metro
run: |
yarn start &
echo "METRO_PID=$!" >> $GITHUB_ENV
- name: Run Detox Tests
run: yarn e2e:test android.emu.debug --headless -d -R 3 --take-screenshots all --record-videos all --record-logs all --headless
# Tests on iOS Simulator
- name: Run Detox Tests on iOS Simulator
run: yarn e2e:test ios.sim.debug -d -R 5 --take-screenshots all --record-videos all --record-logs all --artifacts-location ios-recordings

- uses: actions/upload-artifact@v4
if: always()
with:
name: android-recordings
path: artifacts
name: ios-recordings
path: ios-artifacts

- name: Destroy Android Emulator
# Cleanup
- name: Terminate Metro
if: always()
continue-on-error: true
run: adb devices | grep emulator | cut -f1 | while read -r line; do adb -s $line emu kill; done
run: kill $METRO_PID

- name: Terminate Metro
- run: killall Simulator
if: always()
continue-on-error: true
run: kill $METRO_PID

- name: Destroy backend
if: always()
Expand All @@ -128,49 +88,27 @@ jobs:
nix develop -c sh -c 'cd dev && tilt down' || true
docker rm -f $(docker ps -aq)
build-e2e-ios:
name: Build IPA
runs-on: macos-latest
e2e-android:
name: E2E Test on Android
runs-on: self-hosted

steps:
- uses: actions/checkout@v2

# Node, Ruby, Java, Android Sdk
- uses: actions/setup-node@v2
with:
node-version: 20
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- uses: actions/cache@v2
with:
path: |
node_modules
ios/Pods
key: ${{ runner.os }}-deps-${{ hashFiles('**/yarn.lock', '**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-deps-
- run: yarn install
- name: Build app
run: yarn e2e:build ios.sim.debug

- uses: actions/upload-artifact@v4
- run: npm i -g yarn
- uses: actions/setup-java@v2
with:
name: built-e2e-ipa
path: ios/build/Build/Products/Debug-iphonesimulator/Blink.app

test-e2e-ios:
name: Run Detox tests on iOS
runs-on: ["self-hosted", "MacOS", "ARM64"]
needs: build-e2e-ios
java-version: 17
distribution: temurin
- uses: android-actions/setup-android@v3

steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v4
with:
name: built-e2e-ipa
path: ios/build/Build/Products/Debug-iphonesimulator/Blink.app
- uses: actions/setup-node@v2
with:
node-version: 20
# Caching
- uses: gradle/actions/setup-gradle@v3
- uses: DeterminateSystems/magic-nix-cache-action@v2
- uses: actions/cache@v2
with:
path: |
Expand All @@ -180,14 +118,19 @@ jobs:
restore-keys: |
${{ runner.os }}-deps-
- run: npm install -g yarn
- run: yarn install
# Install Node Modules
- run: NOPOSTINSTALLPODS=true yarn install

# Metro
- name: Start Metro
run: |
yarn start &
echo "METRO_PID=$!" >> $GITHUB_ENV
- uses: DeterminateSystems/magic-nix-cache-action@v2
# Build
- run: yarn e2e:build android.emu.debug

# Start Tilt
- name: Tilt CI
run: |
for i in {1..5}; do
Expand All @@ -196,20 +139,28 @@ jobs:
done
exit 1
- run: yarn e2e:test ios.sim.debug -d -R 5 --take-screenshots all --record-videos all --record-logs all --headless
# Android Emulator
- name: Run Detox Tests on Android Emulator
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
arch: arm64-v8a
profile: Pixel 6a
avd-name: Pixel_API_34_AOSP
script: yarn e2e:test android.emu.debug -d -R 5 --take-screenshots all --record-videos all --record-logs all --artifacts-location android-recordings

- uses: actions/upload-artifact@v4
if: always()
with:
name: ios-recordings
path: artifacts
name: android-recordings
path: android-recordings

- run: killall Simulator
if: always()
continue-on-error: true
# Cleanup
- name: Terminate Metro
if: always()
continue-on-error: true
run: kill $METRO_PID

- name: Destroy backend
if: always()
continue-on-error: true
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dev:gengql": "yarn node utils/create-gql.ts",
"adb": "adb reverse tcp:9090 tcp:9090 && adb reverse tcp:3000 tcp:3000 && adb reverse tcp:4000 tcp:4000 && adb reverse tcp:9001 tcp:9001 && adb reverse tcp:8081 tcp:8081 && adb reverse tcp:4002 tcp:4002 && adb reverse tcp:4455 tcp:4455",
"patch": "patch-package",
"postinstall": "jetify && yarn patch-package && if which pod >/dev/null; then (cd ios; bundle install; bundle exec pod install); fi",
"postinstall": "jetify && yarn patch-package && if [ -z \"$NOPOSTINSTALLPODS\" ]; then if which pod >/dev/null; then (cd ios; bundle install; bundle exec pod install); fi; fi",
"hack:types-react-native": "rimraf node_modules/@types/react-native/node_modules/@types",
"prepare": "npm-run-all patch hack:*",
"client:dev": "yalc add @galoymoney/client",
Expand Down

0 comments on commit 660c8bc

Please sign in to comment.