Skip to content

Commit 07e0b52

Browse files
chore(ci): E2E RN Version Matrix (#2735)
1 parent c022e6f commit 07e0b52

23 files changed

+7135
-132
lines changed

.github/workflows/e2e.yml

Lines changed: 178 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
access_token: ${{ github.token }}
2323

24-
device-test:
24+
sample:
2525
# Android emulator said to perform best with macos HAXM
2626
runs-on: macos-latest
2727
strategy:
@@ -33,10 +33,6 @@ jobs:
3333
- platform: ios
3434
runtime: '16.0'
3535
device: 'iPhone 14'
36-
env:
37-
PLATFORM: ${{ matrix.platform }}
38-
RUNTIME: ${{ matrix.runtime }}
39-
DEVICE: ${{ matrix.device }}
4036
steps:
4137
- uses: actions/checkout@v3
4238

@@ -45,9 +41,6 @@ jobs:
4541
java-version: '11'
4642
distribution: 'adopt'
4743

48-
- name: Install Global Dependencies
49-
run: yarn global add @sentry/cli yalc
50-
5144
- name: NPM cache
5245
uses: actions/cache@v3
5346
id: deps-cache
@@ -74,28 +67,16 @@ jobs:
7467
- name: Build SDK
7568
run: yarn build
7669

77-
- name: Package SDK
78-
run: yalc publish
79-
80-
- name: Prepare sample for testing
81-
working-directory: ./sample
82-
run: sh ./scripts/prepareConfigsForTesting.sh
83-
84-
- name: Install SDK in sample
85-
working-directory: ./sample
86-
run: yalc add @sentry/react-native
87-
8870
- name: Install Sample Dependencies
8971
if: steps.deps-cache.outputs['cache-hit'] != 'true'
9072
working-directory: ./sample
9173
run: yarn install
9274

9375
- run: pod install
9476
if: ${{ matrix.platform == 'ios' }}
95-
working-directory: ./sample/ios
9677
env:
97-
# TEST env var is used in podfile to determine whether to include the sentry SDK from relative path or node_modules.
98-
TEST: true
78+
PRODUCTION: 1
79+
working-directory: ./sample/ios
9980

10081
- name: Build ${{ matrix.platform }} sample app
10182
if: env.SENTRY_AUTH_TOKEN != null
@@ -129,46 +110,6 @@ jobs:
129110
build
130111
fi
131112
132-
- name: Start Appium Server
133-
working-directory: ./sample
134-
run: yarn run appium --log-timestamp --log-no-colors --log appium.${{ matrix.platform }}.log &
135-
136-
# Wait until the Appium server starts.
137-
- name: Check Appium Server
138-
uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd # pin@v2
139-
with:
140-
timeout_seconds: 60
141-
max_attempts: 10
142-
command: curl --output /dev/null --silent --head --fail http://127.0.0.1:4723/sessions
143-
144-
- name: Run tests on Android
145-
if: ${{ matrix.platform == 'android' }}
146-
uses: reactivecircus/android-emulator-runner@50986b1464923454c95e261820bc626f38490ec0 # pin@v2
147-
with:
148-
api-level: 29
149-
emulator-options: -accel on -no-snapshot -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none -timezone US/Pacific
150-
working-directory: sample
151-
script: |
152-
# Collect logs
153-
adb logcat '*:D' 2>&1 >adb.log &
154-
adb devices -l
155-
156-
yarn test --verbose
157-
158-
- name: Run tests on iOS
159-
if: ${{ matrix.platform == 'ios' }}
160-
working-directory: ./sample
161-
run: yarn test --verbose
162-
163-
- name: Upload logs
164-
if: ${{ always() }}
165-
uses: actions/upload-artifact@v3
166-
with:
167-
name: ${{ matrix.platform }}-logs
168-
path: |
169-
./sample/*.log
170-
./sample/*.png
171-
172113
metrics:
173114
runs-on: macos-latest
174115
strategy:
@@ -325,13 +266,29 @@ jobs:
325266
path: node_modules
326267
key: ${{ github.workflow }}-${{ github.job }}-npm-${{ hashFiles('yarn.lock') }}
327268

269+
- name: NPM cache E2E Tests Library
270+
uses: actions/cache@v3
271+
id: deps-cache-e2e-library
272+
with:
273+
path: test/e2e/node_modules
274+
key: ${{ github.workflow }}-${{ github.job }}-npm-${{ hashFiles('test/e2e/yarn.lock') }}
275+
328276
- name: Install SDK JS Dependencies
329277
if: steps.deps-cache.outputs['cache-hit'] != 'true'
330278
run: yarn install
331279

280+
- name: Install E2E Tests Library JS Dependencies
281+
if: steps.deps-cache.outputs['deps-cache-e2e-library'] != 'true'
282+
working-directory: test/e2e
283+
run: yarn install
284+
332285
- name: Build SDK
333286
run: yarn build
334287

288+
- name: Build E2E Tests Library
289+
working-directory: test/e2e
290+
run: yarn build
291+
335292
- name: Package SDK
336293
run: yalc publish
337294

@@ -347,6 +304,10 @@ jobs:
347304
working-directory: test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp
348305
run: yarn install
349306

307+
- name: Add E2E Tests Library to App
308+
working-directory: test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp
309+
run: yarn add ../../../../e2e
310+
350311
- name: Install App Pods
351312
if: matrix.platform == 'ios'
352313
working-directory: test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp/ios
@@ -387,8 +348,8 @@ jobs:
387348
run: |
388349
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
389350
echo "Building $CONFIG"
351+
mkdir -p "DerivedData"
390352
derivedData="$(cd "DerivedData" ; pwd -P)"
391-
mkdir -p "$derivedData"
392353
xcodebuild \
393354
-workspace RnDiffApp.xcworkspace \
394355
-configuration "$CONFIG" \
@@ -398,3 +359,157 @@ jobs:
398359
-sdk 'iphonesimulator${{ matrix.runtime }}' \
399360
-derivedDataPath "$derivedData" \
400361
build
362+
363+
- name: Archive Android APK
364+
if: matrix.platform == 'android' && matrix.build-type == 'production'
365+
run: |
366+
BUILD_PATH=test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp/android/app/build/outputs/apk/release
367+
BUILD_NAME=app-release.apk
368+
tar -cvf apk.tar -C $BUILD_PATH $BUILD_NAME
369+
370+
- name: Archive iOS APP
371+
if: matrix.platform == 'ios' && matrix.build-type == 'production'
372+
run: |
373+
BUILD_PATH=test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp/ios/DerivedData/Build/Products/Release-iphonesimulator
374+
BUILD_NAME=RnDiffApp.app
375+
tar -cvf app.tar -C $BUILD_PATH $BUILD_NAME
376+
377+
- name: Upload App APK
378+
if: matrix.platform == 'android' && matrix.build-type == 'production'
379+
uses: actions/upload-artifact@v3
380+
with:
381+
name: ${{ matrix.rn-version }}-${{ matrix.rn-architecture }}-${{ matrix.platform }}-${{ matrix.build-type }}-app-package
382+
path: apk.tar
383+
retention-days: 1
384+
385+
- name: Upload App APP
386+
if: matrix.platform == 'ios' && matrix.build-type == 'production'
387+
uses: actions/upload-artifact@v3
388+
with:
389+
name: ${{ matrix.rn-version }}-${{ matrix.rn-architecture }}-${{ matrix.platform }}-${{ matrix.build-type }}-app-package
390+
path: app.tar
391+
retention-days: 1
392+
393+
react-native-test:
394+
name: Test RN ${{ matrix.rn-version }} ${{ matrix.rn-architecture }} ${{ matrix.platform }} ${{ matrix.build-type }}
395+
needs: react-native-build
396+
runs-on: macos-latest
397+
strategy:
398+
fail-fast: false # keeps matrix running if one fails
399+
matrix:
400+
rn-version: ['0.65.3', '0.70.6']
401+
rn-architecture: ['legacy', 'new']
402+
platform: ['android', 'ios']
403+
build-type: ['production']
404+
include:
405+
- platform: ios
406+
runtime: '16.0'
407+
device: 'iPhone 14'
408+
# exclude all rn versions lower than 0.70.0 for new architecture
409+
exclude:
410+
- rn-version: '0.65.3'
411+
rn-architecture: 'new'
412+
env:
413+
PLATFORM: ${{ matrix.platform }}
414+
RUNTIME: ${{ matrix.runtime }}
415+
DEVICE: ${{ matrix.device }}
416+
steps:
417+
- uses: actions/checkout@v3
418+
419+
- name: Download App Package
420+
if: matrix.build-type == 'production'
421+
uses: actions/download-artifact@v3
422+
with:
423+
name: ${{ matrix.rn-version }}-${{ matrix.rn-architecture }}-${{ matrix.platform }}-${{ matrix.build-type }}-app-package
424+
path: test/e2e
425+
426+
- name: Extract App Package
427+
working-directory: test/e2e
428+
run: tar -xvf *.tar
429+
430+
- uses: actions/setup-java@v3
431+
with:
432+
java-version: '11'
433+
distribution: 'adopt'
434+
435+
- name: NPM cache E2E Tests Library
436+
uses: actions/cache@v3
437+
id: deps-cache-e2e-library
438+
with:
439+
path: test/e2e/node_modules
440+
key: ${{ github.workflow }}-${{ github.job }}-npm-${{ hashFiles('test/e2e/yarn.lock') }}
441+
442+
- name: Install E2E Tests Library JS Dependencies
443+
if: steps.deps-cache.outputs['deps-cache-e2e-library'] != 'true'
444+
working-directory: test/e2e
445+
run: yarn install
446+
447+
- name: Build iOS WebDriverAgent
448+
if: matrix.platform == 'ios'
449+
working-directory: test/e2e
450+
run: |
451+
mkdir -p "DerivedData"
452+
derivedData="$(cd "DerivedData" ; pwd -P)"
453+
xcodebuild \
454+
-project node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj \
455+
-scheme WebDriverAgentRunner \
456+
GCC_TREAT_WARNINGS_AS_ERRORS=0 \
457+
COMPILER_INDEX_STORE_ENABLE=NO \
458+
-destination 'platform=iOS Simulator,name=${{ matrix.device }}' \
459+
ONLY_ACTIVE_ARCH=yes \
460+
-sdk 'iphonesimulator${{ matrix.runtime }}' \
461+
-derivedDataPath "$derivedData" \
462+
build
463+
464+
- name: Start Appium Server
465+
working-directory: test/e2e
466+
run: yarn run appium --log-timestamp --log-no-colors --log appium.${{ matrix.platform }}.log &
467+
468+
# Wait until the Appium server starts.
469+
- name: Check Appium Server
470+
uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd # pin@v2
471+
with:
472+
timeout_seconds: 60
473+
max_attempts: 10
474+
command: curl --output /dev/null --silent --head --fail http://127.0.0.1:4723/sessions
475+
476+
- name: Run tests on Android
477+
if: ${{ matrix.platform == 'android' }}
478+
env:
479+
APPIUM_APP: ./app-release.apk
480+
uses: reactivecircus/android-emulator-runner@50986b1464923454c95e261820bc626f38490ec0 # pin@v2
481+
with:
482+
working-directory: test/e2e
483+
api-level: 29
484+
emulator-options: >
485+
-accel on
486+
-no-snapshot
487+
-gpu swiftshader_indirect
488+
-noaudio
489+
-no-boot-anim
490+
-camera-back none
491+
-camera-front none
492+
-timezone US/Pacific
493+
script: |
494+
# Collect logs
495+
adb logcat '*:D' 2>&1 >adb.log &
496+
adb devices -l
497+
498+
yarn test --verbose
499+
500+
- name: Run tests on iOS
501+
if: ${{ matrix.platform == 'ios' }}
502+
working-directory: test/e2e
503+
env:
504+
APPIUM_APP: ./RnDiffApp.app
505+
APPIUM_DERIVED_DATA: DerivedData
506+
run: yarn test --verbose
507+
508+
- name: Upload logs
509+
if: ${{ always() }}
510+
uses: actions/upload-artifact@v3
511+
with:
512+
name: ${{ matrix.rn-version }}-${{ matrix.rn-architecture }}-${{ matrix.platform }}-${{ matrix.build-type }}-logs
513+
path: |
514+
test/e2e/*.log
515+
test/e2e/*.png

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@
9797
"js"
9898
],
9999
"testPathIgnorePatterns": [
100-
"<rootDir>/sample/"
100+
"<rootDir>/sample/",
101+
"<rootDir>/test/e2e/"
101102
],
102103
"testEnvironment": "node",
103104
"testMatch": [

sample/babel.config.test.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

sample/ios/Podfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ target 'sample' do
1818
:app_path => "#{Pod::Config.instance.installation_root}/.."
1919
)
2020

21-
if !ENV['TEST']
22-
pod 'RNSentry', :path => '../../RNSentry.podspec'
23-
end
21+
pod 'RNSentry', :path => '../../RNSentry.podspec'
2422

2523
target 'sampleTests' do
2624
inherit! :complete

sample/metro.config.test.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

sample/scripts/prepareConfigsForTesting.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

sample/src/App.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import HomeScreen from './screens/HomeScreen';
1313
import TrackerScreen from './screens/TrackerScreen';
1414
import ManualTrackerScreen from './screens/ManualTrackerScreen';
1515
import PerformanceTimingScreen from './screens/PerformanceTimingScreen';
16-
import EndToEndTestsScreen from './screens/EndToEndTestsScreen';
1716
import ReduxScreen from './screens/ReduxScreen';
1817

1918
import {store} from './reduxApp';
@@ -95,7 +94,6 @@ const App = () => {
9594
component={PerformanceTimingScreen}
9695
/>
9796
<Stack.Screen name="Redux" component={ReduxScreen} />
98-
<Stack.Screen name="EndToEndTests" component={EndToEndTestsScreen} />
9997
</Stack.Navigator>
10098
</NavigationContainer>
10199
</Provider>

src/js/tools/ModulesCollector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { posix, sep } from 'path';
44

55
logger.enable();
66

7+
// eslint-disable-next-line @typescript-eslint/unbound-method
78
const { dirname, join, resolve, sep: posixSep } = posix;
89

910
interface Package {

test/e2e/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.png
2+
*.log

0 commit comments

Comments
 (0)