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

Commit 49b52db

Browse files
author
Harry Terkelsen
authored
[web] Check for cached browsers on LUCI (#37721)
1 parent 3634b6b commit 49b52db

File tree

5 files changed

+50
-3
lines changed

5 files changed

+50
-3
lines changed

.ci.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ targets:
273273
{"download_emsdk": true}
274274
dependencies: >-
275275
[
276+
{"dependency": "chrome_and_driver", "version": "version:107.0"},
277+
{"dependency": "firefox", "version": "version:83.0"},
276278
{"dependency": "goldctl", "version": "git_revision:3a77d0b12c697a840ca0c7705208e8622dc94603"}
277279
]
278280
timeout: 60
@@ -501,6 +503,10 @@ targets:
501503
gclient_variables: >-
502504
{"download_emsdk": true}
503505
gcs_goldens_bucket: flutter_logs
506+
dependencies: >-
507+
[
508+
{"dependency": "chrome_and_driver", "version": "version:107.0"}
509+
]
504510
timeout: 60
505511
runIf:
506512
- DEPS

lib/web_ui/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,20 @@ We test with Firefox on LUCI in the Linux Web Engine builder. The process for
153153
rolling Firefox is even easier than Chromium. Simply update `browser_lock.yaml`
154154
with the latest version of Firefox, and run `browser_roller.dart`.
155155

156+
#### .ci.yaml
157+
158+
After rolling Chrome and/or Firefox, also update the CI dependencies in
159+
`.ci.yaml` to make use of the new versions. The lines look like
160+
161+
```yaml
162+
dependencies: >-
163+
[
164+
{"dependency": "chrome_and_driver", "version": "version:107.0"},
165+
{"dependency": "firefox", "version": "version:83.0"},
166+
{"dependency": "goldctl", "version": "git_revision:3a77d0b12c697a840ca0c7705208e8622dc94603"}
167+
]
168+
```
169+
156170
##### **browser_roller.dart**
157171
158172
The script has the following command-line options:

lib/web_ui/dev/chrome_installer.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import 'common.dart';
1515
import 'environment.dart';
1616
import 'exceptions.dart';
1717

18+
const String _chromeExecutableVar = 'CHROME_EXECUTABLE';
19+
1820
/// Returns the installation of Chrome, installing it if necessary.
1921
///
2022
/// If [requestedVersion] is null, uses the version specified on the
@@ -33,6 +35,18 @@ Future<BrowserInstallation> getOrInstallChrome(
3335
}) async {
3436
infoLog ??= io.stdout;
3537

38+
// When running on LUCI, if we specify the "chrome_and_driver" dependency,
39+
// then the bot will download Chrome from CIPD and place it in a cache and
40+
// set the environment variable CHROME_EXECUTABLE.
41+
if (io.Platform.environment.containsKey(_chromeExecutableVar)) {
42+
infoLog.writeln('Using Chrome from $_chromeExecutableVar variable: '
43+
'${io.Platform.environment[_chromeExecutableVar]}');
44+
return BrowserInstallation(
45+
version: 'cipd',
46+
executable: io.Platform.environment[_chromeExecutableVar]!,
47+
);
48+
}
49+
3650
if (requestedVersion == 'system') {
3751
return BrowserInstallation(
3852
version: 'system',

lib/web_ui/dev/firefox.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class FirefoxEnvironment implements BrowserEnvironment {
2222

2323
@override
2424
Future<Browser> launchBrowserInstance(Uri url, {bool debug = false}) async {
25-
return Firefox(url, this, debug: debug);
25+
return Firefox(url, _installation, debug: debug);
2626
}
2727

2828
@override
@@ -56,8 +56,7 @@ class FirefoxEnvironment implements BrowserEnvironment {
5656
class Firefox extends Browser {
5757
/// Starts a new instance of Firefox open to the given [url], which may be a
5858
/// [Uri] or a [String].
59-
factory Firefox(Uri url, FirefoxEnvironment firefoxEnvironment, {bool debug = false}) {
60-
final BrowserInstallation installation = firefoxEnvironment._installation;
59+
factory Firefox(Uri url, BrowserInstallation installation, {bool debug = false}) {
6160
final Completer<Uri> remoteDebuggerCompleter = Completer<Uri>.sync();
6261
return Firefox._(BrowserProcess(() async {
6362
// Using a profile on opening will prevent popups related to profiles.

lib/web_ui/dev/firefox_installer.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import 'common.dart';
1111
import 'environment.dart';
1212
import 'exceptions.dart';
1313

14+
const String _firefoxExecutableVar = 'FIREFOX_EXECUTABLE';
15+
1416
/// Returns the installation of Firefox, installing it if necessary.
1517
///
1618
/// If [requestedVersion] is null, uses the version specified on the
@@ -36,6 +38,18 @@ Future<BrowserInstallation> getOrInstallFirefox(
3638

3739
infoLog ??= io.stdout;
3840

41+
// When running on LUCI, if we specify the "firefox" dependency, then the
42+
// bot will download Firefox from CIPD and place it in a cache and set the
43+
// environment variable FIREFOX_EXECUTABLE.
44+
if (io.Platform.environment.containsKey(_firefoxExecutableVar)) {
45+
infoLog.writeln('Using Firefox from $_firefoxExecutableVar variable: '
46+
'${io.Platform.environment[_firefoxExecutableVar]}');
47+
return BrowserInstallation(
48+
version: 'cipd',
49+
executable: io.Platform.environment[_firefoxExecutableVar]!,
50+
);
51+
}
52+
3953
if (requestedVersion == 'system') {
4054
return BrowserInstallation(
4155
version: 'system',

0 commit comments

Comments
 (0)