From 25ce811c0b67d3426943fa7a85e9b9f8f3820a8d Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Thu, 17 Nov 2022 10:42:11 -0800 Subject: [PATCH 1/5] Check for cached browsers on LUCI --- lib/web_ui/dev/chrome_installer.dart | 12 ++++++++++++ lib/web_ui/dev/firefox.dart | 5 ++--- lib/web_ui/dev/firefox_installer.dart | 12 ++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lib/web_ui/dev/chrome_installer.dart b/lib/web_ui/dev/chrome_installer.dart index dd3cafec47aed..206dd383a2875 100644 --- a/lib/web_ui/dev/chrome_installer.dart +++ b/lib/web_ui/dev/chrome_installer.dart @@ -15,6 +15,8 @@ import 'common.dart'; import 'environment.dart'; import 'exceptions.dart'; +const String _chromeExecutableVar = 'CHROME_EXECUTABLE'; + /// Returns the installation of Chrome, installing it if necessary. /// /// If [requestedVersion] is null, uses the version specified on the @@ -33,6 +35,16 @@ Future getOrInstallChrome( }) async { infoLog ??= io.stdout; + // When running on LUCI, if we specify the "chrome_and_driver" dependency, + // then the bot will download Chrome from CIPD and place it in a cache and + // set the environment variable CHROME_EXECUTABLE. + if (io.Platform.environment.containsKey(_chromeExecutableVar)) { + return BrowserInstallation( + version: 'cipd', + executable: io.Platform.environment[_chromeExecutableVar]!, + ); + } + if (requestedVersion == 'system') { return BrowserInstallation( version: 'system', diff --git a/lib/web_ui/dev/firefox.dart b/lib/web_ui/dev/firefox.dart index 57893c7bcbc4b..3b9caa8ad59b7 100644 --- a/lib/web_ui/dev/firefox.dart +++ b/lib/web_ui/dev/firefox.dart @@ -22,7 +22,7 @@ class FirefoxEnvironment implements BrowserEnvironment { @override Future launchBrowserInstance(Uri url, {bool debug = false}) async { - return Firefox(url, this, debug: debug); + return Firefox(url, _installation, debug: debug); } @override @@ -56,8 +56,7 @@ class FirefoxEnvironment implements BrowserEnvironment { class Firefox extends Browser { /// Starts a new instance of Firefox open to the given [url], which may be a /// [Uri] or a [String]. - factory Firefox(Uri url, FirefoxEnvironment firefoxEnvironment, {bool debug = false}) { - final BrowserInstallation installation = firefoxEnvironment._installation; + factory Firefox(Uri url, BrowserInstallation installation, {bool debug = false}) { final Completer remoteDebuggerCompleter = Completer.sync(); return Firefox._(BrowserProcess(() async { // Using a profile on opening will prevent popups related to profiles. diff --git a/lib/web_ui/dev/firefox_installer.dart b/lib/web_ui/dev/firefox_installer.dart index 3f074b5b27db9..ab27aa375fa19 100644 --- a/lib/web_ui/dev/firefox_installer.dart +++ b/lib/web_ui/dev/firefox_installer.dart @@ -11,6 +11,8 @@ import 'common.dart'; import 'environment.dart'; import 'exceptions.dart'; +const String _firefoxExecutableVar = 'FIREFOX_EXECUTABLE'; + /// Returns the installation of Firefox, installing it if necessary. /// /// If [requestedVersion] is null, uses the version specified on the @@ -36,6 +38,16 @@ Future getOrInstallFirefox( infoLog ??= io.stdout; + // When running on LUCI, if we specify the "firefox" dependency, then the + // bot will download Firefox from CIPD and place it in a cache and set the + // environment variable FIREFOX_EXECUTABLE. + if (io.Platform.environment.containsKey(_firefoxExecutableVar)) { + return BrowserInstallation( + version: 'cipd', + executable: io.Platform.environment[_firefoxExecutableVar]!, + ); + } + if (requestedVersion == 'system') { return BrowserInstallation( version: 'system', From 8ec1bbfa3298a68a762f0d9bc7a326c71244fe9c Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Thu, 17 Nov 2022 10:46:39 -0800 Subject: [PATCH 2/5] Add logging when using cached browsers --- lib/web_ui/dev/chrome_installer.dart | 1 + lib/web_ui/dev/firefox_installer.dart | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/web_ui/dev/chrome_installer.dart b/lib/web_ui/dev/chrome_installer.dart index 206dd383a2875..237cafb48e175 100644 --- a/lib/web_ui/dev/chrome_installer.dart +++ b/lib/web_ui/dev/chrome_installer.dart @@ -39,6 +39,7 @@ Future getOrInstallChrome( // then the bot will download Chrome from CIPD and place it in a cache and // set the environment variable CHROME_EXECUTABLE. if (io.Platform.environment.containsKey(_chromeExecutableVar)) { + infoLog.writeln('Using Chrome from cache: ${io.Platform.environment[_chromeExecutableVar]}'); return BrowserInstallation( version: 'cipd', executable: io.Platform.environment[_chromeExecutableVar]!, diff --git a/lib/web_ui/dev/firefox_installer.dart b/lib/web_ui/dev/firefox_installer.dart index ab27aa375fa19..4a72b64c9d351 100644 --- a/lib/web_ui/dev/firefox_installer.dart +++ b/lib/web_ui/dev/firefox_installer.dart @@ -42,6 +42,7 @@ Future getOrInstallFirefox( // bot will download Firefox from CIPD and place it in a cache and set the // environment variable FIREFOX_EXECUTABLE. if (io.Platform.environment.containsKey(_firefoxExecutableVar)) { + infoLog.writeln('Using Firefox from cache: ${io.Platform.environment[_firefoxExecutableVar]}'); return BrowserInstallation( version: 'cipd', executable: io.Platform.environment[_firefoxExecutableVar]!, From fe4fc948804a8dde5a84134f5a3d170da5a8150f Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Thu, 17 Nov 2022 12:57:22 -0800 Subject: [PATCH 3/5] Update .ci.yaml --- .ci.yaml | 3 +++ lib/web_ui/README.md | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/.ci.yaml b/.ci.yaml index 528d4bf91dc6f..7ad2cf3c530e4 100644 --- a/.ci.yaml +++ b/.ci.yaml @@ -273,6 +273,8 @@ targets: {"download_emsdk": true} dependencies: >- [ + {"dependency": "chrome_and_driver", "version": "version:107.0"}, + {"dependency": "firefox", "version": "version:83.0"}, {"dependency": "goldctl", "version": "git_revision:3a77d0b12c697a840ca0c7705208e8622dc94603"} ] timeout: 60 @@ -419,6 +421,7 @@ targets: {"download_emsdk": true} dependencies: >- [ + {"dependency": "chrome_and_driver", "version": "version:107.0"}, {"dependency": "goldctl", "version": "git_revision:3a77d0b12c697a840ca0c7705208e8622dc94603"} ] timeout: 60 diff --git a/lib/web_ui/README.md b/lib/web_ui/README.md index f43528e2d9db6..e5766b8685a60 100644 --- a/lib/web_ui/README.md +++ b/lib/web_ui/README.md @@ -153,6 +153,20 @@ We test with Firefox on LUCI in the Linux Web Engine builder. The process for rolling Firefox is even easier than Chromium. Simply update `browser_lock.yaml` with the latest version of Firefox, and run `browser_roller.dart`. +#### .ci.yaml + +After rolling Chrome and/or Firefox, also update the CI dependencies in +`.ci.yaml` to make use of the new versions. The lines look like + +```yaml + dependencies: >- + [ + {"dependency": "chrome_and_driver", "version": "version:107.0"}, + {"dependency": "firefox", "version": "version:83.0"}, + {"dependency": "goldctl", "version": "git_revision:3a77d0b12c697a840ca0c7705208e8622dc94603"} + ] +``` + ##### **browser_roller.dart** The script has the following command-line options: From f90e207907b0721c96e0efa7b7f91eff302d922a Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Thu, 17 Nov 2022 13:11:16 -0800 Subject: [PATCH 4/5] Use CIPD chrome in Windows --- .ci.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.ci.yaml b/.ci.yaml index 7ad2cf3c530e4..68e0388d13d22 100644 --- a/.ci.yaml +++ b/.ci.yaml @@ -421,7 +421,6 @@ targets: {"download_emsdk": true} dependencies: >- [ - {"dependency": "chrome_and_driver", "version": "version:107.0"}, {"dependency": "goldctl", "version": "git_revision:3a77d0b12c697a840ca0c7705208e8622dc94603"} ] timeout: 60 @@ -504,6 +503,10 @@ targets: gclient_variables: >- {"download_emsdk": true} gcs_goldens_bucket: flutter_logs + dependencies: >- + [ + {"dependency": "chrome_and_driver", "version": "version:107.0"} + ] timeout: 60 runIf: - DEPS From e29da7605b6d7c8112c31f098c77ee799f45fd16 Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Thu, 17 Nov 2022 13:14:30 -0800 Subject: [PATCH 5/5] Make logging message more useful --- lib/web_ui/dev/chrome_installer.dart | 3 ++- lib/web_ui/dev/firefox_installer.dart | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/web_ui/dev/chrome_installer.dart b/lib/web_ui/dev/chrome_installer.dart index 237cafb48e175..fda05dbfe01d8 100644 --- a/lib/web_ui/dev/chrome_installer.dart +++ b/lib/web_ui/dev/chrome_installer.dart @@ -39,7 +39,8 @@ Future getOrInstallChrome( // then the bot will download Chrome from CIPD and place it in a cache and // set the environment variable CHROME_EXECUTABLE. if (io.Platform.environment.containsKey(_chromeExecutableVar)) { - infoLog.writeln('Using Chrome from cache: ${io.Platform.environment[_chromeExecutableVar]}'); + infoLog.writeln('Using Chrome from $_chromeExecutableVar variable: ' + '${io.Platform.environment[_chromeExecutableVar]}'); return BrowserInstallation( version: 'cipd', executable: io.Platform.environment[_chromeExecutableVar]!, diff --git a/lib/web_ui/dev/firefox_installer.dart b/lib/web_ui/dev/firefox_installer.dart index 4a72b64c9d351..07c673152bda2 100644 --- a/lib/web_ui/dev/firefox_installer.dart +++ b/lib/web_ui/dev/firefox_installer.dart @@ -42,7 +42,8 @@ Future getOrInstallFirefox( // bot will download Firefox from CIPD and place it in a cache and set the // environment variable FIREFOX_EXECUTABLE. if (io.Platform.environment.containsKey(_firefoxExecutableVar)) { - infoLog.writeln('Using Firefox from cache: ${io.Platform.environment[_firefoxExecutableVar]}'); + infoLog.writeln('Using Firefox from $_firefoxExecutableVar variable: ' + '${io.Platform.environment[_firefoxExecutableVar]}'); return BrowserInstallation( version: 'cipd', executable: io.Platform.environment[_firefoxExecutableVar]!,