Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): E2E RN Version Matrix #2735

Merged
merged 24 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6a108da
Extract e2e test to standalone library
krystofwoldrich Jan 6, 2023
1985df3
Add e2e lib to rn version patch
krystofwoldrich Jan 9, 2023
1c4aeaa
Update min rn build workflow min rn version
krystofwoldrich Jan 9, 2023
876255f
Add e2e lib to rn matrix build workflow
krystofwoldrich Jan 9, 2023
7570252
WIP! Add E2E Library ci job
krystofwoldrich Jan 9, 2023
5ecc370
First working version e2e rn matrix
krystofwoldrich Jan 9, 2023
0097d4a
Add missing rn tests needs rn build
krystofwoldrich Jan 9, 2023
9b7a253
Fix patch for rn 0.70.6
krystofwoldrich Jan 9, 2023
376c553
Fix downloaded artifacts paths
krystofwoldrich Jan 9, 2023
18974a0
Make appium app paths relative
krystofwoldrich Jan 9, 2023
98e6b1e
Add debug dir list test/e2e
krystofwoldrich Jan 9, 2023
76939b6
Remove duplicate app package download and move debug ls to the js dep…
krystofwoldrich Jan 9, 2023
71c23fd
Tar artifact to preserve the app folder and privileges
krystofwoldrich Jan 9, 2023
9a1a5d0
ignore e2e test in default test script
krystofwoldrich Jan 9, 2023
c25c2e4
Fix lint
krystofwoldrich Jan 9, 2023
34475da
Only create app package archive on production builds
krystofwoldrich Jan 9, 2023
51ee78a
Fix e2e test platform and runtime
krystofwoldrich Jan 10, 2023
99f255b
Fix e2e lint
krystofwoldrich Jan 10, 2023
cf7ec5d
Fix ios device env
krystofwoldrich Jan 10, 2023
e731d91
Fix platform env available globally in step
krystofwoldrich Jan 10, 2023
850da93
Remove e2e tests from sample
krystofwoldrich Jan 10, 2023
e77f792
Cleanup e2e ci job
krystofwoldrich Jan 10, 2023
ce24c18
Add git ignore to the e2e lib
krystofwoldrich Jan 10, 2023
29481d5
Merge branch '5.0.0' into e2e-tests-rn-matrix
krystofwoldrich Jan 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
241 changes: 178 additions & 63 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
access_token: ${{ github.token }}

device-test:
sample:
# Android emulator said to perform best with macos HAXM
runs-on: macos-latest
strategy:
Expand All @@ -33,10 +33,6 @@ jobs:
- platform: ios
runtime: '16.0'
device: 'iPhone 14'
env:
PLATFORM: ${{ matrix.platform }}
RUNTIME: ${{ matrix.runtime }}
DEVICE: ${{ matrix.device }}
steps:
- uses: actions/checkout@v3

Expand All @@ -45,9 +41,6 @@ jobs:
java-version: '11'
distribution: 'adopt'

- name: Install Global Dependencies
run: yarn global add @sentry/cli yalc

- name: NPM cache
uses: actions/cache@v3
id: deps-cache
Expand All @@ -74,28 +67,16 @@ jobs:
- name: Build SDK
run: yarn build

- name: Package SDK
run: yalc publish

- name: Prepare sample for testing
working-directory: ./sample
run: sh ./scripts/prepareConfigsForTesting.sh

- name: Install SDK in sample
working-directory: ./sample
run: yalc add @sentry/react-native

- name: Install Sample Dependencies
if: steps.deps-cache.outputs['cache-hit'] != 'true'
working-directory: ./sample
run: yarn install

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

- name: Build ${{ matrix.platform }} sample app
if: env.SENTRY_AUTH_TOKEN != null
Expand Down Expand Up @@ -129,46 +110,6 @@ jobs:
build
fi

- name: Start Appium Server
working-directory: ./sample
run: yarn run appium --log-timestamp --log-no-colors --log appium.${{ matrix.platform }}.log &

# Wait until the Appium server starts.
- name: Check Appium Server
uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd # pin@v2
with:
timeout_seconds: 60
max_attempts: 10
command: curl --output /dev/null --silent --head --fail http://127.0.0.1:4723/sessions

- name: Run tests on Android
if: ${{ matrix.platform == 'android' }}
uses: reactivecircus/android-emulator-runner@50986b1464923454c95e261820bc626f38490ec0 # pin@v2
with:
api-level: 29
emulator-options: -accel on -no-snapshot -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none -timezone US/Pacific
working-directory: sample
script: |
# Collect logs
adb logcat '*:D' 2>&1 >adb.log &
adb devices -l

