Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions packages/shorebird_cli/lib/src/shorebird_build_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down