Update CI config for Flutter 2 (#3674)

Includes cleanup to simplify our setup. Major changes:
- Eliminate the NNBD plugin filtering for stable.
- Remove the temporarily-added beta branch testing.
- Enable Linux, macOS, and web on stable (Windows is LUCI-based)
- Combine the two different macOS matrix configurations now that they
  are the same.
- Combine the two different Linux matrix configurations by using a single
  Dockerfile (which now also includes clang-format)
  - The web integration smoke test temporarily still uses the old Dockerfile,
    now renamed, because the driver installer script doesn't support
    Chrome 89 yet.
- Move most of the Linux tasks to lower-CPU machines to allow more
  tasks to run in parallel without hitting the community limit.
- Reorder the tasks slightly and give them comments to identify
  platform groupings
- Enabled web "build all plugins together" and "build all examples"
  tests
This commit is contained in:
stuartmorgan
2021-03-04 13:59:21 -08:00
committed by GitHub
parent c042ad3628
commit 373cf772f0
3 changed files with 105 additions and 26 deletions

View File

@ -19,6 +19,7 @@ class BuildExamplesCommand extends PluginCommand {
}) : super(packagesDir, fileSystem, processRunner: processRunner) { }) : super(packagesDir, fileSystem, processRunner: processRunner) {
argParser.addFlag(kLinux, defaultsTo: false); argParser.addFlag(kLinux, defaultsTo: false);
argParser.addFlag(kMacos, defaultsTo: false); argParser.addFlag(kMacos, defaultsTo: false);
argParser.addFlag(kWeb, defaultsTo: false);
argParser.addFlag(kWindows, defaultsTo: false); argParser.addFlag(kWindows, defaultsTo: false);
argParser.addFlag(kIpa, defaultsTo: io.Platform.isMacOS); argParser.addFlag(kIpa, defaultsTo: io.Platform.isMacOS);
argParser.addFlag(kApk); argParser.addFlag(kApk);
@ -43,10 +44,10 @@ class BuildExamplesCommand extends PluginCommand {
!argResults[kApk] && !argResults[kApk] &&
!argResults[kLinux] && !argResults[kLinux] &&
!argResults[kMacos] && !argResults[kMacos] &&
!argResults[kWeb] &&
!argResults[kWindows]) { !argResults[kWindows]) {
print( print('None of --linux, --macos, --web, --windows, --apk, or --ipa were '
'None of --linux, --macos, --windows, --apk nor --ipa were specified, ' 'specified, so not building anything.');
'so not building anything.');
return; return;
} }
final String flutterCommand = final String flutterCommand =
@ -84,33 +85,43 @@ class BuildExamplesCommand extends PluginCommand {
if (argResults[kMacos]) { if (argResults[kMacos]) {
print('\nBUILDING macOS for $packageName'); print('\nBUILDING macOS for $packageName');
if (isMacOsPlugin(plugin, fileSystem)) { if (isMacOsPlugin(plugin, fileSystem)) {
// TODO(https://github.com/flutter/flutter/issues/46236):
// Builing macos without running flutter pub get first results
// in an error.
int exitCode = await processRunner.runAndStream( int exitCode = await processRunner.runAndStream(
flutterCommand, <String>['pub', 'get'], flutterCommand,
<String>[
'build',
kMacos,
if (enableExperiment.isNotEmpty)
'--enable-experiment=$enableExperiment',
],
workingDir: example); workingDir: example);
if (exitCode != 0) { if (exitCode != 0) {
failingPackages.add('$packageName (macos)'); failingPackages.add('$packageName (macos)');
} else {
exitCode = await processRunner.runAndStream(
flutterCommand,
<String>[
'build',
kMacos,
if (enableExperiment.isNotEmpty)
'--enable-experiment=$enableExperiment',
],
workingDir: example);
if (exitCode != 0) {
failingPackages.add('$packageName (macos)');
}
} }
} else { } else {
print('macOS is not supported by this plugin'); print('macOS is not supported by this plugin');
} }
} }
if (argResults[kWeb]) {
print('\nBUILDING web for $packageName');
if (isWebPlugin(plugin, fileSystem)) {
int buildExitCode = await processRunner.runAndStream(
flutterCommand,
<String>[
'build',
kWeb,
if (enableExperiment.isNotEmpty)
'--enable-experiment=$enableExperiment',
],
workingDir: example);
if (buildExitCode != 0) {
failingPackages.add('$packageName (web)');
}
} else {
print('Web is not supported by this plugin');
}
}
if (argResults[kWindows]) { if (argResults[kWindows]) {
print('\nBUILDING Windows for $packageName'); print('\nBUILDING Windows for $packageName');
if (isWindowsPlugin(plugin, fileSystem)) { if (isWindowsPlugin(plugin, fileSystem)) {

View File

@ -22,10 +22,10 @@ class FormatCommand extends PluginCommand {
FileSystem fileSystem, { FileSystem fileSystem, {
ProcessRunner processRunner = const ProcessRunner(), ProcessRunner processRunner = const ProcessRunner(),
}) : super(packagesDir, fileSystem, processRunner: processRunner) { }) : super(packagesDir, fileSystem, processRunner: processRunner) {
argParser.addFlag('travis', hide: true); argParser.addFlag('fail-on-change', hide: true);
argParser.addOption('clang-format', argParser.addOption('clang-format',
defaultsTo: 'clang-format', defaultsTo: 'clang-format',
help: 'Path to executable of clang-format v5.'); help: 'Path to executable of clang-format.');
} }
@override @override
@ -46,7 +46,7 @@ class FormatCommand extends PluginCommand {
await _formatJava(googleFormatterPath); await _formatJava(googleFormatterPath);
await _formatCppAndObjectiveC(); await _formatCppAndObjectiveC();
if (argResults['travis']) { if (argResults['fail-on-change']) {
final bool modified = await _didModifyAnything(); final bool modified = await _didModifyAnything();
if (modified) { if (modified) {
throw ToolExit(1); throw ToolExit(1);

View File

@ -201,7 +201,7 @@ void main() {
output, output,
orderedEquals(<String>[ orderedEquals(<String>[
'\nBUILDING macOS for $packageName', '\nBUILDING macOS for $packageName',
'\macOS is not supported by this plugin', 'macOS is not supported by this plugin',
'\n\n', '\n\n',
'All builds successful!', 'All builds successful!',
]), ]),
@ -213,6 +213,7 @@ void main() {
expect(processRunner.recordedCalls, orderedEquals(<ProcessCall>[])); expect(processRunner.recordedCalls, orderedEquals(<ProcessCall>[]));
cleanupPackages(); cleanupPackages();
}); });
test('building for macos', () async { test('building for macos', () async {
createFakePlugin('plugin', createFakePlugin('plugin',
withExtraFiles: <List<String>>[ withExtraFiles: <List<String>>[
@ -244,14 +245,81 @@ void main() {
expect( expect(
processRunner.recordedCalls, processRunner.recordedCalls,
orderedEquals(<ProcessCall>[ orderedEquals(<ProcessCall>[
ProcessCall(flutterCommand, <String>['pub', 'get'],
pluginExampleDirectory.path),
ProcessCall(flutterCommand, <String>['build', 'macos'], ProcessCall(flutterCommand, <String>['build', 'macos'],
pluginExampleDirectory.path), pluginExampleDirectory.path),
])); ]));
cleanupPackages(); cleanupPackages();
}); });
test('building for web with no implementation results in no-op', () async {
createFakePlugin('plugin', withExtraFiles: <List<String>>[
<String>['example', 'test'],
]);
final Directory pluginExampleDirectory =
mockPackagesDir.childDirectory('plugin').childDirectory('example');
createFakePubspec(pluginExampleDirectory, isFlutter: true);
final List<String> output = await runCapturingPrint(
runner, <String>['build-examples', '--no-ipa', '--web']);
final String packageName =
p.relative(pluginExampleDirectory.path, from: mockPackagesDir.path);
expect(
output,
orderedEquals(<String>[
'\nBUILDING web for $packageName',
'Web is not supported by this plugin',
'\n\n',
'All builds successful!',
]),
);
print(processRunner.recordedCalls);
// Output should be empty since running build-examples --macos with no macos
// implementation is a no-op.
expect(processRunner.recordedCalls, orderedEquals(<ProcessCall>[]));
cleanupPackages();
});
test('building for web', () async {
createFakePlugin('plugin',
withExtraFiles: <List<String>>[
<String>['example', 'test'],
<String>['example', 'web', 'index.html'],
],
isWebPlugin: true);
final Directory pluginExampleDirectory =
mockPackagesDir.childDirectory('plugin').childDirectory('example');
createFakePubspec(pluginExampleDirectory, isFlutter: true);
final List<String> output = await runCapturingPrint(
runner, <String>['build-examples', '--no-ipa', '--web']);
final String packageName =
p.relative(pluginExampleDirectory.path, from: mockPackagesDir.path);
expect(
output,
orderedEquals(<String>[
'\nBUILDING web for $packageName',
'\n\n',
'All builds successful!',
]),
);
print(processRunner.recordedCalls);
expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(flutterCommand, <String>['build', 'web'],
pluginExampleDirectory.path),
]));
cleanupPackages();
});
test( test(
'building for Windows when plugin is not set up for Windows results in no-op', 'building for Windows when plugin is not set up for Windows results in no-op',
() async { () async {