Skip to content

Instantly share code, notes, and snippets.

@timmyjose
Created March 13, 2024 04:25
Show Gist options
  • Save timmyjose/aa03d1633f6261673cb6c7a2b6178e5a to your computer and use it in GitHub Desktop.
Save timmyjose/aa03d1633f6261673cb6c7a2b6178e5a to your computer and use it in GitHub Desktop.
Using github's `macos-14` runner for detox e2e tests (attempt)
name: e2e tests for RustyCalc
on:
workflow_dispatch:
push:
branches:
- 'main'
paths:
- 'app/**'
- '.github/workflows/e2e-tests.yml'
jobs:
build_ios:
name: Install, Build, and e2e Testing (iOS)
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: yarn
cache-dependency-path: '**/yarn.lock'
lfs: 'true'
- name: Set LANG globally for subsequent steps
run: echo "LANG=en_US.UTF-8" >> $GITHUB_ENV
- name: Install detox cli
run: npm install -g detox-cli
- name: Install applesimutils
run: |
brew tap wix/brew
brew install applesimutils
- name: Checkout
uses: actions/checkout@v4
with:
lfs: 'true'
- name: Setup Project
working-directory: app/packages/calc
run: bash -c "yarn setup"
- name: Pod install for iOS
working-directory: app/packages/calc/ios
run: npx pod-install
- name: Detox build for iOS
working-directory: app/packages/calc
run: bash -c "detox build -c ios.release" > /dev/null
- name: Detox e2e tests for iOS
working-directory: app/packages/calc
run: bash -c "NODE_OPTIONS='--max-old-space-size=4096' detox test -c ios.release"
build_android:
name: Install, Build, and e2e Testing (Android)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: yarn
cache-dependency-path: '**/yarn.lock'
lfs: 'true'
- name: Set LANG globally for subsequent steps
run: echo "LANG=en_US.UTF-8" >> $GITHUB_ENV
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Create AVD, start emulator, and wait for emulator to be available
run: |
echo "Installing dependencies"
sudo apt-get --quiet update --yes
sudo apt-get --quiet install --yes \
libc6 \
libdbus-1-3 \
libfontconfig1 \
libgcc1 \
libpulse0 \
libtinfo5 \
libx11-6 \
libxcb1 \
libxdamage1 \
libnss3 \
libxcomposite1 \
libxcursor1 \
libxi6 \
libxext6 \
libxfixes3 \
zlib1g \
libgl1 \
pulseaudio \
socat
> /dev/null
echo "Starting adb server"
adb start-server
echo "Installing AVD system image"
sdkmanager --install "system-images;android-31;google_apis;x86_64"
ANDROID_EMULATOR="pixel_4"
echo "Creating AVD"
avdmanager --verbose create avd --force --name "${ANDROID_EMULATOR}" --device "${ANDROID_EMULATOR}" --package "system-images;android-31;google_apis;x86_64"
max_retries=10
counter=0
until ${ANDROID_SDK_ROOT}/emulator/emulator -list-avds | grep "${ANDROID_EMULATOR}"; do
echo "AVD not available yet..."
sleep 5
echo "Listing AVDs..."
echo $(${ANDROID_SDK_ROOT}/emulator/emulator -list-avds)
[[ counter -eq $max_retries ]] && echo "Could not list ${ANDROID_EMULATOR} in list of AVDs" && exit 1
counter=$((counter + 1))
done
echo "emulator version: $(${ANDROID_SDK_ROOT}/emulator/emulator --version)"
echo "Starting emulator ${ANDROID_EMULATOR}"
${ANDROID_SDK_ROOT}/emulator/emulator @"${ANDROID_EMULATOR}" -no-audio -no-window -no-boot-anim -use-system-libs 2>&1 > /dev/null &
max_retries=10
counter=0
until adb shell getprop sys.boot_completed; do
sleep 10
[[ counter -eq $max_retries ]] && echo "Failed to start the emulator!" && exit 1
counter=$((counter + 1))
done
env:
ANDROID_SDK_ROOT: ${{ env.ANDROID_SDK_ROOT }}
- name: Install detox cli
run: npm install -g detox-cli
- name: Checkout
uses: actions/checkout@v4
with:
lfs: 'true'
- name: Setup Project
working-directory: app/packages/calc
run: bash -c "yarn setup"
- name: Detox build for Android
working-directory: app/packages/calc
run: bash -c "detox build -c android.release" > /dev/null
- name: Detox e2e tests for Android
working-directory: app/packages/calc
run: bash -c "NODE_OPTIONS='--max-old-space-size=4096' detox test -c android.release"
- name: Stop Android emulator and adb server
run: |
max_retries=10
counter=0
echo "Killing emulator"
adb devices | grep emulator | cut -f1 | while read -r emulator; do
sleep 5
[[ $counter -eq $max_retries ]] && echo "Failed to kill the emulator!" && exit 1
adb -s $emulator emu kill
counter=$((counter + 1))
done
echo "Killing adb server"
adb kill-server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment