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

test: refactor e2e test to a script from yaml #3982

Merged
merged 49 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
fe7ab45
wip: extract e2e test script from yaml
vaind Jul 25, 2024
a393435
update e2e test script
vaind Jul 27, 2024
5c13f0d
move more stuff to e2e.js
vaind Jul 27, 2024
a477d6e
script args
vaind Jul 27, 2024
fc61db5
more stuff moved to e2e.js
vaind Jul 27, 2024
857e6a8
run tests from e2e script
vaind Jul 30, 2024
53e825f
remove e2e build from ci
vaind Jul 30, 2024
dd8abf5
fix ruby/setup-ruby
vaind Jul 30, 2024
b0a2ca2
update actions
vaind Jul 30, 2024
273a376
more script fixes
vaind Jul 30, 2024
7b7a0c2
fixup script on CI
vaind Jul 30, 2024
e368e4a
cleanup
vaind Jul 30, 2024
fd4c50a
fix CI
vaind Jul 30, 2024
b6601a3
fix CI
vaind Jul 30, 2024
655300d
linter issues
vaind Jul 31, 2024
2dc8ebc
Merge branch 'main' into test/e2e-refactor
vaind Jul 31, 2024
3f65502
post-merge script update
vaind Jul 31, 2024
6e94861
Update scripts/e2e.mjs
vaind Jul 31, 2024
612813d
Update scripts/e2e.mjs
vaind Jul 31, 2024
85e6afb
Update scripts/e2e.mjs
vaind Jul 31, 2024
efd1f9a
Update scripts/e2e.mjs
vaind Jul 31, 2024
883f9fb
cleanup
vaind Jul 31, 2024
5701c7c
move webdriveragent build to test
vaind Jul 31, 2024
030049d
cache webdriveragent build
vaind Jul 31, 2024
1739957
Merge branch 'main' into test/e2e-refactor
vaind Jul 31, 2024
d0b1f42
use bundler
vaind Jul 31, 2024
8becfea
Update e2e.yml
vaind Jul 31, 2024
b26695b
fix e2e test run
vaind Jul 31, 2024
009864d
try to fix ci
vaind Jul 31, 2024
d2cd560
Update e2e.yml
vaind Jul 31, 2024
0442bfa
fixes
vaind Jul 31, 2024
35b1c9e
try to remove node module removal
vaind Jul 31, 2024
883b36a
fix caching
vaind Jul 31, 2024
80b5fa4
Revert "try to remove node module removal"
vaind Jul 31, 2024
991927e
fix e2e.yml cache config
vaind Jul 31, 2024
a31ca9a
fix appium invocation
vaind Jul 31, 2024
459e842
handle child processes gracefully
vaind Aug 1, 2024
6c1bb2c
try to fix android test hangs
vaind Aug 1, 2024
11c1692
try to fix ci
vaind Aug 1, 2024
d742a85
tmp: debug session
vaind Aug 1, 2024
f1140fa
tmp killall
vaind Aug 1, 2024
082406e
fix android ci
vaind Aug 1, 2024
5ddfeb9
roll back unintended changes
vaind Aug 1, 2024
92fa628
fix hanging CI
vaind Aug 1, 2024
f554613
ensure node_modules from root are not resolved during e2e test app build
vaind Aug 1, 2024
6074dae
Merge branch 'main' into test/e2e-refactor
vaind Aug 1, 2024
03a948c
Merge branch 'main' into test/e2e-refactor
vaind Aug 5, 2024
6e1ddc3
Merge branch 'main' into test/e2e-refactor
vaind Aug 8, 2024
bdbee2a
Merge branch 'main' into test/e2e-refactor
vaind Aug 9, 2024
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
225 changes: 25 additions & 200 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,13 @@ jobs:
needs: [diff_check]
if: ${{ needs.diff_check.outputs.skip_ci != 'true' }}
env:
SENTRY_DISABLE_AUTO_UPLOAD: 'true' # TODO: Remove this when testing against a mocked Sentry server
RN_SENTRY_POD_NAME: RNSentry
RN_DIFF_REPOSITORY: https://github.com/react-native-community/rn-diff-purge.git
RN_VERSION: ${{ matrix.rn-version }}
RN_ENGINE: ${{ matrix.engine }}
USE_FRAMEWORKS: ${{ matrix.ios-use-frameworks }}
PRODUCTION: ${{ matrix.build-type == 'production' && '1' || '0' }}
RCT_NEW_ARCH_ENABLED: ${{ matrix.rn-architecture == 'new' && '1' || '0' }}
IOS_RUNTIME: ${{ matrix.runtime }}
IOS_DEVICE: ${{ matrix.device }}
strategy:
fail-fast: false # keeps matrix running if one fails
matrix:
Expand Down Expand Up @@ -240,15 +244,8 @@ jobs:
node-version: 18

