From 100d68282e466735e6a19e8f4f1f03446431e083 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Fri, 12 Mar 2021 17:29:54 +0100 Subject: [PATCH 1/2] Add build WDA step in iOS e2e tests workflow --- .github/workflows/rnmobile-ios-runner.yml | 7 ++++++- .../__device-tests__/helpers/utils.js | 9 +++++++++ packages/react-native-editor/package.json | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rnmobile-ios-runner.yml b/.github/workflows/rnmobile-ios-runner.yml index 60b119ff1ee0c2..a8625c59b127bf 100644 --- a/.github/workflows/rnmobile-ios-runner.yml +++ b/.github/workflows/rnmobile-ios-runner.yml @@ -38,7 +38,9 @@ jobs: - name: Restore build cache uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 with: - path: packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app + path: | + packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app + packages/react-native-editor/ios/build/WDA key: ${{ runner.os }}-ios-build-${{ matrix.xcode }}-${{ hashFiles('ios-checksums.txt') }} - name: Restore pods cache @@ -65,6 +67,9 @@ jobs: - name: Build (if needed) run: test -e packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/GutenbergDemo || npm run native test:e2e:build-app:ios + - name: Build Web Driver Agent (if needed) + run: test -d packages/react-native-editor/ios/build/WDA || npm run native test:e2e:build-wda + - name: Run iOS Device Tests run: TEST_RN_PLATFORM=ios npm run native device-tests:local ${{ matrix.native-test-name }} diff --git a/packages/react-native-editor/__device-tests__/helpers/utils.js b/packages/react-native-editor/__device-tests__/helpers/utils.js index 8810756ee7a86b..84829a7aa2f4b3 100644 --- a/packages/react-native-editor/__device-tests__/helpers/utils.js +++ b/packages/react-native-editor/__device-tests__/helpers/utils.js @@ -22,12 +22,14 @@ const rnPlatform = process.env.TEST_RN_PLATFORM || defaultPlatform; // Environment setup, local environment or Sauce Labs const defaultEnvironment = 'local'; const testEnvironment = process.env.TEST_ENV || defaultEnvironment; +const isCI = process.env.CI; // Local App Paths const defaultAndroidAppPath = './android/app/build/outputs/apk/debug/app-debug.apk'; const defaultIOSAppPath = './ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app'; +const webDriverAgentPath = process.env.WDA_PATH || './ios/build/WDA'; const localAndroidAppPath = process.env.ANDROID_APP_PATH || defaultAndroidAppPath; @@ -140,6 +142,13 @@ const setupDriver = async () => { } desiredCaps.app = path.resolve( localIOSAppPath ); + + if ( isCI ) { + desiredCaps.usePrebuiltWDA = true; + desiredCaps.derivedDataPath = path.resolve( + webDriverAgentPath + ); + } } } diff --git a/packages/react-native-editor/package.json b/packages/react-native-editor/package.json index c6b2c8f4bd8afa..67233336010d34 100644 --- a/packages/react-native-editor/package.json +++ b/packages/react-native-editor/package.json @@ -113,6 +113,7 @@ "test:e2e:android:local": "npm run test:e2e:bundle:android && npm run test:e2e:build-app:android && TEST_RN_PLATFORM=android npm run device-tests:local", "test:e2e:bundle:ios": "mkdir -p ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app && npm run rn-bundle -- --reset-cache --platform=ios --dev=false --minify false --entry-file=index.js --bundle-output=./ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/main.jsbundle --assets-dest=./ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app", "test:e2e:build-app:ios": "npm run preios && SKIP_BUNDLING=true xcodebuild -workspace ios/GutenbergDemo.xcworkspace -configuration Release -scheme GutenbergDemo -destination 'platform=iOS Simulator,name=iPhone 11' -derivedDataPath ios/build/GutenbergDemo", + "test:e2e:build-wda": "SKIP_BUNDLING=true xcodebuild -project ../../node_modules/appium/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'platform=iOS Simulator,name=iPhone 11' -derivedDataPath ios/build/WDA", "test:e2e:ios:local": "npm run test:e2e:bundle:ios && npm run test:e2e:build-app:ios && TEST_RN_PLATFORM=ios npm run device-tests:local", "build:gutenberg": "cd gutenberg && npm ci && npm run build", "clean": "npm run clean:build-artifacts; npm run clean:aztec; npm run clean:haste; npm run clean:jest; npm run clean:metro; npm run clean:react; npm run clean:watchman", From f02b756a056b808e0a5e5509e190fe4aeb45e709 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Tue, 16 Mar 2021 10:23:07 +0100 Subject: [PATCH 2/2] Unify setup process of local and CI for e2e tests --- .../react-native-editor/__device-tests__/helpers/caps.js | 1 + .../__device-tests__/helpers/utils.js | 9 +-------- packages/react-native-editor/package.json | 4 ++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/react-native-editor/__device-tests__/helpers/caps.js b/packages/react-native-editor/__device-tests__/helpers/caps.js index a71916c83a6607..30f23cc2ffa5e6 100644 --- a/packages/react-native-editor/__device-tests__/helpers/caps.js +++ b/packages/react-native-editor/__device-tests__/helpers/caps.js @@ -15,6 +15,7 @@ exports.iosLocal = { ...ios, deviceName: 'iPhone 11', wdaLaunchTimeout: 240000, + usePrebuiltWDA: true, }; exports.iosServer = { diff --git a/packages/react-native-editor/__device-tests__/helpers/utils.js b/packages/react-native-editor/__device-tests__/helpers/utils.js index 84829a7aa2f4b3..eec48ba84a26b4 100644 --- a/packages/react-native-editor/__device-tests__/helpers/utils.js +++ b/packages/react-native-editor/__device-tests__/helpers/utils.js @@ -22,7 +22,6 @@ const rnPlatform = process.env.TEST_RN_PLATFORM || defaultPlatform; // Environment setup, local environment or Sauce Labs const defaultEnvironment = 'local'; const testEnvironment = process.env.TEST_ENV || defaultEnvironment; -const isCI = process.env.CI; // Local App Paths const defaultAndroidAppPath = @@ -142,13 +141,7 @@ const setupDriver = async () => { } desiredCaps.app = path.resolve( localIOSAppPath ); - - if ( isCI ) { - desiredCaps.usePrebuiltWDA = true; - desiredCaps.derivedDataPath = path.resolve( - webDriverAgentPath - ); - } + desiredCaps.derivedDataPath = path.resolve( webDriverAgentPath ); } } diff --git a/packages/react-native-editor/package.json b/packages/react-native-editor/package.json index 67233336010d34..400f853b5b4539 100644 --- a/packages/react-native-editor/package.json +++ b/packages/react-native-editor/package.json @@ -113,8 +113,8 @@ "test:e2e:android:local": "npm run test:e2e:bundle:android && npm run test:e2e:build-app:android && TEST_RN_PLATFORM=android npm run device-tests:local", "test:e2e:bundle:ios": "mkdir -p ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app && npm run rn-bundle -- --reset-cache --platform=ios --dev=false --minify false --entry-file=index.js --bundle-output=./ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/main.jsbundle --assets-dest=./ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app", "test:e2e:build-app:ios": "npm run preios && SKIP_BUNDLING=true xcodebuild -workspace ios/GutenbergDemo.xcworkspace -configuration Release -scheme GutenbergDemo -destination 'platform=iOS Simulator,name=iPhone 11' -derivedDataPath ios/build/GutenbergDemo", - "test:e2e:build-wda": "SKIP_BUNDLING=true xcodebuild -project ../../node_modules/appium/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'platform=iOS Simulator,name=iPhone 11' -derivedDataPath ios/build/WDA", - "test:e2e:ios:local": "npm run test:e2e:bundle:ios && npm run test:e2e:build-app:ios && TEST_RN_PLATFORM=ios npm run device-tests:local", + "test:e2e:build-wda": "xcodebuild -project ../../node_modules/appium/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'platform=iOS Simulator,name=iPhone 11' -derivedDataPath ios/build/WDA", + "test:e2e:ios:local": "npm run test:e2e:bundle:ios && npm run test:e2e:build-app:ios && npm run test:e2e:build-wda && TEST_RN_PLATFORM=ios npm run device-tests:local", "build:gutenberg": "cd gutenberg && npm ci && npm run build", "clean": "npm run clean:build-artifacts; npm run clean:aztec; npm run clean:haste; npm run clean:jest; npm run clean:metro; npm run clean:react; npm run clean:watchman", "clean:runtime": "npm run clean:haste; npm run clean:react; npm run clean:metro; npm run clean:jest; npm run clean:watchman; npm run clean:babel-cache",