From 8c545281c92c127fa6e7bed90aba0a4a62e3db5e Mon Sep 17 00:00:00 2001 From: Bryan Oltman Date: Mon, 11 Sep 2023 18:09:01 -0400 Subject: [PATCH] chore(shorebird_cli): hide split-per-abi flag, print warning (#1255) --- .../release/release_android_command.dart | 23 +++++++-- .../lib/src/shorebird_build_mixin.dart | 4 ++ .../release/release_android_command_test.dart | 49 ++++--------------- 3 files changed, 32 insertions(+), 44 deletions(-) diff --git a/packages/shorebird_cli/lib/src/commands/release/release_android_command.dart b/packages/shorebird_cli/lib/src/commands/release/release_android_command.dart index d65c344e..cd78ed77 100644 --- a/packages/shorebird_cli/lib/src/commands/release/release_android_command.dart +++ b/packages/shorebird_cli/lib/src/commands/release/release_android_command.dart @@ -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) { diff --git a/packages/shorebird_cli/lib/src/shorebird_build_mixin.dart b/packages/shorebird_cli/lib/src/shorebird_build_mixin.dart index 8d3d6577..5fab16b2 100644 --- a/packages/shorebird_cli/lib/src/shorebird_build_mixin.dart +++ b/packages/shorebird_cli/lib/src/shorebird_build_mixin.dart @@ -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, ]; diff --git a/packages/shorebird_cli/test/src/commands/release/release_android_command_test.dart b/packages/shorebird_cli/test/src/commands/release/release_android_command_test.dart index 5e3c16fc..b3c6279d 100644 --- a/packages/shorebird_cli/test/src/commands/release/release_android_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/release/release_android_command_test.dart @@ -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);