From 72926bdff72e7915136c653c8448107ba9252e36 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Thu, 29 Nov 2018 09:32:11 -0800 Subject: [PATCH] Smoke test building IPA and APK on supported platforms (#24601) * build tests - AOT on all, APK on Linux, IPA on Mac --- .cirrus.yml | 23 ++++++++++++-- dev/bots/test.dart | 77 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 85 insertions(+), 15 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 6f34fdee0b..3305fbe2e6 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -38,6 +38,7 @@ task: - analyze - tests-linux - tool_tests-linux + - build_tests-linux env: SHARD: deploy_gallery GOOGLE_DEVELOPER_SERVICE_ACCOUNT_ACTOR_FASTLANE: ENCRYPTED[d9ac1462c3c556fc2f8165c9d5566a16497d8ebc38a50357f7f3abf136b7f83e1d1d76dde36fee356cb0f9ebf7a89346] @@ -62,9 +63,9 @@ task: container: cpu: 4 memory: 12G - - name: aot_build_tests-linux + - name: build_tests-linux env: - SHARD: aot_build_tests + SHARD: build_tests test_script: - dart ./dev/bots/test.dart container: @@ -110,6 +111,12 @@ task: - name: tool_tests-windows env: SHARD: tool_tests + - name: build_tests-windows + env: + SHARD: build_tests + container: + cpu: 4 + memory: 12G task: use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_PR == '' @@ -121,6 +128,7 @@ task: - analyze - tests-macos - tool_tests-macos + - build_tests-macos env: # Name the SDK directory to include a space so that we constantly # test path names with spaces in them. @@ -153,6 +161,8 @@ task: - analyze env: CIRRUS_WORKING_DIR: "/tmp/flutter sdk" + install_cocoapods_script: + - sudo gem install cocoapods git_fetch_script: - git fetch origin - git fetch origin master # To set FETCH_HEAD for "git merge-base" to work @@ -178,6 +188,14 @@ task: - name: tool_tests-macos env: SHARD: tool_tests + - name: build_tests-macos + env: + SHARD: build_tests + COCOAPODS_DISABLE_STATS: true + FLUTTER_FRAMEWORK_DIR: "/tmp/flutter sdk/bin/cache/artifacts/engine/ios/" + container: + cpu: 4 + memory: 12G docker_builder: @@ -190,6 +208,7 @@ docker_builder: - analyze - tests-linux - tool_tests-linux + - build_tests-linux build_script: "$CIRRUS_WORKING_DIR/dev/ci/docker_linux/docker_build.sh" login_script: "$CIRRUS_WORKING_DIR/dev/ci/docker_linux/docker_login.sh" push_script: "$CIRRUS_WORKING_DIR/dev/ci/docker_linux/docker_push.sh" diff --git a/dev/bots/test.dart b/dev/bots/test.dart index e55847a04a..289b5ded60 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -21,7 +21,7 @@ final List flutterTestArgs = []; const Map _kShards = { 'tests': _runTests, 'tool_tests': _runToolTests, - 'aot_build_tests': _runAotBuildTests, + 'build_tests': _runBuildTests, 'coverage': _runCoverage, }; @@ -150,25 +150,76 @@ Future _runToolTests() async { print('${bold}DONE: All tests successful.$reset'); } -/// Verifies that AOT builds of some examples apps finish -/// without crashing. It does not actually launch the AOT-built -/// apps. That happens later in the devicelab. This is just -/// a smoke-test. -Future _runAotBuildTests() async { - await _flutterBuildAot(path.join('examples', 'hello_world')); - await _flutterBuildAot(path.join('examples', 'flutter_gallery')); - await _flutterBuildAot(path.join('examples', 'flutter_view')); +/// Verifies that AOT, APK, and IPA (if on macOS) builds of some +/// examples apps finish without crashing. It does not actually +/// launch the apps. That happens later in the devicelab. This is +/// just a smoke-test. In particular, this will verify we can build +/// when there are spaces in the path name for the Flutter SDK and +/// target app. +Future _runBuildTests() async { + final List paths = [ + path.join('examples', 'hello_world'), + path.join('examples', 'flutter_gallery'), + path.join('examples', 'flutter_view'), + ]; + for (String path in paths) { + await _flutterBuildAot(path); + await _flutterBuildApk(path); + await _flutterBuildIpa(path); + } - print('${bold}DONE: All AOT build tests successful.$reset'); + print('${bold}DONE: All build tests successful.$reset'); } -Future _flutterBuildAot(String relativePathToApplication) { - return runCommand(flutter, - ['build', 'aot'], +Future _flutterBuildAot(String relativePathToApplication) async { + print('Running AOT build tests...'); + await runCommand(flutter, + ['build', 'aot', '-v'], workingDirectory: path.join(flutterRoot, relativePathToApplication), expectNonZeroExit: false, timeout: _kShortTimeout, ); + print('Done.'); +} + +Future _flutterBuildApk(String relativePathToApplication) async { + // TODO(dnfield): See if we can get Android SDK on all Cirrus platforms. + if (Platform.environment['ANDROID_HOME']?.isEmpty ?? true) { + return; + } + print('Running APK build tests...'); + await runCommand(flutter, + ['build', 'apk', '--debug', '-v'], + workingDirectory: path.join(flutterRoot, relativePathToApplication), + expectNonZeroExit: false, + timeout: _kShortTimeout, + ); + print('Done.'); +} + +Future _flutterBuildIpa(String relativePathToApplication) async { + if (!Platform.isMacOS) { + return; + } + print('Running IPA build tests...'); + // Install Cocoapods. We don't have these checked in for the examples, + // and build ios doesn't take care of it automatically. + final File podfile = File(path.join(flutterRoot, relativePathToApplication, 'ios', 'Podfile')); + if (podfile.existsSync()) { + await runCommand('pod', + ['install'], + workingDirectory: podfile.parent.path, + expectNonZeroExit: false, + timeout: _kShortTimeout, + ); + } + await runCommand(flutter, + ['build', 'ios', '--no-codesign', '--debug', '-v'], + workingDirectory: path.join(flutterRoot, relativePathToApplication), + expectNonZeroExit: false, + timeout: _kShortTimeout, + ); + print('Done.'); } Future _runTests() async {