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

[RNMobile] Cache the Web Driver Agent in iOS e2e tests workflow #29831

Merged
merged 2 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
7 changes: 6 additions & 1 deletion .github/workflows/rnmobile-ios-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -140,6 +142,13 @@ const setupDriver = async () => {
}

desiredCaps.app = path.resolve( localIOSAppPath );

if ( isCI ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having another code path just for local CI could further complicate things. WDYT about adding test:e2e:build-wda in test:e2e:ios:local as an additional step and removing the check for CI so both local and CI runs stay the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference between local and CI regarding the command test:e2e:build-wda is that for CI the WDA cache gets invalidated with the build cache key so if there's any changes in the native side, the WDA is rebuilt but this won't happen for local. This could produce an error if you change for example the Xcode version without deleting the derived data folder ios/build/WDA.

For local, my idea was to let Appium decide when the WDA should be rebuilt, that's why we have another code path but I'd be happy to figure out a different approach.

Copy link
Member

@ceyhun ceyhun Mar 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we put test:e2e:build-wda inside test:e2e:ios:local it should also always rebuild WDA when ran locally, right? We can add a rm -rf ios/build/WDA in test:e2e:build-wda to be safe, but it seems to me that it's the same case for building with test:e2e:build-app:ios locally and I don't think it produces an error, so maybe even the rm -rf isn't necessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note here if we go the rm -rf ios/build/WDA to utilize https://www.npmjs.com/package/rimraf for cross-platform compatibility. If it's not needed here then please do ignore 🙇🏾

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we put test:e2e:build-wda inside test:e2e:ios:local it should also always rebuild WDA when ran locally, right? We can add a rm -rf ios/build/WDA in test:e2e:build-wda to be safe, but it seems to me that it's the same case for building with test:e2e:build-app:ios locally and I don't think it produces an error, so maybe even the rm -rf isn't necessary.

Yeah you're right, we can run the command test:e2e:build-wda when running test:e2e:ios:local. I thought that the workflow was running test:e2e:ios:local but it's not, sorry for the misleading. Since this command is only run locally, it makes sense to also build the WDA. This would also require to pass the WDA derived data folder as an environment variable when running it from Gutenberg-mobile, as we do with the app’s path but nothing else.

Regarding removing the derived data folder, I'm going to check it but most likely it won't be necessary.

Thanks for the feedback @ceyhun and @jd-alexander 🙇 !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I applied the changes from these comments in this commit. I'm going to open a Gutenberg-mobile PR with the required changes to run the e2e tests there too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the PR in Gutenberg-mobile related to these changes, @ceyhun and @jd-alexander I've assigned you as reviewers there too.

desiredCaps.usePrebuiltWDA = true;
desiredCaps.derivedDataPath = path.resolve(
webDriverAgentPath
);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/react-native-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
fluiddot marked this conversation as resolved.
Show resolved Hide resolved
"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",
Expand Down