feat(shorebird_cli): improve artifact build failure messages (#2949)

This commit is contained in:
Felix Angelov
2025-03-11 11:35:24 -05:00
committed by GitHub
parent d23e52dcfd
commit 806c9b38dc
2 changed files with 45 additions and 17 deletions
@@ -141,7 +141,10 @@ class ArtifactBuilder {
final exitCode = await buildProcess.exitCode;
if (exitCode != ExitCode.success.code) {
throw ArtifactBuildException(
'Failed to build',
'''
Failed to build AAB.
Command: $executable ${arguments.join(' ')}
Reason: Exited with code $exitCode.''',
stderr: stderrLines,
stdout: stdoutLines,
);
@@ -208,10 +211,10 @@ class ArtifactBuilder {
);
if (result.exitCode != ExitCode.success.code) {
throw ArtifactBuildException.fromProcessResult(
'Failed to build',
buildProcessResult: result,
);
throw ArtifactBuildException.fromProcessResult('''
Failed to build APK.
Command: $executable ${arguments.join(' ')}
Reason: Exited with code $exitCode.''', buildProcessResult: result);
}
});
final projectRoot = shorebirdEnv.getShorebirdProjectRoot()!;
@@ -257,10 +260,10 @@ class ArtifactBuilder {
final result = await process.run(executable, arguments);
if (result.exitCode != ExitCode.success.code) {
throw ArtifactBuildException.fromProcessResult(
'Failed to build',
buildProcessResult: result,
);
throw ArtifactBuildException.fromProcessResult('''
Failed to build AAR.
Command: $executable ${arguments.join(' ')}
Reason: Exited with code $exitCode.''', buildProcessResult: result);
}
});
}
@@ -306,7 +309,10 @@ class ArtifactBuilder {
final exitCode = await buildProcess.exitCode;
if (exitCode != ExitCode.success.code) {
throw ArtifactBuildException(
'Failed to build',
'''
Failed to build linux app.
Command: $executable ${arguments.join(' ')}
Reason: Exited with code $exitCode.''',
stdout: stdoutLines,
stderr: stderrLines,
);
@@ -378,7 +384,10 @@ class ArtifactBuilder {
final exitCode = await buildProcess.exitCode;
if (exitCode != ExitCode.success.code) {
throw ArtifactBuildException(
'Failed to build',
'''
Failed to build macOS app.
Command: $executable ${arguments.join(' ')}
Reason: Exited with code $exitCode.''',
stdout: stdoutLines,
stderr: stderrLines,
);
@@ -458,7 +467,10 @@ class ArtifactBuilder {
if (exitCode != ExitCode.success.code) {
throw ArtifactBuildException(
'Failed to build',
'''
Failed to build IPA.
Command: $executable ${arguments.join(' ')}
Reason: Exited with code $exitCode.''',
stdout: stdoutLines,
stderr: stderrLines,
);
@@ -469,7 +481,10 @@ class ArtifactBuilder {
// https://github.com/shorebirdtech/shorebird/issues/2855
if (stderr.contains('Encountered error while creating the IPA')) {
throw ArtifactBuildException(
'Failed to build',
'''
Failed to build IPA.
Command: $executable ${arguments.join(' ')}
Reason: stderr contains "Encountered error while creating the IPA".''',
stdout: stdoutLines,
stderr: stderrLines,
);
@@ -507,7 +522,11 @@ class ArtifactBuilder {
final result = await process.run(executable, arguments);
if (result.exitCode != ExitCode.success.code) {
throw ArtifactBuildException('Failed to build: ${result.stderr}');
throw ArtifactBuildException('''
Failed to build iOS framework.
Command: $executable ${arguments.join(' ')}
Reason: Exited with code $exitCode.
''');
}
appDillPath = findAppDill(stdout: result.stdout.toString());
@@ -700,7 +700,10 @@ Either run `flutter pub get` manually, or follow the steps in ${cannotRunInVSCod
isA<ArtifactBuildException>().having(
(e) => e.message,
'message',
equals('Failed to build'),
equals('''
Failed to build linux app.
Command: flutter build linux --release
Reason: Exited with code 70.'''),
),
),
);
@@ -1129,7 +1132,10 @@ error: exportArchive: No signing certificate "iOS Distribution" found''',
() => runWithOverrides(() => builder.buildIpa(codesign: false)),
throwsA(
isA<ArtifactBuildException>()
.having((e) => e.message, 'message', 'Failed to build')
.having((e) => e.message, 'message', '''
Failed to build IPA.
Command: flutter build ipa --release --no-codesign
Reason: stderr contains "Encountered error while creating the IPA".''')
.having(
(e) => e.stderr,
'stderr',
@@ -1185,7 +1191,10 @@ error: exportArchive No signing certificate "iOS Distribution" found''',
() => runWithOverrides(() => builder.buildIpa(codesign: false)),
throwsA(
isA<ArtifactBuildException>()
.having((e) => e.message, 'message', 'Failed to build')
.having((e) => e.message, 'message', '''
Failed to build IPA.
Command: flutter build ipa --release --no-codesign
Reason: stderr contains "Encountered error while creating the IPA".''')
.having(
(e) => e.stderr,
'stderr',