Skip to content

Commit 765f943

Browse files
feat: Use prebuilt WDA package to speed up the CI pipeline (#2304)
1 parent 5813ac5 commit 765f943

File tree

9 files changed

+143
-11
lines changed

9 files changed

+143
-11
lines changed

.github/workflows/gradle.yml renamed to .github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ env:
2929
IOS_PLATFORM_VERSION: "17.5"
3030
FLUTTER_ANDROID_APP: "https://github.com/AppiumTestDistribution/appium-flutter-server/releases/latest/download/app-debug.apk"
3131
FLUTTER_IOS_APP: "https://github.com/AppiumTestDistribution/appium-flutter-server/releases/latest/download/ios.zip"
32+
PREBUILT_WDA_PATH: ${{ github.workspace }}/wda/WebDriverAgentRunner-Runner.app
3233

3334
jobs:
3435
build:
@@ -135,12 +136,14 @@ jobs:
135136
with:
136137
model: "${{ env.IOS_DEVICE_NAME }}"
137138
os_version: "${{ env.IOS_PLATFORM_VERSION }}"
139+
wait_for_boot: true
140+
shutdown_after_job: false
138141
- name: Install XCUITest driver
139142
if: matrix.e2e-tests == 'ios' || matrix.e2e-tests == 'flutter-ios'
140143
run: appium driver install xcuitest
141-
- name: Prebuild XCUITest driver
144+
- name: Download prebuilt WDA
142145
if: matrix.e2e-tests == 'ios' || matrix.e2e-tests == 'flutter-ios'
143-
run: appium driver run xcuitest build-wda --sdk=${{ env.IOS_PLATFORM_VERSION }} --name='${{ env.IOS_DEVICE_NAME }}'
146+
run: appium driver run xcuitest download-wda-sim --platform=ios --outdir=$(dirname "$PREBUILT_WDA_PATH")
144147
- name: Run iOS E2E tests
145148
if: matrix.e2e-tests == 'ios'
146149
run: ./gradlew e2eIosTest -PisCI -Pselenium.version=$latest_snapshot

src/e2eFlutterTest/java/io/appium/java_client/android/BaseFlutterTest.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class BaseFlutterTest {
3535
private static AppiumDriverLocalService service;
3636
protected static FlutterIntegrationTestDriver driver;
3737
protected static final By LOGIN_BUTTON = AppiumBy.flutterText("Login");
38+
private static String PREBUILT_WDA_PATH = System.getenv("PREBUILT_WDA_PATH");
3839

3940
/**
4041
* initialization.
@@ -74,15 +75,19 @@ void startSession() throws MalformedURLException {
7475
String platformVersion = System.getenv("IOS_PLATFORM_VERSION") != null
7576
? System.getenv("IOS_PLATFORM_VERSION")
7677
: "14.5";
77-
driver = new FlutterIOSDriver(service.getUrl(), flutterOptions
78-
.setXCUITestOptions(new XCUITestOptions()
79-
.setApp(System.getProperty("flutterApp"))
80-
.setDeviceName(deviceName)
81-
.setPlatformVersion(platformVersion)
82-
.setWdaLaunchTimeout(Duration.ofMinutes(4))
83-
.setSimulatorStartupTimeout(Duration.ofMinutes(5))
84-
.eventTimings()
85-
)
78+
XCUITestOptions xcuiTestOptions = new XCUITestOptions()
79+
.setApp(System.getProperty("flutterApp"))
80+
.setDeviceName(deviceName)
81+
.setPlatformVersion(platformVersion)
82+
.setWdaLaunchTimeout(Duration.ofMinutes(4))
83+
.setSimulatorStartupTimeout(Duration.ofMinutes(5))
84+
.eventTimings();
85+
if (PREBUILT_WDA_PATH != null) {
86+
xcuiTestOptions.usePreinstalledWda().setPrebuiltWdaPath(PREBUILT_WDA_PATH);
87+
}
88+
driver = new FlutterIOSDriver(
89+
service.getUrl(),
90+
flutterOptions.setXCUITestOptions(xcuiTestOptions)
8691
);
8792
}
8893
}

src/e2eIosTest/java/io/appium/java_client/ios/AppIOSTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public static void beforeClass() {
2323
.setApp(TEST_APP_ZIP)
2424
.enableBiDi()
2525
.setWdaLaunchTimeout(WDA_LAUNCH_TIMEOUT);
26+
if (PREBUILT_WDA_PATH != null) {
27+
options.usePreinstalledWda().setPrebuiltWdaPath(PREBUILT_WDA_PATH);
28+
}
2629
try {
2730
driver = new IOSDriver(service.getUrl(), options);
2831
} catch (SessionNotCreatedException e) {

src/e2eIosTest/java/io/appium/java_client/ios/BaseIOSTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public class BaseIOSTest {
3636
: "14.5";
3737
public static final Duration WDA_LAUNCH_TIMEOUT = Duration.ofMinutes(4);
3838
public static final Duration SERVER_START_TIMEOUT = Duration.ofMinutes(3);
39+
protected static String PREBUILT_WDA_PATH = System.getenv("PREBUILT_WDA_PATH");
40+
3941

4042
/**
4143
* Starts a local server.

src/e2eIosTest/java/io/appium/java_client/ios/BaseIOSWebViewTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public static void beforeClass() {
4040
.setWdaLaunchTimeout(WDA_LAUNCH_TIMEOUT)
4141
.setCommandTimeouts(Duration.ofSeconds(240))
4242
.setApp(VODQA_ZIP);
43+
if (PREBUILT_WDA_PATH != null) {
44+
options.usePreinstalledWda().setPrebuiltWdaPath(PREBUILT_WDA_PATH);
45+
}
4346
Supplier<IOSDriver> createDriver = () -> new IOSDriver(service.getUrl(), options);
4447
try {
4548
driver = createDriver.get();

src/e2eIosTest/java/io/appium/java_client/ios/BaseSafariTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public class BaseSafariTest extends BaseIOSTest {
3434
.setPlatformVersion(PLATFORM_VERSION)
3535
.setWebviewConnectTimeout(WEBVIEW_CONNECT_TIMEOUT)
3636
.setWdaLaunchTimeout(WDA_LAUNCH_TIMEOUT);
37+
if (PREBUILT_WDA_PATH != null) {
38+
options.usePreinstalledWda().setPrebuiltWdaPath(PREBUILT_WDA_PATH);
39+
}
3740
driver = new IOSDriver(service.getUrl(), options);
3841
}
3942
}

src/main/java/io/appium/java_client/ios/options/XCUITestOptions.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import io.appium.java_client.ios.options.wda.SupportsKeychainOptions;
5656
import io.appium.java_client.ios.options.wda.SupportsMaxTypingFrequencyOption;
5757
import io.appium.java_client.ios.options.wda.SupportsMjpegServerPortOption;
58+
import io.appium.java_client.ios.options.wda.SupportsPrebuiltWdaPathOption;
5859
import io.appium.java_client.ios.options.wda.SupportsProcessArgumentsOption;
5960
import io.appium.java_client.ios.options.wda.SupportsResultBundlePathOption;
6061
import io.appium.java_client.ios.options.wda.SupportsScreenshotQualityOption;
@@ -66,6 +67,7 @@
6667
import io.appium.java_client.ios.options.wda.SupportsUseNativeCachingStrategyOption;
6768
import io.appium.java_client.ios.options.wda.SupportsUseNewWdaOption;
6869
import io.appium.java_client.ios.options.wda.SupportsUsePrebuiltWdaOption;
70+
import io.appium.java_client.ios.options.wda.SupportsUsePreinstalledWdaOption;
6971
import io.appium.java_client.ios.options.wda.SupportsUseSimpleBuildTestOption;
7072
import io.appium.java_client.ios.options.wda.SupportsUseXctestrunFileOption;
7173
import io.appium.java_client.ios.options.wda.SupportsWaitForIdleTimeoutOption;
@@ -156,6 +158,8 @@ public class XCUITestOptions extends BaseOptions<XCUITestOptions> implements
156158
SupportsWdaBaseUrlOption<XCUITestOptions>,
157159
SupportsShowXcodeLogOption<XCUITestOptions>,
158160
SupportsUsePrebuiltWdaOption<XCUITestOptions>,
161+
SupportsUsePreinstalledWdaOption<XCUITestOptions>,
162+
SupportsPrebuiltWdaPathOption<XCUITestOptions>,
159163
SupportsShouldUseSingletonTestManagerOption<XCUITestOptions>,
160164
SupportsWaitForIdleTimeoutOption<XCUITestOptions>,
161165
SupportsUseXctestrunFileOption<XCUITestOptions>,
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.appium.java_client.ios.options.wda;
18+
19+
import io.appium.java_client.remote.options.BaseOptions;
20+
import io.appium.java_client.remote.options.CanSetCapability;
21+
import org.openqa.selenium.Capabilities;
22+
23+
import java.util.Optional;
24+
25+
public interface SupportsPrebuiltWdaPathOption<T extends BaseOptions<T>> extends
26+
Capabilities, CanSetCapability<T> {
27+
String PREBUILT_WDA_PATH_OPTION = "prebuiltWDAPath";
28+
29+
/**
30+
* The full path to the prebuilt WebDriverAgent-Runner application
31+
* package to be installed if appium:usePreinstalledWDA capability
32+
* is enabled. The package's bundle identifier could be customized via
33+
* appium:updatedWDABundleId capability.
34+
*
35+
* @param path The full path to the bundle .app file on the server file system.
36+
* @return self instance for chaining.
37+
*/
38+
default T setPrebuiltWdaPath(String path) {
39+
return amend(PREBUILT_WDA_PATH_OPTION, path);
40+
}
41+
42+
/**
43+
* Get prebuilt WebDriverAgent path.
44+
*
45+
* @return The full path to the bundle .app file on the server file system.
46+
*/
47+
default Optional<String> getPrebuiltWdaPath() {
48+
return Optional.ofNullable((String) getCapability(PREBUILT_WDA_PATH_OPTION));
49+
}
50+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.appium.java_client.ios.options.wda;
18+
19+
import io.appium.java_client.remote.options.BaseOptions;
20+
import io.appium.java_client.remote.options.CanSetCapability;
21+
import org.openqa.selenium.Capabilities;
22+
23+
import java.util.Optional;
24+
25+
import static io.appium.java_client.internal.CapabilityHelpers.toSafeBoolean;
26+
27+
public interface SupportsUsePreinstalledWdaOption<T extends BaseOptions<T>> extends
28+
Capabilities, CanSetCapability<T> {
29+
String USE_PREINSTALLED_WDA_OPTION = "usePreinstalledWDA";
30+
31+
/**
32+
* Whether to launch a preinstalled WebDriverAgentRunner application using a custom XCTest API client.
33+
*
34+
* @return self instance for chaining.
35+
*/
36+
default T usePreinstalledWda() {
37+
return amend(USE_PREINSTALLED_WDA_OPTION, true);
38+
}
39+
40+
/**
41+
* Whether to launch a preinstalled WebDriverAgentRunner application using a custom XCTest API client.
42+
* Defaults to false.
43+
*
44+
* @param value Either true or false.
45+
* @return self instance for chaining.
46+
*/
47+
default T setUsePreinstalledWda(boolean value) {
48+
return amend(USE_PREINSTALLED_WDA_OPTION, value);
49+
}
50+
51+
/**
52+
* Get whether to launch a preinstalled WebDriverAgentRunner application using a custom XCTest API client.
53+
*
54+
* @return True or false.
55+
*/
56+
default Optional<Boolean> doesUsePreinstalledWda() {
57+
return Optional.ofNullable(toSafeBoolean(getCapability(USE_PREINSTALLED_WDA_OPTION)));
58+
}
59+
}

0 commit comments

Comments
 (0)