- uses: actions/setup-java@v4
if: ${{ matrix.rn-version == '0.65.3' }}
with:
java-version: '11'
distribution: 'adopt'

- uses: actions/setup-java@v4
if: ${{ matrix.rn-version != '0.65.3' }}
with:
java-version: '17'
java-version: ${{ matrix.rn-version == '0.65.3' && '11' || '17' }}
vaind marked this conversation as resolved.
Show resolved Hide resolved
distribution: 'adopt'

- name: Gradle cache
Expand Down Expand Up @@ -277,56 +274,21 @@ jobs:
key: ${{ github.workflow }}-${{ github.job }}-npm-${{ hashFiles('test/e2e/yarn.lock') }}

- name: Install SDK JS Dependencies
if: ${{ steps.deps-cache.outputs['cache-hit'] != 'true' }}
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'
if: steps.deps-cache-e2e-library.outputs['cache-hit'] != '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

- uses: actions/setup-node@v4
if: ${{ matrix.rn-version == '0.65.3' }}
with:
node-version: 16

- name: Download Plain RN ${{ matrix.rn-version }} App
working-directory: test/react-native/versions
run: git clone $RN_DIFF_REPOSITORY --branch release/${{ matrix.rn-version }} --single-branch ${{ matrix.rn-version }}

- name: Add SDK to App
working-directory: test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp
run: yalc add @sentry/react-native

- name: Install App JS Dependencies (yarn v1)
working-directory: test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp
if: ${{ matrix.rn-version != '0.73.9' }}
run: |
yarn install

- name: Install App JS Dependencies (yarn v3)
working-directory: test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp
if: ${{ matrix.rn-version == '0.73.9' }}
run: |
rm -f .yarnrc.yml # original yarnrc contains the exact yarn version which causes corepack to fail to install yarn v3
echo "nodeLinker: node-modules" > .yarnrc.yml # RN build script require dependencies to be present in node_modules
touch yarn.lock # yarn v3 won't install dependencies in a sub project without a yarn.lock file present
export YARN_ENABLE_IMMUTABLE_INSTALLS=false # yarn v3 run immutable install by default in CI
yarn install

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

- uses: ruby/setup-ruby@v1
if: ${{ matrix.platform == 'ios' }}
Expand All @@ -335,113 +297,16 @@ jobs:
ruby-version: '3.3.0' # based on what is used in the sample
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
cache-version: 1 # cache the installed gems
- run: gem install cocoapods -v 1.15.2 # fixes Hermes pod install https://github.com/CocoaPods/CocoaPods/issues/12226#issuecomment-1930604302
working-directory: test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp
if: ${{ matrix.platform == 'ios' }}

- name: Install App Pods
if: ${{ matrix.platform == 'ios' }}
working-directory: test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp/ios
run: |
../../../../rn.patch.podfile.js --pod-file Podfile --engine ${{ matrix.engine }}
export NO_FLIPPER=1 # Flipper is causing build issues on iOS, so we disable it
[[ "${{ matrix.ios-use-frameworks }}" == "static" ]] && export USE_FRAMEWORKS=static
[[ "${{ matrix.ios-use-frameworks }}" == "dynamic" ]] && export USE_FRAMEWORKS=dynamic
[[ "${{ matrix.build-type }}" == "production" ]] && ENABLE_PROD=1 || ENABLE_PROD=0
[[ "${{ matrix.rn-architecture }}" == "new" ]] && ENABLE_NEW_ARCH=1 || ENABLE_NEW_ARCH=0
[[ "${{ matrix.rn-version }}" == "0.65.3" ]] && POD_INSTALL_COMMNAND="pod install" || POD_INSTALL_COMMNAND="bundle exec pod install"
echo "ENABLE_PROD=$ENABLE_PROD"
echo "ENABLE_NEW_ARCH=$ENABLE_NEW_ARCH"
echo "USE_FRAMEWORKS=$USE_FRAMEWORKS"
PRODUCTION=$ENABLE_PROD RCT_NEW_ARCH_ENABLED=$ENABLE_NEW_ARCH $POD_INSTALL_COMMNAND
cat Podfile.lock | grep $RN_SENTRY_POD_NAME

- name: Patch App RN
working-directory: test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp
run: |
patch --verbose --strip=0 --force --ignore-whitespace --fuzz 4 < ../../../rn.patch
../../../rn.patch.app.js --app .
../../../rn.patch.metro.config.js --path metro.config.js

- name: Patch Android App RN
if: ${{ matrix.platform == 'android' }}
working-directory: test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp
run: |
../../../rn.patch.gradle.properties.js --gradle-properties android/gradle.properties --engine ${{ matrix.engine }}
../../../rn.patch.app.build.gradle.js --app-build-gradle android/app/build.gradle

