Skip to content

Commit 72926bd

Browse files
authored
Smoke test building IPA and APK on supported platforms (#24601)
* build tests - AOT on all, APK on Linux, IPA on Mac
1 parent c80244d commit 72926bd

File tree

2 files changed

+85
-15
lines changed

2 files changed

+85
-15
lines changed

.cirrus.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ task:
3838
- analyze
3939
- tests-linux
4040
- tool_tests-linux
41+
- build_tests-linux
4142
env:
4243
SHARD: deploy_gallery
4344
GOOGLE_DEVELOPER_SERVICE_ACCOUNT_ACTOR_FASTLANE: ENCRYPTED[d9ac1462c3c556fc2f8165c9d5566a16497d8ebc38a50357f7f3abf136b7f83e1d1d76dde36fee356cb0f9ebf7a89346]
@@ -62,9 +63,9 @@ task:
6263
container:
6364
cpu: 4
6465
memory: 12G
65-
- name: aot_build_tests-linux
66+
- name: build_tests-linux
6667
env:
67-
SHARD: aot_build_tests
68+
SHARD: build_tests
6869
test_script:
6970
- dart ./dev/bots/test.dart
7071
container:
@@ -110,6 +111,12 @@ task:
110111
- name: tool_tests-windows
111112
env:
112113
SHARD: tool_tests
114+
- name: build_tests-windows
115+
env:
116+
SHARD: build_tests
117+
container:
118+
cpu: 4
119+
memory: 12G
113120

114121
task:
115122
use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_PR == ''
@@ -121,6 +128,7 @@ task:
121128
- analyze
122129
- tests-macos
123130
- tool_tests-macos
131+
- build_tests-macos
124132
env:
125133
# Name the SDK directory to include a space so that we constantly
126134
# test path names with spaces in them.
@@ -153,6 +161,8 @@ task:
153161
- analyze
154162
env:
155163
CIRRUS_WORKING_DIR: "/tmp/flutter sdk"
164+
install_cocoapods_script:
165+
- sudo gem install cocoapods
156166
git_fetch_script:
157167
- git fetch origin
158168
- git fetch origin master # To set FETCH_HEAD for "git merge-base" to work
@@ -178,6 +188,14 @@ task:
178188
- name: tool_tests-macos
179189
env:
180190
SHARD: tool_tests
191+
- name: build_tests-macos
192+
env:
193+
SHARD: build_tests
194+
COCOAPODS_DISABLE_STATS: true
195+
FLUTTER_FRAMEWORK_DIR: "/tmp/flutter sdk/bin/cache/artifacts/engine/ios/"
196+
container:
197+
cpu: 4
198+
memory: 12G
181199

182200

183201
docker_builder:
@@ -190,6 +208,7 @@ docker_builder:
190208
- analyze
191209
- tests-linux
192210
- tool_tests-linux
211+
- build_tests-linux
193212
build_script: "$CIRRUS_WORKING_DIR/dev/ci/docker_linux/docker_build.sh"
194213
login_script: "$CIRRUS_WORKING_DIR/dev/ci/docker_linux/docker_login.sh"
195214
push_script: "$CIRRUS_WORKING_DIR/dev/ci/docker_linux/docker_push.sh"

dev/bots/test.dart

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final List<String> flutterTestArgs = <String>[];
2121
const Map<String, ShardRunner> _kShards = <String, ShardRunner>{
2222
'tests': _runTests,
2323
'tool_tests': _runToolTests,
24-
'aot_build_tests': _runAotBuildTests,
24+
'build_tests': _runBuildTests,
2525
'coverage': _runCoverage,
2626
};
2727

@@ -150,25 +150,76 @@ Future<void> _runToolTests() async {
150150
print('${bold}DONE: All tests successful.$reset');
151151
}
152152

153-
/// Verifies that AOT builds of some examples apps finish
154-
/// without crashing. It does not actually launch the AOT-built
155-
/// apps. That happens later in the devicelab. This is just
156-
/// a smoke-test.
157-
Future<void> _runAotBuildTests() async {
158-
await _flutterBuildAot(path.join('examples', 'hello_world'));
159-
await _flutterBuildAot(path.join('examples', 'flutter_gallery'));
160-
await _flutterBuildAot(path.join('examples', 'flutter_view'));
153+
/// Verifies that AOT, APK, and IPA (if on macOS) builds of some
154+
/// examples apps finish without crashing. It does not actually
155+
/// launch the apps. That happens later in the devicelab. This is
156+
/// just a smoke-test. In particular, this will verify we can build
157+
/// when there are spaces in the path name for the Flutter SDK and
158+
/// target app.
159+
Future<void> _runBuildTests() async {
160+
final List<String> paths = <String>[
161+
path.join('examples', 'hello_world'),
162+
path.join('examples', 'flutter_gallery'),
163+
path.join('examples', 'flutter_view'),
164+
];
165+
for (String path in paths) {
166+
await _flutterBuildAot(path);
167+
await _flutterBuildApk(path);
168+
await _flutterBuildIpa(path);
169+
}
170+
171+
print('${bold}DONE: All build tests successful.$reset');
172+
}
173+
174+
Future<void> _flutterBuildAot(String relativePathToApplication) async {
175+
print('Running AOT build tests...');
176+
await runCommand(flutter,
177+
<String>['build', 'aot', '-v'],
178+
workingDirectory: path.join(flutterRoot, relativePathToApplication),
179+
expectNonZeroExit: false,
180+
timeout: _kShortTimeout,
181+
);
182+
print('Done.');
183+
}
161184

162-
print('${bold}DONE: All AOT build tests successful.$reset');
185+
Future<void> _flutterBuildApk(String relativePathToApplication) async {
186+
// TODO(dnfield): See if we can get Android SDK on all Cirrus platforms.
187+
if (Platform.environment['ANDROID_HOME']?.isEmpty ?? true) {
188+
return;
189+
}
190+
print('Running APK build tests...');
191+
await runCommand(flutter,
192+
<String>['build', 'apk', '--debug', '-v'],
193+
workingDirectory: path.join(flutterRoot, relativePathToApplication),
194+
expectNonZeroExit: false,
195+
timeout: _kShortTimeout,
196+
);
197+
print('Done.');
163198
}
164199

165-
Future<void> _flutterBuildAot(String relativePathToApplication) {
166-
return runCommand(flutter,
167-
<String>['build', 'aot'],
200+
Future<void> _flutterBuildIpa(String relativePathToApplication) async {
201+
if (!Platform.isMacOS) {
202+
return;
203+
}
204+
print('Running IPA build tests...');
205+
// Install Cocoapods. We don't have these checked in for the examples,
206+
// and build ios doesn't take care of it automatically.
207+
final File podfile = File(path.join(flutterRoot, relativePathToApplication, 'ios', 'Podfile'));
208+
if (podfile.existsSync()) {
209+
await runCommand('pod',
210+
<String>['install'],
211+
workingDirectory: podfile.parent.path,
212+
expectNonZeroExit: false,
213+
timeout: _kShortTimeout,
214+
);
215+
}
216+
await runCommand(flutter,
217+
<String>['build', 'ios', '--no-codesign', '--debug', '-v'],
168218
workingDirectory: path.join(flutterRoot, relativePathToApplication),
169219
expectNonZeroExit: false,
170220
timeout: _kShortTimeout,
171221
);
222+
print('Done.');
172223
}
173224

174225
Future<void> _runTests() async {

0 commit comments

Comments
 (0)