From c23319ee9f13cf4bdb78f515c8056efa96879c52 Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Thu, 29 Oct 2020 09:27:59 -0700 Subject: [PATCH] Enable dev/bots/ build_tests for Linux (#68658) Enables build_test for Linux. 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 Linux. Other example/test projects can be brought online for Linux in the future just by adding the linux/ directory to the project. --- dev/bots/test.dart | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/dev/bots/test.dart b/dev/bots/test.dart index a1c3cf526d2..e05c6fc335d 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -129,6 +129,13 @@ Future main(List args) async { print('$clock ${bold}Test successful.$reset'); } +/// Returns whether or not Linux desktop tests should be run. +/// +/// The branch restrictions here should stay in sync with features.dart. +bool _shouldRunLinux() { + return Platform.isLinux && (branchName != 'beta' && branchName != 'stable'); +} + /// Returns whether or not macOS desktop tests should be run. /// /// The branch restrictions here should stay in sync with features.dart. @@ -400,6 +407,14 @@ Future _runExampleProjectBuildTests(FileSystemEntity exampleDirectory) asy print('Example project ${path.basename(examplePath)} has no ios directory, skipping ipa'); } } + if (_shouldRunLinux()) { + if (Directory(path.join(examplePath, 'linux')).existsSync()) { + await _flutterBuildLinux(examplePath, release: false, additionalArgs: additionalArgs, verifyCaching: verifyCaching); + await _flutterBuildLinux(examplePath, release: true, additionalArgs: additionalArgs, verifyCaching: verifyCaching); + } else { + print('Example project ${path.basename(examplePath)} has no linux directory, skipping Linux'); + } + } if (_shouldRunMacOS()) { if (Directory(path.join(examplePath, 'macos')).existsSync()) { await _flutterBuildMacOS(examplePath, release: false, additionalArgs: additionalArgs, verifyCaching: verifyCaching); @@ -457,6 +472,21 @@ Future _flutterBuildIpa(String relativePathToApplication, { ); } +Future _flutterBuildLinux(String relativePathToApplication, { + @required bool release, + bool verifyCaching = false, + List additionalArgs = const [], +}) async { + assert(Platform.isLinux); + await runCommand(flutter, ['config', '--enable-linux-desktop']); + print('${green}Testing Linux build$reset for $cyan$relativePathToApplication$reset...'); + await _flutterBuild(relativePathToApplication, 'Linux', 'linux', + release: release, + verifyCaching: verifyCaching, + additionalArgs: additionalArgs + ); +} + Future _flutterBuildMacOS(String relativePathToApplication, { @required bool release, bool verifyCaching = false,