Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7c0c7f8

Browse files
author
nturgut
committed
changing directory to use chrome driver in LUCI
1 parent 09b9329 commit 7c0c7f8

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

lib/web_ui/dev/driver_manager.dart

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,29 @@ import 'utils.dart';
2020
///
2121
/// This manager can be used for both macOS and Linux.
2222
class ChromeDriverManager extends DriverManager {
23-
ChromeDriverManager(String browser) : super(browser);
23+
24+
/// Directory which contains the preferred version of Chrome.
25+
///
26+
/// On LUCI we are using the CIPD packages to control Chrome binaries we use.
27+
/// There will be multiple CIPD packages loaded at the same time. Yaml file
28+
/// `driver_version.yaml` contains the version number we want to use.
29+
///
30+
/// Local integration tests are still using the system Chrome. This should be
31+
/// fixed in issue: https://github.com/flutter/flutter/issues/53179.
32+
///
33+
/// Initialized to the current first to avoid the `Non-nullable` error.
34+
io.Directory _browserDriverDirWithVersion = io.Directory.current;
35+
36+
ChromeDriverManager(String browser) : super(browser) {
37+
final io.File lockFile = io.File(pathlib.join(
38+
environment.webUiRootDir.path, 'dev', 'driver_version.yaml'));
39+
YamlMap _configuration = loadYaml(lockFile.readAsStringSync()) as YamlMap;
40+
final String preferredChromeDriverVersion =
41+
_configuration['preferred_version']['chrome'] as String;
42+
print('preferred_version $preferredChromeDriverVersion');
43+
_browserDriverDirWithVersion = io.Directory(
44+
pathlib.join(_browserDriverDir.path, preferredChromeDriverVersion));
45+
}
2446

2547
@override
2648
Future<void> _installDriver() async {
@@ -50,17 +72,19 @@ class ChromeDriverManager extends DriverManager {
5072
/// Driver should already exist on LUCI as a CIPD package.
5173
@override
5274
Future<void> _verifyDriverForLUCI() {
53-
if (!_browserDriverDir.existsSync()) {
75+
if (!_browserDriverDirWithVersion.existsSync()) {
5476
throw StateError('Failed to locate Chrome driver on LUCI on path:'
55-
'${_browserDriverDir.path}');
77+
'${_browserDriverDirWithVersion.path}');
5678
}
5779
return Future<void>.value();
5880
}
5981

6082
@override
61-
Future<void> _startDriver(String driverPath) async {
83+
Future<void> _startDriver() async {
6284
await startProcess('./chromedriver/chromedriver', ['--port=4444'],
63-
workingDirectory: driverPath);
85+
workingDirectory: isLuci
86+
? _browserDriverDirWithVersion.path
87+
: _browserDriverDir.path);
6488
print('INFO: Driver started');
6589
}
6690
}
@@ -106,9 +130,9 @@ class FirefoxDriverManager extends DriverManager {
106130
}
107131

108132
@override
109-
Future<void> _startDriver(String driverPath) async {
133+
Future<void> _startDriver() async {
110134
await startProcess('./firefoxdriver/geckodriver', ['--port=4444'],
111-
workingDirectory: driverPath);
135+
workingDirectory: _browserDriverDir.path);
112136
print('INFO: Driver started');
113137
}
114138

@@ -144,7 +168,7 @@ class SafariDriverManager extends DriverManager {
144168
}
145169

146170
@override
147-
Future<void> _startDriver(String driverPath) async {
171+
Future<void> _startDriver() async {
148172
final SafariDriverRunner safariDriverRunner = SafariDriverRunner();
149173

150174
final io.Process process =
@@ -184,7 +208,7 @@ abstract class DriverManager {
184208
} else {
185209
await _verifyDriverForLUCI();
186210
}
187-
await _startDriver(_browserDriverDir.path);
211+
await _startDriver();
188212
}
189213

190214
/// Always re-install since driver can change frequently.
@@ -198,7 +222,7 @@ abstract class DriverManager {
198222
Future<void> _verifyDriverForLUCI();
199223

200224
@protected
201-
Future<void> _startDriver(String driverPath);
225+
Future<void> _startDriver();
202226

203227
static DriverManager chooseDriver(String browser) {
204228
if (browser == 'chrome') {

lib/web_ui/dev/driver_version.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
1+
## Version to be picked by this PR. The LUCI will have multiple cipd packages
2+
## insalled in the recipe at the same time.
3+
## This mapping will be used to switch between them.
4+
preferred_version:
5+
## Make sure the major version of the binary in `browser_driver.yaml` is the
6+
## same for Chrome.
7+
chrome: '84'
28
## Map for driver versions to use for each browser version.
39
## See: https://chromedriver.chromium.org/downloads
410
chrome:

0 commit comments

Comments
 (0)