chore(shorebird_cli): hide split-per-abi flag, print warning (#1255)

This commit is contained in:
Bryan Oltman
2023-09-11 18:09:01 -04:00
committed by GitHub
parent ba1c06dbff
commit 8c545281c9
3 changed files with 32 additions and 44 deletions
@@ -45,6 +45,7 @@ class ReleaseAndroidCommand extends ShorebirdCommand
'split-per-abi',
help: 'Whether to split the APKs per ABIs. '
'To learn more, see: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split',
hide: true,
negatable: false,
)
..addFlag(
@@ -81,15 +82,27 @@ make smaller updates to your app.
final flavor = results['flavor'] as String?;
final target = results['target'] as String?;
final generateApk = results['artifact'] as String == 'apk';
final splitApk = results['split-per-abi'] == true;
if (generateApk && splitApk) {
logger
..err(
'Shorebird does not support the split-per-abi option at this time',
)
..info(
'''
Split APKs are each given a different release version than what is specified in the pubspec.yaml.
See ${link(uri: Uri.parse('https://github.com/flutter/flutter/issues/39817'))} for more information about this issue.
Please comment and upvote ${link(uri: Uri.parse('https://github.com/shorebirdtech/shorebird/issues/1141'))} if you would like shorebird to support this.''',
);
return ExitCode.unavailable.code;
}
final buildProgress = logger.progress('Building release');
try {
await buildAppBundle(flavor: flavor, target: target);
if (generateApk) {
await buildApk(
flavor: flavor,
target: target,
splitPerAbi: results['split-per-abi'] == true,
);
await buildApk(flavor: flavor, target: target);
}
buildProgress.complete();
} on ProcessException catch (error) {
@@ -157,7 +157,11 @@ mixin ShorebirdBuildMixin on ShorebirdCommand {
'--release',
if (flavor != null) '--flavor=$flavor',
if (target != null) '--target=$target',
// TODO(bryanoltman): reintroduce coverage when we can support this.
// See https://github.com/shorebirdtech/shorebird/issues/1141.
// coverage:ignore-start
if (splitPerAbi) '--split-per-abi',
// coverage:ignore-end
...results.rest,
];
@@ -283,6 +283,16 @@ void main() {
).called(1);
});
test('exits with code unavailable when --split-per-abi is provided',
() async {
when(() => argResults['artifact']).thenReturn('apk');
when(() => argResults['split-per-abi']).thenReturn(true);
final exitCode = await runWithOverrides(command.run);
expect(exitCode, ExitCode.unavailable.code);
});
test('exits with code 70 when building fails', () async {
when(() => flutterBuildProcessResult.exitCode).thenReturn(1);
when(() => flutterBuildProcessResult.stderr).thenReturn('oops');
@@ -424,45 +434,6 @@ ${link(uri: Uri.parse('https://support.google.com/googleplay/android-developer/a
expect(exitCode, ExitCode.success.code);
});
test('succeeds when release is successful (with apk + split-per-abi)',
() async {
when(() => argResults['artifact']).thenReturn('apk');
when(() => argResults['split-per-abi']).thenReturn(true);
final exitCode = await runWithOverrides(command.run);
verify(() => logger.success('\n✅ Published Release!')).called(1);
verify(
() => codePushClientWrapper.createAndroidReleaseArtifacts(
appId: appId,
releaseId: release.id,
platform: releasePlatform,
aabPath: any(named: 'aabPath'),
architectures: any(named: 'architectures'),
),
).called(1);
verify(
() => codePushClientWrapper.updateReleaseStatus(
appId: appId,
releaseId: release.id,
platform: releasePlatform,
status: ReleaseStatus.active,
),
).called(1);
const buildApkArguments = [
'build',
'apk',
'--release',
'--split-per-abi',
];
verify(
() => shorebirdProcess.run(
'flutter',
buildApkArguments,
runInShell: true,
),
).called(1);
expect(exitCode, ExitCode.success.code);
});
test('runs flutter pub get with system flutter after successful build',
() async {
await runWithOverrides(command.run);