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

refactor(shorebird_cli): rename stable deployment track for consistency #2619

Merged
merged 3 commits into from
Nov 13, 2024
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
15 changes: 10 additions & 5 deletions packages/shorebird_cli/lib/src/commands/patch/patch_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ of the iOS app that is using this module.''',
'track',
allowed: DeploymentTrack.values.map((v) => v.channel),
help: 'The track to publish the patch to.',
defaultsTo: DeploymentTrack.production.channel,
defaultsTo: DeploymentTrack.stable.channel,
)
..addFlag(
'staging',
Expand Down Expand Up @@ -441,15 +441,20 @@ Please re-run the release command for this version or create a new release.''');
final size = formatBytes(patchArtifactBundles[arch]!.size);
return '${arch.name} ($size)';
});
final trackSummary = (() {
return switch (track) {
DeploymentTrack.staging => '🟠 Track: ${lightCyan.wrap('Staging')}',
DeploymentTrack.beta => '🔵 Track: ${lightCyan.wrap('Beta')}',
DeploymentTrack.stable => '🟢 Track: ${lightCyan.wrap('Stable')}',
};
})();

final summary = [
'''📱 App: ${lightCyan.wrap(app.displayName)} ${lightCyan.wrap('(${app.appId})')}''',
if (flavor != null) '🍧 Flavor: ${lightCyan.wrap(flavor)}',
'📦 Release Version: ${lightCyan.wrap(releaseVersion)}',
'''🕹️ Platform: ${lightCyan.wrap(patcher.releaseType.releasePlatform.name)} ${lightCyan.wrap('[${archMetadata.join(', ')}]')}''',
if (isStaging)
'🟠 Track: ${lightCyan.wrap('Staging')}'
else
'🟢 Track: ${lightCyan.wrap('Production')}',
trackSummary,
if (patcher.linkPercentage != null &&
patcher.linkPercentage! < Patcher.minLinkPercentage)
'''🔍 Debug Info: ${lightCyan.wrap(patcher.debugInfoFile.path)}''',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ class PromoteCommand extends ShorebirdCommand {
return ExitCode.usage.code;
}

if (patchToPromote.channel == DeploymentTrack.production.channel) {
if (patchToPromote.channel == DeploymentTrack.stable.channel) {
logger.err('Patch ${patchToPromote.number} is already live');
return ExitCode.usage.code;
}

final channel = await codePushClientWrapper.maybeGetChannel(
appId: appId,
name: DeploymentTrack.production.channel,
name: DeploymentTrack.stable.channel,
);
if (channel == null) {
// This is a symptom that something bigger is wrong. Apps should always
Expand Down
6 changes: 2 additions & 4 deletions packages/shorebird_cli/lib/src/commands/preview_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@ class PreviewCommand extends ShorebirdCommand {

final deviceId = results['device-id'] as String?;
final isStaging = results['staging'] == true;
final track =
isStaging ? DeploymentTrack.staging : DeploymentTrack.production;
final track = isStaging ? DeploymentTrack.staging : DeploymentTrack.stable;

return switch (releasePlatform) {
ReleasePlatform.android => installAndLaunchAndroid(
Expand Down Expand Up @@ -589,8 +588,7 @@ class PreviewCommand extends ShorebirdCommand {
final yaml = loadYaml(yamlText) as YamlMap;
final yamlChannel = yaml['channel'];

if (yamlChannel == null &&
channel == DeploymentTrack.production.channel) {
if (yamlChannel == null && channel == DeploymentTrack.stable.channel) {
// We would be updating the channel to the default value.
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/shorebird_cli/lib/src/deployment_track.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ enum DeploymentTrack {
beta('beta'),

/// A public track for publishing changes to production.
production('stable');
stable('stable');

const DeploymentTrack(this.channel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void main() {
createdAt: DateTime(2023),
updatedAt: DateTime(2023),
);
const track = DeploymentTrack.production;
const track = DeploymentTrack.stable;
final channel = Channel(id: 0, appId: appId, name: track.channel);
const patchId = 1;
const patchNumber = 2;
Expand Down Expand Up @@ -829,7 +829,7 @@ You can manage this release in the ${link(uri: uri, message: 'Shorebird Console'
final patch = ReleasePatch(
id: 0,
number: 1,
channel: DeploymentTrack.production.channel,
channel: DeploymentTrack.stable.channel,
isRolledBack: false,
artifacts: const [],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void main() {

setUpAll(() {
registerFallbackValue(CreatePatchMetadata.forTest());
registerFallbackValue(DeploymentTrack.production);
registerFallbackValue(DeploymentTrack.stable);
registerFallbackValue(FakeDiffStatus());
registerFallbackValue(Directory(''));
registerFallbackValue(File(''));
Expand Down Expand Up @@ -160,7 +160,7 @@ void main() {
when(() => argResults['release-version']).thenReturn(releaseVersion);
when(
() => argResults['track'],
).thenReturn(DeploymentTrack.production.channel);
).thenReturn(DeploymentTrack.stable.channel);
when(() => argResults.wasParsed(any())).thenReturn(true);
when(() => argResults.wasParsed('staging')).thenReturn(false);
when(
Expand Down Expand Up @@ -490,7 +490,7 @@ void main() {
'🍧 Flavor: ${lightCyan.wrap(flavor)}',
'📦 Release Version: ${lightCyan.wrap(releaseVersion)}',
'''🕹️ Platform: ${lightCyan.wrap(patcher.releaseType.releasePlatform.name)} ${lightCyan.wrap('[arm32 (42 B)]')}''',
'🟢 Track: ${lightCyan.wrap('Production')}',
'🟢 Track: ${lightCyan.wrap('Stable')}',
];
await expectLater(
runWithOverrides(
Expand Down Expand Up @@ -544,6 +544,39 @@ void main() {
});
});

group('when is beta', () {
setUp(() {
when(
() => argResults['track'],
).thenReturn(DeploymentTrack.beta.channel);
});

test('logs correct summary', () async {
final expectedSummary = [
'''📱 App: ${lightCyan.wrap(appDisplayName)} ${lightCyan.wrap('($appId)')}''',
'📦 Release Version: ${lightCyan.wrap(releaseVersion)}',
'''🕹️ Platform: ${lightCyan.wrap(patcher.releaseType.releasePlatform.name)} ${lightCyan.wrap('[arm32 (42 B)]')}''',
'🔵 Track: ${lightCyan.wrap('Beta')}',
];
await expectLater(
runWithOverrides(
() => command.confirmCreatePatch(
app: appMetadata,
releaseVersion: releaseVersion,
patcher: patcher,
patchArtifactBundles: patchArtifactBundles,
),
),
completes,
);
verify(
() => logger.info(
any(that: contains(expectedSummary.join('\n'))),
),
).called(1);
});
});

group('when has link percentage', () {
const linkPercentage = 42.1337;
final debugInfoFile = File('debug-info.txt');
Expand All @@ -558,7 +591,7 @@ void main() {
'''📱 App: ${lightCyan.wrap(appDisplayName)} ${lightCyan.wrap('($appId)')}''',
'📦 Release Version: ${lightCyan.wrap(releaseVersion)}',
'''🕹️ Platform: ${lightCyan.wrap(patcher.releaseType.releasePlatform.name)} ${lightCyan.wrap('[arm32 (42 B)]')}''',
'🟢 Track: ${lightCyan.wrap('Production')}',
'🟢 Track: ${lightCyan.wrap('Stable')}',
'''🔍 Debug Info: ${lightCyan.wrap(patcher.debugInfoFile.path)}''',
];
await expectLater(
Expand Down Expand Up @@ -643,7 +676,7 @@ void main() {
releaseId: release.id,
metadata: patchMetadata.toJson(),
artifacts: any(named: 'artifacts'),
track: DeploymentTrack.production,
track: DeploymentTrack.stable,
),
]);
});
Expand Down Expand Up @@ -693,7 +726,7 @@ void main() {
releaseId: release.id,
metadata: any(named: 'metadata'),
artifacts: any(named: 'artifacts'),
track: DeploymentTrack.production,
track: DeploymentTrack.stable,
),
]);

Expand Down Expand Up @@ -814,7 +847,7 @@ void main() {
releaseId: release.id,
metadata: any(named: 'metadata'),
artifacts: any(named: 'artifacts'),
track: DeploymentTrack.production,
track: DeploymentTrack.stable,
),
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void main() {
group(Patcher, () {
setUpAll(() {
registerFallbackValue(ReleasePlatform.android);
registerFallbackValue(DeploymentTrack.production);
registerFallbackValue(DeploymentTrack.stable);
});

group('linkPercentage', () {
Expand Down Expand Up @@ -185,7 +185,7 @@ void main() {
const releaseId = 42;
const metadata = <String, String>{};
const artifacts = <Arch, PatchArtifactBundle>{};
const track = DeploymentTrack.production;
const track = DeploymentTrack.stable;
final codePushClientWrapper = MockCodePushClientWrapper();
when(
() => codePushClientWrapper.publishPatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void main() {
final stableChannel = Channel(
id: 0,
appId: appId,
name: DeploymentTrack.production.channel,
name: DeploymentTrack.stable.channel,
);
final release = Release(
id: 0,
Expand Down Expand Up @@ -135,7 +135,7 @@ void main() {
final prodPatch = ReleasePatch(
id: 0,
number: 1,
channel: DeploymentTrack.production.channel,
channel: DeploymentTrack.stable.channel,
isRolledBack: false,
artifacts: const [],
);
Expand All @@ -160,7 +160,7 @@ void main() {
when(
() => codePushClientWrapper.maybeGetChannel(
appId: any(named: 'appId'),
name: DeploymentTrack.production.channel,
name: DeploymentTrack.stable.channel,
),
).thenAnswer((_) async => null);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void main() {
const appId = 'test-app-id';
const appDisplayName = 'Test App';
const releaseVersion = '1.2.3';
const track = DeploymentTrack.production;
const track = DeploymentTrack.stable;
const releaseId = 42;
const androidArtifactId = 21;
const iosArtifactId = 12;
Expand Down Expand Up @@ -479,7 +479,7 @@ void main() {
await runWithOverrides(
() => command.setChannelOnAab(
aabFile: aabFile,
channel: DeploymentTrack.production.channel,
channel: DeploymentTrack.stable.channel,
),
);

Expand Down
Loading