Switch to Chrome For Testing instead of Chromium (flutter/engine#46683)

This switches over to using Chrome for Testing instead of Chromium. This requires some changes from the recipes repo (https://flutter-review.googlesource.com/c/recipes/+/51482) in order to coordinate the change in filestructure on the mac versions.
This commit is contained in:
Jackson Gardner
2023-10-11 14:24:11 -07:00
committed by GitHub
parent 0d5c0a660f
commit 99de03845c
12 changed files with 85 additions and 178 deletions

View File

@@ -360,7 +360,7 @@ targets:
{"download_emsdk": true}
dependencies: >-
[
{"dependency": "chrome_and_driver", "version": "version:117.0"},
{"dependency": "chrome_and_driver", "version": "version:118.0.5993.70"},
{"dependency": "curl", "version": "version:7.64.0"}
]
framework: "true"

View File

@@ -355,7 +355,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -391,7 +391,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -427,7 +427,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -463,7 +463,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -499,7 +499,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -535,7 +535,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -571,7 +571,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -607,7 +607,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -823,7 +823,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -859,7 +859,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -895,7 +895,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -931,7 +931,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -967,7 +967,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -1003,7 +1003,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -1039,7 +1039,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -1075,7 +1075,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -1095,7 +1095,7 @@
"recipe": "engine_v2/tester_engine",
"drone_dimensions": [
"device_type=none",
"os=Mac-12"
"os=Mac"
],
"gclient_variables": {
"download_android_deps": false
@@ -1127,7 +1127,7 @@
"recipe": "engine_v2/tester_engine",
"drone_dimensions": [
"device_type=none",
"os=Mac-12"
"os=Mac"
],
"gclient_variables": {
"download_android_deps": false
@@ -1159,7 +1159,7 @@
"recipe": "engine_v2/tester_engine",
"drone_dimensions": [
"device_type=none",
"os=Mac-12"
"os=Mac"
],
"gclient_variables": {
"download_android_deps": false
@@ -1191,7 +1191,7 @@
"recipe": "engine_v2/tester_engine",
"drone_dimensions": [
"device_type=none",
"os=Mac-12"
"os=Mac"
],
"gclient_variables": {
"download_android_deps": false
@@ -1223,7 +1223,7 @@
"recipe": "engine_v2/tester_engine",
"drone_dimensions": [
"device_type=none",
"os=Mac-12"
"os=Mac"
],
"gclient_variables": {
"download_android_deps": false
@@ -1271,7 +1271,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -1307,7 +1307,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -1343,7 +1343,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -1379,7 +1379,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -1415,7 +1415,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -1451,7 +1451,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -1487,7 +1487,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [
@@ -1523,7 +1523,7 @@
},
{
"dependency": "chrome_and_driver",
"version": "version:117.0"
"version": "118.0.5993.70"
}
],
"tasks": [

View File

@@ -135,8 +135,8 @@ tests locally. To make changes effective on LUCI follow instructions in
### Rolling browsers
When running tests on LUCI using Chromium, LUCI uses the version of Chromium
fetched from CIPD.
When running tests on LUCI using Chrome, LUCI uses the version of Chrome for
Testing fetched from CIPD.
Since the engine code and infra recipes do not live in the same repository
there are few steps to follow in order to upgrade a browser's version.
@@ -166,12 +166,11 @@ the `--dry-run` flag to the felt command.
NOTE: Because this script uses `fc-config`, this roll step only actually works
on Linux, not on macOS or Windows.
#### Chromium
#### Chrome for Testing
Chromium is an independent project that gets rolled into Flutter manually, and as needed.
Flutter consumes a pre-built Chromium version from chromium.org. When a new version of
Chromium (check [here](https://www.chromium.org/getting-involved/download-chromium/#downloading-old-builds-of-chrome-chromium))
is needed, follow these steps to roll the new version:
Chrome for Testing is an independent project that gets rolled into Flutter
manually, and as needed. Flutter consumes a pre-built Chrome for Testing build.
The available versions of Chrome for Testing available can be found [here](https://googlechromelabs.github.io/chrome-for-testing/). To roll to a newer version:
- Make sure you have `depot_tools` installed (if you are regularly hacking on
the engine code, you probably do).
@@ -179,13 +178,8 @@ is needed, follow these steps to roll the new version:
instructions (this step requires sufficient privileges; contact
#hackers-infra-🌡 on [Flutter's Discord server](https://github.com/flutter/flutter/wiki/Chat)).
- Edit `dev/browser_lock.yaml` and update the following values under `chrome`:
- Set `Windows`, `Mac` and `Linux` to the `branch_base_position`s given [in this table](https://omahaproxy.appspot.com).
(Pick from `linux`, `mac` and `win` as `os`, and the `stable` channel.)
- Set `version` to a string composed of the Major Version of the browser, and
the number of times that major version has been uploaded to CIPD. For example,
start with `'99'` for version 99.0.4844.51 of Chromium, and update to `'99.1'`,
`'99.2'` and so on if you need to upload newer bundles of the same major version.
(This is required because tags can't be repeated in CIPD).
- Set `version` to the full four part version number of the build of Chrome
for Testing you want to roll (for example, `118.0.5993.70`)
- Run `dart dev/browser_roller.dart` and make sure it completes successfully.
The script uploads the specified versions of Chromium (and Chromedriver) to the
right locations in CIPD: [Chrome](https://chrome-infra-packages.appspot.com/p/flutter_internal/browsers/chrome),

View File

@@ -7,7 +7,6 @@ import 'dart:io' as io;
import 'package:path/path.dart' as path;
import 'package:yaml/yaml.dart';
import 'common.dart';
import 'environment.dart';
/// Returns the browser configuration based on the `browser_lock.yaml` file in
@@ -36,23 +35,10 @@ class BrowserLock {
class ChromeLock {
ChromeLock._fromYaml(YamlMap yaml) :
linux = (yaml['Linux'] as int).toString(),
mac = (yaml['Mac'] as int).toString(),
macArm = (yaml['Mac_Arm'] as int).toString(),
windows = (yaml['Win'] as int).toString(),
version = yaml['version'] as String;
final String linux;
final String mac;
final String macArm;
final String windows;
/// The major version of Chromium represented by this lock. E.g: '96' (for Chromium 96.0.554.51)
/// The full version of Chromium represented by this lock. E.g: '119.0.6045.9'
final String version;
/// Return the Chromium Build ID to use for the current operating system.
String get versionForCurrentPlatform {
return PlatformBinding.instance.getChromeBuild(this);
}
}
class FirefoxLock {

View File

@@ -1,23 +1,7 @@
# Please refer to the "Upgrade Browser Version" section in the README.md for
# more details on how to update browser version numbers.
chrome:
# It seems Chrome can't always release from the same build for all operating
# systems, so we specify per-OS build number.
#
# Follow these instructions to find the correct build number for a specific
# Chromium version + OS combo:
#
# https://www.chromium.org/getting-involved/download-chromium/#downloading-old-builds-of-chrome-chromium
#
# The OS names here must match what recipe Python expression
# `self.m.platform.name.capitalize()` evaluates to. See:
#
# recipe_modules/web_util/api.py
Linux: 1181205
Mac: 1181205
Mac_Arm: 1181212
Win: 1181217
version: '117.0' # CIPD tag for the above Build IDs. Normally "ChromeMajorVersion.UploadAttempt". ;)
version: '118.0.5993.70'
firefox:
version: '106.0'

View File

@@ -209,19 +209,18 @@ class _BrowserRoller {
// Downloads Chromium from the internet, packs it in the directory structure
// that the LUCI script wants. The result of this will be then uploaded to CIPD.
Future<void> _rollChromium(_Platform platform) async {
final String chromeBuild = platform.binding.getChromeBuild(_lock.chromeLock);
final String majorVersion = _lock.chromeLock.version;
final String url = platform.binding.getChromeDownloadUrl(chromeBuild);
final String version = _lock.chromeLock.version;
final String url = platform.binding.getChromeDownloadUrl(version);
final String cipdPackageName = 'flutter_internal/browsers/chrome/${platform.name}';
final io.Directory platformDir = io.Directory(path.join(_rollDir.path, platform.name));
print('\nRolling Chromium for ${platform.name} (version:$majorVersion, build $chromeBuild)');
print('\nRolling Chromium for ${platform.name} (version:$version)');
// Bail out if CIPD already has version:$majorVersion for this package!
if (!dryRun && await cipdKnowsPackageVersion(
package: cipdPackageName,
versionTag: majorVersion,
versionTag: version,
isVerbose: verbose
)) {
print(' Skipping $cipdPackageName version:$majorVersion. Already uploaded to CIPD!');
print(' Skipping $cipdPackageName version:$version. Already uploaded to CIPD!');
vprint(' Update browser_lock.yaml and use a different version value.');
return;
}
@@ -233,24 +232,17 @@ class _BrowserRoller {
await _unzipAndDeleteFile(chromeDownload, platformDir);
late String relativePlatformDirPath;
// Preserve the `chrome-mac` directory when bundling, but remove it for win and linux.
if (platform.os == 'mac') {
relativePlatformDirPath = path.relative(platformDir.path, from: _rollDir.path);
} else {
final io.Directory? actualContentRoot = await _locateContentRoot(platformDir);
assert(actualContentRoot != null);
relativePlatformDirPath = path.relative(actualContentRoot!.path, from: _rollDir.path);
}
final io.Directory? actualContentRoot = await _locateContentRoot(platformDir);
assert(actualContentRoot != null);
final String relativePlatformDirPath = path.relative(actualContentRoot!.path, from: _rollDir.path);
vprint(' Uploading Chromium (${platform.name}) to CIPD...');
await uploadDirectoryToCipd(
directory: _rollDir,
packageName: cipdPackageName,
configFileName: 'cipd.chromium.${platform.name}.yaml',
description: 'Chromium $majorVersion (build $chromeBuild) used for testing',
version: majorVersion,
buildId: chromeBuild,
description: 'Chromium $version used for testing',
version: version,
root: relativePlatformDirPath,
isDryRun: dryRun,
isVerbose: verbose,
@@ -260,19 +252,18 @@ class _BrowserRoller {
// Downloads Chromedriver from the internet, packs it in the directory structure
// that the LUCI script wants. The result of this will be then uploaded to CIPD.
Future<void> _rollChromeDriver(_Platform platform) async {
final String chromeBuild = platform.binding.getChromeBuild(_lock.chromeLock);
final String majorVersion = _lock.chromeLock.version;
final String url = platform.binding.getChromeDriverDownloadUrl(chromeBuild);
final String version = _lock.chromeLock.version;
final String url = platform.binding.getChromeDriverDownloadUrl(version);
final String cipdPackageName = 'flutter_internal/browser-drivers/chrome/${platform.name}';
final io.Directory platformDir = io.Directory(path.join(_rollDir.path, '${platform.name}_driver'));
print('\nRolling Chromedriver for ${platform.os}-${platform.arch} (version:$majorVersion, build $chromeBuild)');
print('\nRolling Chromedriver for ${platform.os}-${platform.arch} (version:$version)');
// Bail out if CIPD already has version:$majorVersion for this package!
if (!dryRun && await cipdKnowsPackageVersion(
package: cipdPackageName,
versionTag: majorVersion,
versionTag: version,
isVerbose: verbose
)) {
print(' Skipping $cipdPackageName version:$majorVersion. Already uploaded to CIPD!');
print(' Skipping $cipdPackageName version:$version. Already uploaded to CIPD!');
vprint(' Update browser_lock.yaml and use a different version value.');
return;
}
@@ -294,9 +285,8 @@ class _BrowserRoller {
directory: _rollDir,
packageName: cipdPackageName,
configFileName: 'cipd.chromedriver.${platform.name}.yaml',
description: 'Chromedriver for Chromium $majorVersion (build $chromeBuild) used for testing',
version: majorVersion,
buildId: chromeBuild,
description: 'Chromedriver for Chromium $version used for testing',
version: version,
root: relativePlatformDirPath,
isDryRun: dryRun,
isVerbose: verbose,
@@ -341,7 +331,6 @@ class _BrowserRoller {
configFileName: 'cipd.firefox.${platform.name}.yaml',
description: 'Firefox $version used for testing',
version: version,
buildId: version,
root: relativePlatformDirPath,
isDryRun: dryRun,
isVerbose: verbose,

View File

@@ -52,7 +52,7 @@ class ChromeEnvironment implements BrowserEnvironment {
@override
Future<void> prepare() async {
final String version = browserLock.chromeLock.versionForCurrentPlatform;
final String version = browserLock.chromeLock.version;
_installation = await getOrInstallChrome(
version,
infoLog: isCi ? stdout : DevNull(),

View File

@@ -180,7 +180,7 @@ class ChromeInstaller {
/// Windows LUCI bots does not have a `unzip`. Instead we are
/// using `archive` pub package.
///
/// We didn't use `archieve` on Mac/Linux since the new files have
/// We didn't use `archive` on Mac/Linux since the new files have
/// permission issues. For now we are not able change file permissions
/// from dart.
/// See: https://github.com/dart-lang/sdk/issues/15078.
@@ -219,7 +219,7 @@ class ChromeInstaller {
// named e.g. 'chrome-linux'. We need to copy the files out of that
// directory and into the version directory.
final io.Directory tmpDir = await io.Directory.systemTemp.createTemp();
final io.Directory unzipDir = io.Platform.isLinux ? tmpDir : versionDir;
final io.Directory unzipDir = tmpDir;
final io.ProcessResult unzipResult =
await io.Process.run('unzip', <String>[
downloadedFile.path,
@@ -233,17 +233,13 @@ class ChromeInstaller {
'The unzip process exited with code ${unzipResult.exitCode}.');
}
// Remove the "chrome-linux/" path prefix, which is the Linux
// convention for Chromium directory structure.
if (io.Platform.isLinux) {
final io.Directory chromeLinuxDir =
await tmpDir.list().single as io.Directory;
await for (final io.FileSystemEntity entity in chromeLinuxDir.list()) {
await entity
.rename(path.join(versionDir.path, path.basename(entity.path)));
}
await tmpDir.delete(recursive: true);
final io.Directory topLevelDir =
await tmpDir.list().single as io.Directory;
await for (final io.FileSystemEntity entity in topLevelDir.list()) {
await entity
.rename(path.join(versionDir.path, path.basename(entity.path)));
}
await tmpDir.delete(recursive: true);
}
downloadedFile.deleteSync();

View File

@@ -40,7 +40,6 @@ Future<int> uploadDirectoryToCipd({
required String description,
required String root,
required String version,
required String buildId,
bool isDryRun = false,
bool isVerbose = false,
}) async {
@@ -72,7 +71,7 @@ data:
'--tag',
'version:$version',
'--ref',
buildId,
version,
],
if (isDryRun) ...<String>[
'--out',

View File

@@ -7,7 +7,6 @@ import 'dart:io' as io;
import 'package:path/path.dart' as path;
import 'browser.dart';
import 'browser_lock.dart';
import 'chrome.dart';
import 'edge.dart';
import 'environment.dart';
@@ -43,9 +42,14 @@ abstract class PlatformBinding {
throw UnsupportedError('${io.Platform.operatingSystem} is not supported');
}
String getChromeBuild(ChromeLock chromeLock);
String getChromeDownloadUrl(String version);
String getChromeDriverDownloadUrl(String version);
String get chromePlatformString;
String getChromeDownloadUrl(String version) =>
'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/$version/$chromePlatformString/chrome-$chromePlatformString.zip';
String getChromeDriverDownloadUrl(String version) =>
'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/$version/$chromePlatformString/chromedriver-$chromePlatformString.zip';
String getFirefoxDownloadUrl(String version);
String getFirefoxDownloadFilename(String version);
String getChromeExecutablePath(io.Directory versionDir);
@@ -55,22 +59,9 @@ abstract class PlatformBinding {
String getCommandToRunEdge();
}
const String _kBaseDownloadUrl =
'https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o';
class WindowsPlatformBinding implements PlatformBinding {
class WindowsPlatformBinding extends PlatformBinding {
@override
String getChromeBuild(ChromeLock chromeLock) {
return chromeLock.windows;
}
@override
String getChromeDownloadUrl(String version) =>
'https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Win_x64%2F$version%2Fchrome-win.zip?alt=media';
@override
String getChromeDriverDownloadUrl(String version) =>
'https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Win_x64%2F$version%2Fchromedriver_win32.zip?alt=media';
String get chromePlatformString => 'win64';
@override
String getChromeExecutablePath(io.Directory versionDir) =>
@@ -100,19 +91,9 @@ class WindowsPlatformBinding implements PlatformBinding {
String getCommandToRunEdge() => 'MicrosoftEdgeLauncher';
}
class LinuxPlatformBinding implements PlatformBinding {
class LinuxPlatformBinding extends PlatformBinding {
@override
String getChromeBuild(ChromeLock chromeLock) {
return chromeLock.linux;
}
@override
String getChromeDownloadUrl(String version) =>
'$_kBaseDownloadUrl/Linux_x64%2F$version%2Fchrome-linux.zip?alt=media';
@override
String getChromeDriverDownloadUrl(String version) =>
'$_kBaseDownloadUrl/Linux_x64%2F$version%2Fchromedriver_linux64.zip?alt=media';
String get chromePlatformString => 'linux64';
@override
String getChromeExecutablePath(io.Directory versionDir) =>
@@ -144,25 +125,14 @@ class LinuxPlatformBinding implements PlatformBinding {
throw UnsupportedError('Edge is not supported on Linux');
}
abstract class MacPlatformBinding implements PlatformBinding {
String get chromePlatformString;
@override
String getChromeDownloadUrl(String version) =>
'$_kBaseDownloadUrl/$chromePlatformString%2F$version%2Fchrome-mac.zip?alt=media';
@override
String getChromeDriverDownloadUrl(String version) =>
'$_kBaseDownloadUrl/$chromePlatformString%2F$version%2Fchromedriver_mac64.zip?alt=media';
abstract class MacPlatformBinding extends PlatformBinding {
@override
String getChromeExecutablePath(io.Directory versionDir) => path.join(
versionDir.path,
'chrome-mac',
'Chromium.app',
'Google Chrome for Testing.app',
'Contents',
'MacOS',
'Chromium',
'Google Chrome for Testing',
);
@override
@@ -191,22 +161,12 @@ abstract class MacPlatformBinding implements PlatformBinding {
class MacArmPlatformBinding extends MacPlatformBinding {
@override
String get chromePlatformString => 'Mac_Arm';
@override
String getChromeBuild(ChromeLock chromeLock) {
return chromeLock.macArm;
}
String get chromePlatformString => 'mac-arm64';
}
class Macx64PlatformBinding extends MacPlatformBinding {
@override
String get chromePlatformString => 'Mac';
@override
String getChromeBuild(ChromeLock chromeLock) {
return chromeLock.mac;
}
String get chromePlatformString => 'mac-x64';
}
class BrowserInstallation {

View File

@@ -154,7 +154,7 @@ Iterable<dynamic> _getTestStepsForPlatform(
if (suite.runConfig.browser == BrowserName.chrome)
<String, dynamic>{
'dependency': 'chrome_and_driver',
'version': 'version:117.0',
'version': '118.0.5993.70',
},
if (suite.runConfig.browser == BrowserName.firefox)
<String, dynamic>{

View File

@@ -311,7 +311,6 @@ OTHER DEALINGS IN THE FONT SOFTWARE.
description: 'A set of Noto fonts to fall back to for use in testing.',
root: fontDir.path,
version: versionString,
buildId: versionString,
isDryRun: isDryRun,
);
}