- name: Patch iOS App RN
if: ${{ matrix.platform == 'ios' }}
working-directory: test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp
run: |
../../../rn.patch.xcode.js \
--project ios/RnDiffApp.xcodeproj/project.pbxproj \
--rn-version '${{ matrix.rn-version }}'

# This prevents modules resolution from outside of the RN Test App projects
# during the native app build
- name: Clean SDK node_modules
run: rm -rf node_modules
- name: Build Plain RN ${{ matrix.rn-version }} App
run: ./scripts/e2e.mjs ${{ matrix.platform }} --build

- name: Build Android App
if: ${{ matrix.platform == 'android' }}
working-directory: test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp/android
run: |
if [[ ${{ matrix.rn-architecture }} == 'new' ]]; then
perl -i -pe's/newArchEnabled=false/newArchEnabled=true/g' gradle.properties
echo 'New Architecture enabled'
fi
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
echo "Building $CONFIG"
./gradlew ":app:assemble$CONFIG" -PreactNativeArchitectures=x86

- name: Build iOS App
if: ${{ matrix.platform == 'ios' }}
working-directory: test/react-native/versions/${{ matrix.rn-version }}/RnDiffApp/ios
run: |
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
echo "Building $CONFIG"
mkdir -p "DerivedData"
derivedData="$(cd "DerivedData" ; pwd -P)"
set -o pipefail && xcodebuild \
-workspace RnDiffApp.xcworkspace \
-configuration "$CONFIG" \
-scheme RnDiffApp \
-destination 'platform=iOS Simulator,OS=${{ matrix.runtime }},name=${{ matrix.device }}' \
ONLY_ACTIVE_ARCH=yes \
-derivedDataPath "$derivedData" \
build \
| tee xcodebuild.log \
| xcbeautify --quieter --is-ci --disable-colored-output

- 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@v4
with:
name: ${{ matrix.rn-version }}-${{ matrix.rn-architecture }}-${{ matrix.engine }}-${{ matrix.platform }}-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks }}-app-package
path: apk.tar
retention-days: 1

- name: Upload App APP
if: matrix.platform == 'ios' && matrix.build-type == 'production'
- name: Upload App
if: matrix.build-type == 'production'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.rn-version }}-${{ matrix.rn-architecture }}-${{ matrix.engine }}-${{ matrix.platform }}-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks }}-app-package
path: app.tar
path: test/e2e/RnDiffApp.ap*
vaind marked this conversation as resolved.
Show resolved Hide resolved
retention-days: 1

- name: Upload logs
Expand Down Expand Up @@ -511,10 +376,6 @@ jobs:
name: ${{ matrix.rn-version }}-${{ matrix.rn-architecture }}-${{ matrix.engine }}-${{ matrix.platform }}-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks }}-app-package
path: test/e2e

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

- uses: actions/setup-node@v4
with:
node-version: 20
Expand Down Expand Up @@ -547,47 +408,14 @@ jobs:
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'
if: steps.deps-cache-e2e-library.outputs['cache-hit'] != '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)"
set -o pipefail && 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,OS=${{ matrix.runtime }},name=${{ matrix.device }}' \
ONLY_ACTIVE_ARCH=yes \
-derivedDataPath "$derivedData" \
build \
| tee xcodebuild.log \
| xcbeautify --quieter --is-ci --disable-colored-output

- 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@7152eba30c6575329ac0576536151aca5a72780e # [email protected]
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@77986be26589807b8ebab3fde7bbf5c60dabec32 # [email protected]
with:
working-directory: test/e2e
api-level: 30
force-avd-creation: false
disable-animations: true
Expand All @@ -603,20 +431,17 @@ jobs:
-camera-back none
-camera-front none
-timezone US/Pacific
script: |
# Collect logs
adb logcat '*:D' 2>&1 >adb.log &
adb devices -l
script: ./scripts/e2e.mjs ${{ matrix.platform }} --test

yarn test --verbose
- uses: actions/cache@v4
if: ${{ matrix.platform == 'ios' }}
with:
path: test/e2e/DerivedData/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app
key: appium-webdriveragent-${{ hashFiles('test/e2e/yarn.lock') }}

- 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
run: ./scripts/e2e.mjs ${{ matrix.platform }} --test

- name: Upload logs
if: ${{ always() }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ yalc.lock

# E2E tests
test/react-native/versions
node_modules.bak

# Created by Sentry Metro Plugin
.sentry/
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"editor.formatOnSave": true,
"editor.rulers": [120],
"editor.tabSize": 2,
"files.autoSave": "onWindowChange",
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"search.exclude": {
Expand Down
Loading
Loading