yarn test --verbose

- name: Run tests on iOS
if: ${{ matrix.platform == 'ios' }}
working-directory: ./sample
run: yarn test --verbose

- name: Upload logs
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.platform }}-logs
path: |
./sample/*.log
./sample/*.png

metrics:
runs-on: macos-latest
strategy:
Expand Down Expand Up @@ -325,13 +266,29 @@ jobs:
path: node_modules
key: ${{ github.workflow }}-${{ github.job }}-npm-${{ hashFiles('yarn.lock') }}

- name: NPM cache E2E Tests Library
uses: actions/cache@v3
id: deps-cache-e2e-library
with:
path: test/e2e/node_modules
key: ${{ github.workflow }}-${{ github.job }}-npm-${{ hashFiles('test/e2e/yarn.lock') }}

- name: Install SDK JS Dependencies
if: steps.deps-cache.outputs['cache-hit'] != 'true'
run: yarn install

- name: Install E2E Tests Library JS Dependencies
if: steps.deps-cache.outputs['deps-cache-e2e-library'] != 'true'
working-directory: test/e2e
run: yarn install

- name: Build SDK
run: yarn build

- name: Build E2E Tests Library
working-directory: test/e2e
run: yarn build

- name: Package SDK
run: yalc publish

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

- name: Add E2E Tests Library to App
working-directory: test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp
run: yarn add ../../../../e2e

- name: Install App Pods
if: matrix.platform == 'ios'
working-directory: test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp/ios
Expand Down Expand Up @@ -387,8 +348,8 @@ jobs:
run: |
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
echo "Building $CONFIG"
mkdir -p "DerivedData"
derivedData="$(cd "DerivedData" ; pwd -P)"
krystofwoldrich marked this conversation as resolved.
Show resolved Hide resolved
mkdir -p "$derivedData"
xcodebuild \
-workspace RnDiffApp.xcworkspace \
-configuration "$CONFIG" \
Expand All @@ -398,3 +359,157 @@ jobs:
-sdk 'iphonesimulator${{ matrix.runtime }}' \
-derivedDataPath "$derivedData" \
build

- name: Archive Android APK
if: matrix.platform == 'android' && matrix.build-type == 'production'
run: |
BUILD_PATH=test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp/android/app/build/outputs/apk/release
BUILD_NAME=app-release.apk
tar -cvf apk.tar -C $BUILD_PATH $BUILD_NAME

- name: Archive iOS APP
if: matrix.platform == 'ios' && matrix.build-type == 'production'
run: |
BUILD_PATH=test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp/ios/DerivedData/Build/Products/Release-iphonesimulator
BUILD_NAME=RnDiffApp.app
tar -cvf app.tar -C $BUILD_PATH $BUILD_NAME

- name: Upload App APK
if: matrix.platform == 'android' && matrix.build-type == 'production'
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.rn-version }}-${{ matrix.rn-architecture }}-${{ matrix.platform }}-${{ matrix.build-type }}-app-package
path: apk.tar
retention-days: 1

- name: Upload App APP
if: matrix.platform == 'ios' && matrix.build-type == 'production'
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.rn-version }}-${{ matrix.rn-architecture }}-${{ matrix.platform }}-${{ matrix.build-type }}-app-package
path: app.tar
retention-days: 1

react-native-test:
name: Test RN ${{ matrix.rn-version }} ${{ matrix.rn-architecture }} ${{ matrix.platform }} ${{ matrix.build-type }}
needs: react-native-build
runs-on: macos-latest
strategy:
fail-fast: false # keeps matrix running if one fails
matrix:
rn-version: ['0.65.3', '0.70.6']
rn-architecture: ['legacy', 'new']
platform: ['android', 'ios']
build-type: ['production']
include:
- platform: ios
runtime: '16.0'
device: 'iPhone 14'
# exclude all rn versions lower than 0.70.0 for new architecture
exclude:
- rn-version: '0.65.3'
rn-architecture: 'new'
env:
PLATFORM: ${{ matrix.platform }}
RUNTIME: ${{ matrix.runtime }}
DEVICE: ${{ matrix.device }}
steps:
- uses: actions/checkout@v3

- name: Download App Package
if: matrix.build-type == 'production'
uses: actions/download-artifact@v3
with:
name: ${{ matrix.rn-version }}-${{ matrix.rn-architecture }}-${{ matrix.platform }}-${{ matrix.build-type }}-app-package
path: test/e2e

- name: Extract App Package
working-directory: test/e2e
run: tar -xvf *.tar

- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'

- name: NPM cache E2E Tests Library
uses: actions/cache@v3
id: deps-cache-e2e-library
with:
path: test/e2e/node_modules
key: ${{ github.workflow }}-${{ github.job }}-npm-${{ hashFiles('test/e2e/yarn.lock') }}

- name: Install E2E Tests Library JS Dependencies
if: steps.deps-cache.outputs['deps-cache-e2e-library'] != 'true'
working-directory: test/e2e
run: yarn install

- name: Build iOS WebDriverAgent
if: matrix.platform == 'ios'
working-directory: test/e2e
run: |
mkdir -p "DerivedData"
derivedData="$(cd "DerivedData" ; pwd -P)"
xcodebuild \
-project node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj \
-scheme WebDriverAgentRunner \
GCC_TREAT_WARNINGS_AS_ERRORS=0 \
COMPILER_INDEX_STORE_ENABLE=NO \
-destination 'platform=iOS Simulator,name=${{ matrix.device }}' \
ONLY_ACTIVE_ARCH=yes \
-sdk 'iphonesimulator${{ matrix.runtime }}' \
-derivedDataPath "$derivedData" \
build

- name: Start Appium Server
working-directory: test/e2e
run: yarn run appium --log-timestamp --log-no-colors --log appium.${{ matrix.platform }}.log &

# Wait until the Appium server starts.
- name: Check Appium Server
uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd # pin@v2
with:
timeout_seconds: 60
max_attempts: 10
command: curl --output /dev/null --silent --head --fail http://127.0.0.1:4723/sessions

- name: Run tests on Android
if: ${{ matrix.platform == 'android' }}
env:
APPIUM_APP: ./app-release.apk
uses: reactivecircus/android-emulator-runner@50986b1464923454c95e261820bc626f38490ec0 # pin@v2
with:
working-directory: test/e2e
api-level: 29
emulator-options: >
-accel on
-no-snapshot
-gpu swiftshader_indirect
-noaudio
-no-boot-anim
-camera-back none
-camera-front none
-timezone US/Pacific
script: |
# Collect logs
adb logcat '*:D' 2>&1 >adb.log &
adb devices -l

yarn test --verbose

- name: Run tests on iOS
if: ${{ matrix.platform == 'ios' }}
working-directory: test/e2e
env:
APPIUM_APP: ./RnDiffApp.app
APPIUM_DERIVED_DATA: DerivedData
run: yarn test --verbose

- name: Upload logs
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.rn-version }}-${{ matrix.rn-architecture }}-${{ matrix.platform }}-${{ matrix.build-type }}-logs
path: |
test/e2e/*.log
test/e2e/*.png
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@
"js"
],
"testPathIgnorePatterns": [
"<rootDir>/sample/"
"<rootDir>/sample/",
"<rootDir>/test/e2e/"
],
"testEnvironment": "node",
"testMatch": [
Expand Down
3 changes: 0 additions & 3 deletions sample/babel.config.test.js

This file was deleted.

4 changes: 1 addition & 3 deletions sample/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ target 'sample' do
:app_path => "#{Pod::Config.instance.installation_root}/.."
)

if !ENV['TEST']
pod 'RNSentry', :path => '../../RNSentry.podspec'
end
pod 'RNSentry', :path => '../../RNSentry.podspec'

target 'sampleTests' do
inherit! :complete
Expand Down
15 changes: 0 additions & 15 deletions sample/metro.config.test.js

This file was deleted.

4 changes: 0 additions & 4 deletions sample/scripts/prepareConfigsForTesting.sh

This file was deleted.

2 changes: 0 additions & 2 deletions sample/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import HomeScreen from './screens/HomeScreen';
import TrackerScreen from './screens/TrackerScreen';
import ManualTrackerScreen from './screens/ManualTrackerScreen';
import PerformanceTimingScreen from './screens/PerformanceTimingScreen';
import EndToEndTestsScreen from './screens/EndToEndTestsScreen';
import ReduxScreen from './screens/ReduxScreen';

import {store} from './reduxApp';
Expand Down Expand Up @@ -95,7 +94,6 @@ const App = () => {
component={PerformanceTimingScreen}
/>
<Stack.Screen name="Redux" component={ReduxScreen} />
<Stack.Screen name="EndToEndTests" component={EndToEndTestsScreen} />
</Stack.Navigator>
</NavigationContainer>
</Provider>
Expand Down
1 change: 1 addition & 0 deletions src/js/tools/ModulesCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { posix, sep } from 'path';

logger.enable();

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

interface Package {
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.png
*.log
Loading