Add Windows build test (#68657)

Enables build_test for Windows. Currently only flutter_gallery has platform directories for the desktop platforms, so this will run only that build, but this will provide an end-to-end build test for Windows.

Other example/test projects can be brought online for Windows in the future just by adding the windows/ directory to the project.
This commit is contained in:
stuartmorgan 2020-10-22 15:14:30 -07:00 committed by GitHub
parent 2e75f52ae4
commit 22c502e315
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -136,6 +136,13 @@ bool _shouldRunMacOS() {
return Platform.isMacOS && (branchName != 'beta' && branchName != 'stable');
}
/// Returns whether or not Windows desktop tests should be run.
///
/// The branch restrictions here should stay in sync with features.dart.
bool _shouldRunWindows() {
return Platform.isWindows && (branchName != 'beta' && branchName != 'stable');
}
/// Verify the Flutter Engine is the revision in
/// bin/cache/internal/engine.version.
Future<void> _validateEngineHash() async {
@ -393,6 +400,14 @@ Future<void> _runExampleProjectBuildTests(FileSystemEntity exampleDirectory) asy
print('Example project ${path.basename(examplePath)} has no macos directory, skipping macOS');
}
}
if (_shouldRunWindows()) {
if (Directory(path.join(examplePath, 'windows')).existsSync()) {
await _flutterBuildWin32(examplePath, release: false, additionalArgs: additionalArgs, verifyCaching: verifyCaching);
await _flutterBuildWin32(examplePath, release: true, additionalArgs: additionalArgs, verifyCaching: verifyCaching);
} else {
print('Example project ${path.basename(examplePath)} has no windows directory, skipping Win32');
}
}
}
Future<void> _flutterBuildApk(String relativePathToApplication, {
@ -449,6 +464,21 @@ Future<void> _flutterBuildMacOS(String relativePathToApplication, {
);
}
Future<void> _flutterBuildWin32(String relativePathToApplication, {
@required bool release,
bool verifyCaching = false,
List<String> additionalArgs = const <String>[],
}) async {
assert(Platform.isWindows);
await runCommand(flutter, <String>['config', '--enable-windows-desktop']);
print('${green}Testing Windows build$reset for $cyan$relativePathToApplication$reset...');
await _flutterBuild(relativePathToApplication, 'Windows', 'windows',
release: release,
verifyCaching: verifyCaching,
additionalArgs: additionalArgs
);
}
Future<void> _flutterBuild(
String relativePathToApplication,
String platformLabel,