Run e2e tests on CI #677
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
merge_group: | |
types: | |
- checks_requested | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
static-analysis: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup | |
uses: ./.github/actions/setup | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Clang Format | |
working-directory: packages/webgpu | |
run: yarn clang-format | |
- name: Lint files | |
run: yarn lint | |
- name: Typecheck files | |
run: yarn tsc | |
- name: Codegen | |
working-directory: packages/webgpu | |
run: yarn codegen | |
test: | |
runs-on: macos-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup | |
uses: ./.github/actions/setup | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install Chrome | |
run: npx puppeteer browsers install chrome | |
- name: Run reference test suite | |
working-directory: packages/webgpu | |
run: yarn test:ref | |
- name: Build package | |
run: yarn build | |
build-android: | |
runs-on: macos-latest | |
env: | |
TURBO_CACHE_DIR: .turbo/android | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup | |
uses: ./.github/actions/setup | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Cache turborepo for Android | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.TURBO_CACHE_DIR }} | |
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-turborepo-android | |
- name: Install JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
- name: Install NDK | |
uses: nttld/setup-ndk@v1 | |
id: setup-ndk | |
with: | |
ndk-version: r26d | |
- name: Set ANDROID_NDK | |
run: echo "ANDROID_NDK=$ANDROID_HOME/ndk-bundle" >> $GITHUB_ENV | |
- name: Finalize Android SDK | |
run: | | |
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null" | |
- name: Install Android SDK | |
run: echo "sdk.dir=$ANDROID_HOME" > $GITHUB_WORKSPACE/apps/example/android/local.properties | |
- name: Cache Gradle | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/wrapper | |
~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('./apps/example/android/gradle/wrapper/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Build example for Android | |
env: | |
JAVA_OPTS: "-XX:MaxHeapSize=6g" | |
run: | | |
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --force | |
- name: Cache apk | |
uses: actions/cache/save@v3 | |
env: | |
cache-name: cache-apk | |
with: | |
path: apps/example/android/app/build/outputs/apk/debug/app-debug.apk | |
key: apk-${{ github.sha }} | |
test-android: | |
needs: build-android | |
runs-on: macos-latest-large | |
env: | |
TURBO_CACHE_DIR: .turbo/android | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup | |
uses: ./.github/actions/setup | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Restore APK | |
id: cache-apk | |
uses: actions/cache/restore@v3 | |
with: | |
path: apps/example/android/app/build/outputs/apk/debug/app-debug.apk | |
key: apk-${{ github.sha }} | |
- name: SDKs - download required images | |
run: $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "system-images;android-30;default;x86_64" | |
- name: Emulator - Create | |
run: $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n Pixel_API_30 --device 'Nexus 5X' --package "system-images;android-30;default;x86_64" --sdcard 512M | |
- name: Emulator - Boot | |
run: $ANDROID_HOME/emulator/emulator -memory 4096 -avd Pixel_API_30 -wipe-data -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim & | |
- name: ADB Wait For Device | |
run: adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;' | |
timeout-minutes: 15 | |
- name: Start Package Manager | |
working-directory: apps/example | |
run: CI=true yarn start > yarn_start_output.log 2>&1 & | |
- name: Check APK existence | |
uses: andstor/file-existence-action@v2 | |
with: | |
files: apps/example/android/app/build/outputs/apk/debug/app-debug.apk | |
fail: true | |
- name: Install APK | |
run: adb install -r apps/example/android/app/build/outputs/apk/debug/app-debug.apk | |
- name: Reverse Port | |
run: adb devices | grep '\t' | awk '{print $1}' | sed 's/\\s//g' | xargs -I {} adb -s {} reverse tcp:8081 tcp:8081 | |
- name: Launch APK | |
env: | |
PACKAGE_NAME: com.microsoft.reacttestapp | |
run: adb shell monkey -p ${{ env.PACKAGE_NAME }} 1 | |
- name: Run e2e Tests | |
working-directory: packages/webgpu | |
run: yarn test | |
- uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
path: packages/webgpu/src/__tests__/snapshots/ | |
name: tests-snapshots-screenshots | |
- name: Display yarn start output | |
if: always() | |
run: cat apps/example/yarn_start_output.log | |
build-ios: | |
runs-on: macos-latest | |
env: | |
TURBO_CACHE_DIR: .turbo/ios | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup | |
uses: ./.github/actions/setup | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Cache turborepo for iOS | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.TURBO_CACHE_DIR }} | |
key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-turborepo-ios- | |
- name: Build example for iOS | |
run: | | |
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" |