xref: /expo/.github/workflows/test-suite.yml (revision c627e13d)
1name: Test Suite
2
3on:
4  workflow_dispatch: {}
5  push:
6    branches: [main, 'sdk-*']
7    paths:
8      - .github/workflows/test-suite.yml
9      - apps/bare-expo/**
10      - apps/test-suite/**
11      - packages/**
12      - yarn.lock
13  pull_request:
14    paths:
15      - .github/workflows/test-suite.yml
16      - apps/bare-expo/**
17      - apps/test-suite/**
18      - packages/**
19      - yarn.lock
20      # Ignore Expo CLI for now...
21      - '!packages/@expo/cli/**'
22
23concurrency:
24  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
25  cancel-in-progress: true
26
27jobs:
28  web:
29    runs-on: ubuntu-22.04
30    steps:
31      - name: �� Checkout
32        uses: actions/checkout@v3
33        with:
34          submodules: true
35      - name: ⬢ Setup Node
36        uses: actions/setup-node@v3
37        with:
38          node-version: 16
39      - name: ♻️ Restore caches
40        uses: ./.github/actions/expo-caches
41        id: expo-caches
42        with:
43          yarn-workspace: 'true'
44      - name: �� Install node modules in root dir
45        if: steps.expo-caches.outputs.yarn-workspace-hit != 'true'
46        run: yarn install --frozen-lockfile
47      - name: �� Run Web tests
48        run: yarn test:web
49        working-directory: apps/bare-expo
50        env:
51          EXPO_NO_TYPESCRIPT_SETUP: 1
52      - name: �� Notify on Slack
53        uses: 8398a7/action-slack@v3
54        if: failure() && (github.event.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/heads/sdk-'))
55        env:
56          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57          SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook_web }}
58        with:
59          channel: '#expo-web'
60          status: ${{ job.status }}
61          fields: job,message,ref,eventName,author,took
62          author_name: Test Suite (Web)
63
64  ios:
65    runs-on: macos-13
66    steps:
67      - name: �� Checkout
68        uses: actions/checkout@v3
69        with:
70          submodules: true
71      - name: �� Switch to Xcode 14.3
72        run: sudo xcode-select --switch /Applications/Xcode_14.3.app
73      - name: �� Install required tools
74        run: |
75          brew tap wix/brew
76          brew install applesimutils
77          brew install watchman
78      - name: ➕ Add `bin` to GITHUB_PATH
79        run: echo "$(pwd)/bin" >> $GITHUB_PATH
80      - name: �� Setup Ruby and install gems
81        uses: ruby/setup-ruby@v1
82        with:
83          bundler-cache: true
84          ruby-version: 3.2.2
85      - name: ♻️ Restore caches
86        uses: ./.github/actions/expo-caches
87        id: expo-caches
88        with:
89          yarn-workspace: 'true'
90          yarn-tools: 'true'
91          bare-expo-pods: 'true'
92      - name: �� Install node modules in root dir
93        if: steps.expo-caches.outputs.yarn-workspace-hit != 'true'
94        run: yarn install --frozen-lockfile
95      - name: ��️ Debug CocoaPods lockfiles
96        run: git diff Podfile.lock Pods/Manifest.lock
97        working-directory: apps/bare-expo/ios
98        continue-on-error: true
99      - name: ⚛️ Display React Native config
100        run: yarn react-native config
101        working-directory: apps/bare-expo
102      - name: �� Display pod environment
103        run: pod env
104        working-directory: apps/bare-expo/ios
105      - name: �� Install pods in apps/bare-expo/ios
106        if: steps.expo-caches.outputs.ios-pods-hit != 'true'
107        run: pod install
108        working-directory: apps/bare-expo/ios
109      - name: �� Clean Detox
110        run: yarn detox:clean
111        working-directory: apps/bare-expo
112      - name: ��️ Build iOS project for Detox
113        run: yarn ios:detox:build:release
114        working-directory: apps/bare-expo
115        timeout-minutes: 30
116        env:
117          EXPO_DEBUG: 1
118          NODE_ENV: production
119      - name: Run tests
120        run: yarn ios:detox:test:release
121        working-directory: apps/bare-expo
122        env:
123          EXPO_DEBUG: 1
124          NODE_ENV: production
125      - name: Store images of build failures
126        if: always()
127        uses: actions/upload-artifact@v3
128        with:
129          name: bare-expo-artifacts
130          path: apps/bare-expo/artifacts
131      - name: �� Notify on Slack
132        uses: 8398a7/action-slack@v3
133        if: failure() && (github.event.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/heads/sdk-'))
134        env:
135          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
136          SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook_ios }}
137        with:
138          channel: '#expo-ios'
139          status: ${{ job.status }}
140          fields: job,message,ref,eventName,author,took
141          author_name: Test Suite (iOS)
142
143  android-build:
144    runs-on: ubuntu-22.04
145    env:
146      ORG_GRADLE_PROJECT_reactNativeArchitectures: x86_64
147      GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx4096m -XX:MaxMetaspaceSize=4096m"
148    steps:
149      - name: �� Checkout
150        uses: actions/checkout@v3
151        with:
152          submodules: true
153      - name: ⬢ Setup Node
154        uses: actions/setup-node@v3
155        with:
156          node-version: 16
157      - name: �� Use JDK 11
158        uses: actions/setup-java@v3
159        with:
160          distribution: 'temurin'
161          java-version: '11'
162      - name: ➕ Add `bin` to GITHUB_PATH
163        run: echo "$(pwd)/bin" >> $GITHUB_PATH
164      - name: ♻️ Restore caches
165        uses: ./.github/actions/expo-caches
166        id: expo-caches
167        with:
168          gradle: 'true'
169          yarn-workspace: 'true'
170          yarn-tools: 'true'
171          react-native-gradle-downloads: 'true'
172      - name: �� Install workspace node modules
173        if: steps.expo-caches.outputs.yarn-workspace-hit != 'true'
174        run: yarn install --frozen-lockfile
175      - name: ⚛️ Display React Native config
176        run: yarn react-native config
177        working-directory: apps/bare-expo
178      - name: ��️ Generate dynamic macros
179        run: expotools android-generate-dynamic-macros --configuration release --bare
180      - name: ��️ Build Android project
181        run: ./gradlew -DtestBuildType=release :app:assembleRelease :app:assembleAndroidTest --no-daemon
182        working-directory: apps/bare-expo/android
183        timeout-minutes: 35
184        env:
185          EXPO_DEBUG: 1
186          NODE_ENV: production
187      - name: �� Upload builds
188        uses: actions/upload-artifact@v3
189        with:
190          name: bare-expo-android-builds
191          path: apps/bare-expo/android/app/build/outputs/apk
192      - name: �� Notify on Slack
193        uses: 8398a7/action-slack@v3
194        if: failure() && (github.event.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/heads/sdk-'))
195        env:
196          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
197          SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook_android }}
198          MATRIX_CONTEXT: ${{ toJson(matrix) }}
199        with:
200          channel: '#expo-android'
201          status: ${{ job.status }}
202          fields: job,message,ref,eventName,author,took
203          author_name: Test Suite (Android)
204
205  android-test:
206    needs: android-build
207    runs-on: macos-13
208    strategy:
209      matrix:
210        api-level: [33]
211    steps:
212      - name: �� Checkout
213        uses: actions/checkout@v3
214      - name: �� Download builds
215        uses: actions/download-artifact@v3
216        with:
217          name: bare-expo-android-builds
218          path: apps/bare-expo/android/app/build/outputs/apk
219      - name: �� Run tests
220        uses: ./.github/actions/use-android-emulator
221        with:
222          avd-api: ${{ matrix.api-level }}
223          avd-name: avd-${{ matrix.api-level }}
224          script: |
225            mkdir artifacts || true
226            adb logcat -d > artifacts/emulator.log
227            adb logcat -c || true
228            adb shell screencap -p /data/local/tmp/bareexpo.png && adb pull /data/local/tmp/bareexpo.png artifacts/beforeTests.png
229            ./scripts/start-android-e2e-test.sh
230            adb shell screencap -p /data/local/tmp/bareexpo.png && adb pull /data/local/tmp/bareexpo.png artifacts/afterTests.png
231            adb logcat -d > artifacts/adb.log
232          working-directory: ./apps/bare-expo
233      - name: �� Store images of test failures
234        if: always()
235        uses: actions/upload-artifact@v3
236        with:
237          name: bare-expo-artifacts
238          path: apps/bare-expo/artifacts
239      - name: �� Notify on Slack
240        uses: 8398a7/action-slack@v3
241        if: failure() && (github.event.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/heads/sdk-'))
242        env:
243          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
244          SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook_android }}
245          MATRIX_CONTEXT: ${{ toJson(matrix) }}
246        with:
247          channel: '#expo-android'
248          status: ${{ job.status }}
249          fields: job,message,ref,eventName,author,took
250          author_name: Test Suite (Android)
251