Allows adding a storage 'realm' to the storage base URL (#131951)

Context: https://github.com/flutter/flutter/issues/131862

This PR injects a "realm" component to the storage base URL when the contents of the file `bin/internal/engine.realm` is non-empty.

As documented in the PR, when the realm is `flutter_archives_v2`, and `bin/internal/engine.version` contains the commit hash for a commit in a `flutter/engine` PR, then the artifacts pulled by the tool will be the artifacts built by the presubmit checks for the PR.

This works for everything but the following two cases:
1. Fuchsia artifacts are not uploaded to CIPD by the Fuchsia presubmit builds.
2. Web artifacts are not uploaded to gstatic by the web engine presubmit builds.

For (1), the flutter/flutter presubmit `fuchsia_precache` is driven by a shell script outside of the repo. It will fail when the `engine.version` and `engine.realm` don't point to a post-submit engine commit.

For (2), the flutter/flutter web presubmit tests that refer to artifacts in gstatic hang when the artifacts aren't found, so this PR skips them.
This commit is contained in:
Zachary Anderson
2023-08-09 16:26:05 -07:00
committed by GitHub
parent 9c8f3950e3
commit 118c2df776
13 changed files with 163 additions and 39 deletions

View File

@@ -83,6 +83,7 @@ final String flutter = path.join(flutterRoot, 'bin', 'flutter$bat');
final String dart = path.join(flutterRoot, 'bin', 'cache', 'dart-sdk', 'bin', 'dart$exe');
final String pubCache = path.join(flutterRoot, '.pub-cache');
final String engineVersionFile = path.join(flutterRoot, 'bin', 'internal', 'engine.version');
final String engineRealmFile = path.join(flutterRoot, 'bin', 'internal', 'engine.realm');
final String flutterPackagesVersionFile = path.join(flutterRoot, 'bin', 'internal', 'flutter_packages.version');
String get platformFolderName {
@@ -1138,6 +1139,10 @@ Future<void> _runWebUnitTests(String webRenderer) async {
/// Coarse-grained integration tests running on the Web.
Future<void> _runWebLongRunningTests() async {
final String engineVersion = File(engineVersionFile).readAsStringSync().trim();
final String engineRealm = File(engineRealmFile).readAsStringSync().trim();
if (engineRealm.isNotEmpty) {
return;
}
final List<ShardRunner> tests = <ShardRunner>[
for (final String buildMode in _kAllBuildModes) ...<ShardRunner>[
() => _runFlutterDriverWebTest(

View File

@@ -125,7 +125,15 @@ class CodesignCommand extends Command<void> {
await framework.checkout(revision);
// Ensure artifacts present
await framework.runFlutter(<String>['precache', '--android', '--ios', '--macos']);
final io.ProcessResult result = await framework.runFlutter(
<String>['precache', '--android', '--ios', '--macos'],
);
if (result.exitCode != 0) {
stdio.printError(
'flutter precache: exitCode: ${result.exitCode}\n'
'stdout:\n${result.stdout}\nstderr:\n${result.stderr}',
);
}
await verifyExist();
if (argResults![kSignatures] as bool) {

View File

@@ -30,7 +30,8 @@ Future<void> main() async {
await inDirectory(path.join(flutterProject.rootPath, 'android'), () async {
section('Insert gradle testing script');
final File build = File(path.join(
flutterProject.rootPath, 'android', 'app', 'build.gradle'));
flutterProject.rootPath, 'android', 'app', 'build.gradle',
));
build.writeAsStringSync(
'''
task printEngineMavenUrl() {
@@ -44,6 +45,7 @@ task printEngineMavenUrl() {
);
section('Checking default maven URL');
String gradleOutput = await eval(
gradlewExecutable,
<String>['printEngineMavenUrl', '-q'],
@@ -53,29 +55,39 @@ task printEngineMavenUrl() {
String mavenUrl = outputLines.last;
print('Returned maven url: $mavenUrl');
if (mavenUrl != 'https://storage.googleapis.com/download.flutter.io') {
throw TaskResult.failure('Expected Android engine maven dependency URL to '
'resolve to https://storage.googleapis.com/download.flutter.io. Got '
'$mavenUrl instead');
String realm = File(
path.join(flutterDirectory.path, 'bin', 'internal', 'engine.realm'),
).readAsStringSync().trim();
if (realm.isNotEmpty) {
realm = '$realm/';
}
if (mavenUrl != 'https://storage.googleapis.com/${realm}download.flutter.io') {
throw TaskResult.failure(
'Expected Android engine maven dependency URL to '
'resolve to https://storage.googleapis.com/${realm}download.flutter.io. Got '
'$mavenUrl instead',
);
}
section('Checking overridden maven URL');
gradleOutput = await eval(
gradlewExecutable,
<String>['printEngineMavenUrl','-q'],
environment: <String, String>{
'FLUTTER_STORAGE_BASE_URL': 'https://my.special.proxy',
}
);
gradlewExecutable,
<String>['printEngineMavenUrl','-q'],
environment: <String, String>{
'FLUTTER_STORAGE_BASE_URL': 'https://my.special.proxy',
},
);
outputLines = splitter.convert(gradleOutput);
mavenUrl = outputLines.last;
if (mavenUrl != 'https://my.special.proxy/download.flutter.io') {
if (mavenUrl != 'https://my.special.proxy/${realm}download.flutter.io') {
throw TaskResult.failure(
'Expected overridden Android engine maven '
'dependency URL to resolve to proxy location '
'https://my.special.proxy/download.flutter.io. Got '
'$mavenUrl instead');
'Expected overridden Android engine maven '
'dependency URL to resolve to proxy location '
'https://my.special.proxy/${realm}download.flutter.io. Got '
'$mavenUrl instead',
);
}
});
});

View File

@@ -15,11 +15,15 @@ const String kDocRoot = 'dev/docs/doc';
/// the artifact store and extracts them to the location used for Dartdoc.
Future<void> main(List<String> args) async {
final String engineVersion = File('bin/internal/engine.version').readAsStringSync().trim();
String engineRealm = File('bin/internal/engine.realm').readAsStringSync().trim();
if (engineRealm.isNotEmpty) {
engineRealm = '$engineRealm/';
}
final String javadocUrl = 'https://storage.googleapis.com/flutter_infra_release/flutter/$engineVersion/android-javadoc.zip';
final String javadocUrl = 'https://storage.googleapis.com/${engineRealm}flutter_infra_release/flutter/$engineVersion/android-javadoc.zip';
generateDocs(javadocUrl, 'javadoc', 'io/flutter/view/FlutterView.html');
final String objcdocUrl = 'https://storage.googleapis.com/flutter_infra_release/flutter/$engineVersion/ios-objcdoc.zip';
final String objcdocUrl = 'https://storage.googleapis.com/${engineRealm}flutter_infra_release/flutter/$engineVersion/ios-objcdoc.zip';
generateDocs(objcdocUrl, 'objcdoc', 'Classes/FlutterViewController.html');
}