fix(shorebird_cli): flutter revision detection in shorebird release (#1017)
This commit is contained in:
@@ -12,7 +12,6 @@ import 'package:shorebird_cli/src/shorebird_build_mixin.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_env.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_release_version_mixin.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_validator.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_version_manager.dart';
|
||||
import 'package:shorebird_code_push_client/shorebird_code_push_client.dart';
|
||||
|
||||
/// {@template release_aar_command}
|
||||
@@ -135,19 +134,6 @@ ${summary.join('\n')}
|
||||
}
|
||||
}
|
||||
|
||||
final flutterRevisionProgress = logger.progress(
|
||||
'Fetching Flutter revision',
|
||||
);
|
||||
final String shorebirdFlutterRevision;
|
||||
try {
|
||||
shorebirdFlutterRevision =
|
||||
await shorebirdVersionManager.fetchCurrentGitHash();
|
||||
flutterRevisionProgress.complete();
|
||||
} catch (error) {
|
||||
flutterRevisionProgress.fail('$error');
|
||||
return ExitCode.software.code;
|
||||
}
|
||||
|
||||
final Release release;
|
||||
if (existingRelease != null) {
|
||||
release = existingRelease;
|
||||
@@ -161,7 +147,7 @@ ${summary.join('\n')}
|
||||
release = await codePushClientWrapper.createRelease(
|
||||
appId: appId,
|
||||
version: releaseVersion,
|
||||
flutterRevision: shorebirdFlutterRevision,
|
||||
flutterRevision: shorebirdEnv.flutterRevision,
|
||||
platform: platform,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import 'package:shorebird_cli/src/shorebird_build_mixin.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_env.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_release_version_mixin.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_validator.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_version_manager.dart';
|
||||
import 'package:shorebird_code_push_client/shorebird_code_push_client.dart';
|
||||
|
||||
/// {@template release_android_command}
|
||||
@@ -161,19 +160,6 @@ ${summary.join('\n')}
|
||||
}
|
||||
}
|
||||
|
||||
final flutterRevisionProgress = logger.progress(
|
||||
'Fetching Flutter revision',
|
||||
);
|
||||
final String shorebirdFlutterRevision;
|
||||
try {
|
||||
shorebirdFlutterRevision =
|
||||
await shorebirdVersionManager.fetchCurrentGitHash();
|
||||
flutterRevisionProgress.complete();
|
||||
} catch (error) {
|
||||
flutterRevisionProgress.fail('$error');
|
||||
return ExitCode.software.code;
|
||||
}
|
||||
|
||||
final Release release;
|
||||
if (existingRelease != null) {
|
||||
release = existingRelease;
|
||||
@@ -187,7 +173,7 @@ ${summary.join('\n')}
|
||||
release = await codePushClientWrapper.createRelease(
|
||||
appId: appId,
|
||||
version: releaseVersion,
|
||||
flutterRevision: shorebirdFlutterRevision,
|
||||
flutterRevision: shorebirdEnv.flutterRevision,
|
||||
platform: platform,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import 'package:shorebird_cli/src/shorebird_artifact_mixin.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_build_mixin.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_env.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_validator.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_version_manager.dart';
|
||||
import 'package:shorebird_code_push_client/shorebird_code_push_client.dart';
|
||||
|
||||
/// {@template release_ios_command}
|
||||
@@ -160,19 +159,6 @@ ${summary.join('\n')}
|
||||
}
|
||||
}
|
||||
|
||||
final flutterRevisionProgress = logger.progress(
|
||||
'Fetching Flutter revision',
|
||||
);
|
||||
final String shorebirdFlutterRevision;
|
||||
try {
|
||||
shorebirdFlutterRevision =
|
||||
await shorebirdVersionManager.fetchCurrentGitHash();
|
||||
flutterRevisionProgress.complete();
|
||||
} catch (error) {
|
||||
flutterRevisionProgress.fail('$error');
|
||||
return ExitCode.software.code;
|
||||
}
|
||||
|
||||
final Release release;
|
||||
if (existingRelease != null) {
|
||||
release = existingRelease;
|
||||
@@ -186,7 +172,7 @@ ${summary.join('\n')}
|
||||
release = await codePushClientWrapper.createRelease(
|
||||
appId: appId,
|
||||
version: releaseVersion,
|
||||
flutterRevision: shorebirdFlutterRevision,
|
||||
flutterRevision: shorebirdEnv.flutterRevision,
|
||||
platform: releasePlatform,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import 'package:shorebird_cli/src/logger.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_build_mixin.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_env.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_validator.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_version_manager.dart';
|
||||
import 'package:shorebird_code_push_client/shorebird_code_push_client.dart';
|
||||
|
||||
class ReleaseIosFrameworkCommand extends ShorebirdCommand
|
||||
@@ -108,19 +107,6 @@ ${summary.join('\n')}
|
||||
}
|
||||
}
|
||||
|
||||
final flutterRevisionProgress = logger.progress(
|
||||
'Fetching Flutter revision',
|
||||
);
|
||||
final String shorebirdFlutterRevision;
|
||||
try {
|
||||
shorebirdFlutterRevision =
|
||||
await shorebirdVersionManager.fetchCurrentGitHash();
|
||||
flutterRevisionProgress.complete();
|
||||
} catch (error) {
|
||||
flutterRevisionProgress.fail('$error');
|
||||
return ExitCode.software.code;
|
||||
}
|
||||
|
||||
final Release release;
|
||||
if (existingRelease != null) {
|
||||
release = existingRelease;
|
||||
@@ -128,7 +114,7 @@ ${summary.join('\n')}
|
||||
release = await codePushClientWrapper.createRelease(
|
||||
appId: appId,
|
||||
version: releaseVersion,
|
||||
flutterRevision: shorebirdFlutterRevision,
|
||||
flutterRevision: shorebirdEnv.flutterRevision,
|
||||
platform: releasePlatform,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import 'package:shorebird_cli/src/process.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_build_mixin.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_env.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_validator.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_version_manager.dart';
|
||||
import 'package:shorebird_code_push_client/shorebird_code_push_client.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -47,9 +46,6 @@ class _MockShorebirdEnv extends Mock implements ShorebirdEnv {}
|
||||
|
||||
class _MockShorebirdValidator extends Mock implements ShorebirdValidator {}
|
||||
|
||||
class _MockShorebirdVersionManager extends Mock
|
||||
implements ShorebirdVersionManager {}
|
||||
|
||||
class _FakeRelease extends Fake implements Release {}
|
||||
|
||||
class _FakeShorebirdProcess extends Fake implements ShorebirdProcess {}
|
||||
@@ -89,7 +85,6 @@ void main() {
|
||||
late ShorebirdEnv shorebirdEnv;
|
||||
late ShorebirdProcess shorebirdProcess;
|
||||
late ShorebirdValidator shorebirdValidator;
|
||||
late ShorebirdVersionManager shorebirdVersionManager;
|
||||
late ReleaseAarCommand command;
|
||||
|
||||
R runWithOverrides<R>(R Function() body) {
|
||||
@@ -105,9 +100,6 @@ void main() {
|
||||
processRef.overrideWith(() => shorebirdProcess),
|
||||
shorebirdEnvRef.overrideWith(() => shorebirdEnv),
|
||||
shorebirdValidatorRef.overrideWith(() => shorebirdValidator),
|
||||
shorebirdVersionManagerRef.overrideWith(
|
||||
() => shorebirdVersionManager,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -163,7 +155,6 @@ void main() {
|
||||
shorebirdRoot = Directory.systemTemp.createTempSync();
|
||||
shorebirdEnv = _MockShorebirdEnv();
|
||||
shorebirdValidator = _MockShorebirdValidator();
|
||||
shorebirdVersionManager = _MockShorebirdVersionManager();
|
||||
|
||||
when(() => auth.client).thenReturn(httpClient);
|
||||
when(() => argResults['build-number']).thenReturn(buildNumber);
|
||||
@@ -178,6 +169,7 @@ void main() {
|
||||
when(
|
||||
() => shorebirdEnv.androidPackageName,
|
||||
).thenReturn(androidPackageName);
|
||||
when(() => shorebirdEnv.flutterRevision).thenReturn(flutterRevision);
|
||||
|
||||
when(
|
||||
() => flutterBuildProcessResult.exitCode,
|
||||
@@ -241,9 +233,6 @@ void main() {
|
||||
checkShorebirdInitialized: any(named: 'checkShorebirdInitialized'),
|
||||
),
|
||||
).thenAnswer((_) async {});
|
||||
when(
|
||||
() => shorebirdVersionManager.fetchCurrentGitHash(),
|
||||
).thenAnswer((_) async => flutterRevision);
|
||||
|
||||
command = runWithOverrides(
|
||||
() => ReleaseAarCommand(unzipFn: (_, __) async {}),
|
||||
@@ -322,16 +311,6 @@ void main() {
|
||||
verify(() => logger.info('Aborting.')).called(1);
|
||||
});
|
||||
|
||||
test('throws error when unable to detect flutter revision', () async {
|
||||
final exception = Exception('oops');
|
||||
when(
|
||||
() => shorebirdVersionManager.fetchCurrentGitHash(),
|
||||
).thenThrow(exception);
|
||||
final exitCode = await runWithOverrides(command.run);
|
||||
expect(exitCode, ExitCode.software.code);
|
||||
verify(() => progress.fail('$exception')).called(1);
|
||||
});
|
||||
|
||||
test('does not prompt for confirmation when --force is used', () async {
|
||||
when(() => argResults['force']).thenReturn(true);
|
||||
final tempDir = setUpTempArtifacts();
|
||||
|
||||
@@ -20,7 +20,6 @@ import 'package:shorebird_cli/src/platform.dart';
|
||||
import 'package:shorebird_cli/src/process.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_env.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_validator.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_version_manager.dart';
|
||||
import 'package:shorebird_cli/src/validators/validators.dart';
|
||||
import 'package:shorebird_code_push_client/shorebird_code_push_client.dart';
|
||||
import 'package:test/test.dart';
|
||||
@@ -57,9 +56,6 @@ class _MockShorebirdEnv extends Mock implements ShorebirdEnv {}
|
||||
|
||||
class _MockShorebirdValidator extends Mock implements ShorebirdValidator {}
|
||||
|
||||
class _MockShorebirdVersionManager extends Mock
|
||||
implements ShorebirdVersionManager {}
|
||||
|
||||
class _MockJava extends Mock implements Java {}
|
||||
|
||||
class _FakeRelease extends Fake implements Release {}
|
||||
@@ -106,7 +102,6 @@ void main() {
|
||||
late ShorebirdProcess shorebirdProcess;
|
||||
late ShorebirdEnv shorebirdEnv;
|
||||
late ShorebirdValidator shorebirdValidator;
|
||||
late ShorebirdVersionManager shorebirdVersionManager;
|
||||
late ReleaseAndroidCommand command;
|
||||
|
||||
R runWithOverrides<R>(R Function() body) {
|
||||
@@ -125,9 +120,6 @@ void main() {
|
||||
processRef.overrideWith(() => shorebirdProcess),
|
||||
shorebirdEnvRef.overrideWith(() => shorebirdEnv),
|
||||
shorebirdValidatorRef.overrideWith(() => shorebirdValidator),
|
||||
shorebirdVersionManagerRef.overrideWith(
|
||||
() => shorebirdVersionManager,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -157,10 +149,10 @@ void main() {
|
||||
shorebirdProcess = _MockShorebirdProcess();
|
||||
shorebirdEnv = _MockShorebirdEnv();
|
||||
shorebirdValidator = _MockShorebirdValidator();
|
||||
shorebirdVersionManager = _MockShorebirdVersionManager();
|
||||
|
||||
when(() => shorebirdEnv.getShorebirdYaml()).thenReturn(shorebirdYaml);
|
||||
when(() => shorebirdEnv.shorebirdRoot).thenReturn(shorebirdRoot);
|
||||
when(() => shorebirdEnv.flutterRevision).thenReturn(flutterRevision);
|
||||
|
||||
when(
|
||||
() => shorebirdProcess.run(
|
||||
@@ -247,9 +239,6 @@ void main() {
|
||||
supportedOperatingSystems: any(named: 'supportedOperatingSystems'),
|
||||
),
|
||||
).thenAnswer((_) async {});
|
||||
when(
|
||||
() => shorebirdVersionManager.fetchCurrentGitHash(),
|
||||
).thenAnswer((_) async => flutterRevision);
|
||||
|
||||
command = runWithOverrides(ReleaseAndroidCommand.new)
|
||||
..testArgResults = argResults;
|
||||
@@ -329,16 +318,6 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('throws error when unable to detect flutter revision', () async {
|
||||
final exception = Exception('oops');
|
||||
when(
|
||||
() => shorebirdVersionManager.fetchCurrentGitHash(),
|
||||
).thenThrow(exception);
|
||||
final exitCode = await runWithOverrides(command.run);
|
||||
expect(exitCode, ExitCode.software.code);
|
||||
verify(() => progress.fail('$exception')).called(1);
|
||||
});
|
||||
|
||||
test(
|
||||
'does not prompt for confirmation '
|
||||
'when --release-version and --force are used', () async {
|
||||
|
||||
@@ -18,7 +18,6 @@ import 'package:shorebird_cli/src/platform.dart';
|
||||
import 'package:shorebird_cli/src/process.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_env.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_validator.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_version_manager.dart';
|
||||
import 'package:shorebird_cli/src/validators/validators.dart';
|
||||
import 'package:shorebird_code_push_client/shorebird_code_push_client.dart';
|
||||
import 'package:test/test.dart';
|
||||
@@ -53,9 +52,6 @@ class _MockShorebirdEnv extends Mock implements ShorebirdEnv {}
|
||||
|
||||
class _MockShorebirdValidator extends Mock implements ShorebirdValidator {}
|
||||
|
||||
class _MockShorebirdVersionManager extends Mock
|
||||
implements ShorebirdVersionManager {}
|
||||
|
||||
class _FakeRelease extends Fake implements Release {}
|
||||
|
||||
class _FakeShorebirdProcess extends Fake implements ShorebirdProcess {}
|
||||
@@ -115,7 +111,6 @@ flutter:
|
||||
late ShorebirdProcess shorebirdProcess;
|
||||
late ShorebirdEnv shorebirdEnv;
|
||||
late ShorebirdValidator shorebirdValidator;
|
||||
late ShorebirdVersionManager shorebirdVersionManager;
|
||||
late ReleaseIosCommand command;
|
||||
|
||||
R runWithOverrides<R>(R Function() body) {
|
||||
@@ -130,9 +125,6 @@ flutter:
|
||||
processRef.overrideWith(() => shorebirdProcess),
|
||||
shorebirdEnvRef.overrideWith(() => shorebirdEnv),
|
||||
shorebirdValidatorRef.overrideWith(() => shorebirdValidator),
|
||||
shorebirdVersionManagerRef.overrideWith(
|
||||
() => shorebirdVersionManager,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -177,10 +169,10 @@ flutter:
|
||||
shorebirdProcess = _MockShorebirdProcess();
|
||||
shorebirdEnv = _MockShorebirdEnv();
|
||||
shorebirdValidator = _MockShorebirdValidator();
|
||||
shorebirdVersionManager = _MockShorebirdVersionManager();
|
||||
|
||||
when(() => shorebirdEnv.getShorebirdYaml()).thenReturn(shorebirdYaml);
|
||||
when(() => shorebirdEnv.shorebirdRoot).thenReturn(shorebirdRoot);
|
||||
when(() => shorebirdEnv.flutterRevision).thenReturn(flutterRevision);
|
||||
when(
|
||||
() => shorebirdProcess.run(
|
||||
'flutter',
|
||||
@@ -252,9 +244,6 @@ flutter:
|
||||
supportedOperatingSystems: any(named: 'supportedOperatingSystems'),
|
||||
),
|
||||
).thenAnswer((_) async {});
|
||||
when(
|
||||
() => shorebirdVersionManager.fetchCurrentGitHash(),
|
||||
).thenAnswer((_) async => flutterRevision);
|
||||
|
||||
command = runWithOverrides(() => ReleaseIosCommand(ipaReader: ipaReader))
|
||||
..testArgResults = argResults;
|
||||
@@ -450,21 +439,6 @@ error: exportArchive: No signing certificate "iOS Distribution" found
|
||||
).called(1);
|
||||
});
|
||||
|
||||
test('throws error when unable to detect flutter revision', () async {
|
||||
final exception = Exception('oops');
|
||||
when(
|
||||
() => shorebirdVersionManager.fetchCurrentGitHash(),
|
||||
).thenThrow(exception);
|
||||
final tempDir = setUpTempDir();
|
||||
|
||||
final exitCode = await IOOverrides.runZoned(
|
||||
() => runWithOverrides(command.run),
|
||||
getCurrentDirectory: () => tempDir,
|
||||
);
|
||||
expect(exitCode, ExitCode.software.code);
|
||||
verify(() => progress.fail('$exception')).called(1);
|
||||
});
|
||||
|
||||
test(
|
||||
'does not prompt for confirmation '
|
||||
'when --release-version and --force are used', () async {
|
||||
|
||||
+1
-27
@@ -16,7 +16,6 @@ import 'package:shorebird_cli/src/platform.dart';
|
||||
import 'package:shorebird_cli/src/process.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_env.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_validator.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_version_manager.dart';
|
||||
import 'package:shorebird_cli/src/validators/validators.dart';
|
||||
import 'package:shorebird_code_push_client/shorebird_code_push_client.dart';
|
||||
import 'package:test/test.dart';
|
||||
@@ -47,9 +46,6 @@ class _MockShorebirdEnv extends Mock implements ShorebirdEnv {}
|
||||
|
||||
class _MockShorebirdValidator extends Mock implements ShorebirdValidator {}
|
||||
|
||||
class _MockShorebirdVersionManager extends Mock
|
||||
implements ShorebirdVersionManager {}
|
||||
|
||||
class _FakeRelease extends Fake implements Release {}
|
||||
|
||||
class _FakeShorebirdProcess extends Fake implements ShorebirdProcess {}
|
||||
@@ -96,7 +92,6 @@ flutter:
|
||||
late ShorebirdProcess shorebirdProcess;
|
||||
late ShorebirdEnv shorebirdEnv;
|
||||
late ShorebirdValidator shorebirdValidator;
|
||||
late ShorebirdVersionManager shorebirdVersionManager;
|
||||
late ReleaseIosFrameworkCommand command;
|
||||
|
||||
R runWithOverrides<R>(R Function() body) {
|
||||
@@ -111,9 +106,6 @@ flutter:
|
||||
processRef.overrideWith(() => shorebirdProcess),
|
||||
shorebirdEnvRef.overrideWith(() => shorebirdEnv),
|
||||
shorebirdValidatorRef.overrideWith(() => shorebirdValidator),
|
||||
shorebirdVersionManagerRef.overrideWith(
|
||||
() => shorebirdVersionManager,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -150,10 +142,10 @@ flutter:
|
||||
shorebirdProcess = _MockShorebirdProcess();
|
||||
shorebirdEnv = _MockShorebirdEnv();
|
||||
shorebirdValidator = _MockShorebirdValidator();
|
||||
shorebirdVersionManager = _MockShorebirdVersionManager();
|
||||
|
||||
when(() => shorebirdEnv.getShorebirdYaml()).thenReturn(shorebirdYaml);
|
||||
when(() => shorebirdEnv.shorebirdRoot).thenReturn(shorebirdRoot);
|
||||
when(() => shorebirdEnv.flutterRevision).thenReturn(flutterRevision);
|
||||
when(
|
||||
() => shorebirdProcess.run(
|
||||
'flutter',
|
||||
@@ -218,9 +210,6 @@ flutter:
|
||||
supportedOperatingSystems: any(named: 'supportedOperatingSystems'),
|
||||
),
|
||||
).thenAnswer((_) async {});
|
||||
when(
|
||||
() => shorebirdVersionManager.fetchCurrentGitHash(),
|
||||
).thenAnswer((_) async => flutterRevision);
|
||||
|
||||
command = runWithOverrides(ReleaseIosFrameworkCommand.new)
|
||||
..testArgResults = argResults;
|
||||
@@ -314,21 +303,6 @@ flutter:
|
||||
);
|
||||
});
|
||||
|
||||
test('throws error when unable to detect flutter revision', () async {
|
||||
final exception = Exception('oops');
|
||||
when(
|
||||
() => shorebirdVersionManager.fetchCurrentGitHash(),
|
||||
).thenThrow(exception);
|
||||
final tempDir = setUpTempDir();
|
||||
|
||||
final exitCode = await IOOverrides.runZoned(
|
||||
() => runWithOverrides(command.run),
|
||||
getCurrentDirectory: () => tempDir,
|
||||
);
|
||||
expect(exitCode, ExitCode.software.code);
|
||||
verify(() => progress.fail('$exception')).called(1);
|
||||
});
|
||||
|
||||
test(
|
||||
'does not prompt for confirmation '
|
||||
'when --release-version and --force are used', () async {
|
||||
|
||||
Reference in New Issue
Block a user