Skip to content

Commit

Permalink
feat(shorebird_cli): include link percentage in patch metadata (#1837)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel authored Mar 28, 2024
1 parent fcd4eb8 commit 2f2645b
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ ${summary.join('\n')}
hasAssetChanges: diffStatus.hasAssetChanges,
usedIgnoreNativeChangesFlag: allowNativeDiffs,
hasNativeChanges: diffStatus.hasNativeChanges,
linkPercentage: null,
environment: BuildEnvironmentMetadata(
operatingSystem: platform.operatingSystem,
operatingSystemVersion: platform.operatingSystemVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ ${summary.join('\n')}
hasAssetChanges: diffStatus.hasAssetChanges,
usedIgnoreNativeChangesFlag: allowNativeDiffs,
hasNativeChanges: diffStatus.hasNativeChanges,
linkPercentage: null,
environment: BuildEnvironmentMetadata(
operatingSystem: platform.operatingSystem,
operatingSystemVersion: platform.operatingSystemVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ ${summary.join('\n')}
hasAssetChanges: diffStatus.hasAssetChanges,
usedIgnoreNativeChangesFlag: allowNativeDiffs,
hasNativeChanges: diffStatus.hasNativeChanges,
linkPercentage: percentLinked,
environment: BuildEnvironmentMetadata(
operatingSystem: platform.operatingSystem,
operatingSystemVersion: platform.operatingSystemVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ ${summary.join('\n')}
hasAssetChanges: diffStatus.hasAssetChanges,
usedIgnoreNativeChangesFlag: allowNativeDiffs,
hasNativeChanges: diffStatus.hasNativeChanges,
linkPercentage: null,
environment: BuildEnvironmentMetadata(
operatingSystem: platform.operatingSystem,
operatingSystemVersion: platform.operatingSystemVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,7 @@ Please re-run the release command for this version or create a new release.'''),
hasAssetChanges: false,
usedIgnoreNativeChangesFlag: false,
hasNativeChanges: false,
linkPercentage: null,
environment: BuildEnvironmentMetadata(
shorebirdVersion: packageVersion,
operatingSystem: operatingSystem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@ Please re-run the release command for this version or create a new release.'''),
hasAssetChanges: false,
usedIgnoreNativeChangesFlag: false,
hasNativeChanges: false,
linkPercentage: null,
environment: BuildEnvironmentMetadata(
shorebirdVersion: packageVersion,
operatingSystem: operatingSystem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,20 @@ Please re-run the release command for this version or create a new release.'''),
});

test('generates diff base and publishes the appropriate patch', () async {
const linkPercentage = 99.9;
when(
() => aotTools.link(
base: any(named: 'base'),
patch: any(named: 'patch'),
analyzeSnapshot: any(named: 'analyzeSnapshot'),
genSnapshot: any(named: 'genSnapshot'),
kernel: any(named: 'kernel'),
workingDirectory: any(named: 'workingDirectory'),
outputPath: any(named: 'outputPath'),
),
).thenAnswer(
(_) async => linkPercentage,
);
await runWithOverrides(command.run);
verify(
() => codePushClientWrapper.publishPatch(
Expand All @@ -1362,6 +1376,7 @@ Please re-run the release command for this version or create a new release.'''),
hasAssetChanges: false,
usedIgnoreNativeChangesFlag: false,
hasNativeChanges: false,
linkPercentage: linkPercentage,
environment: BuildEnvironmentMetadata(
shorebirdVersion: packageVersion,
operatingSystem: operatingSystem,
Expand Down Expand Up @@ -1651,6 +1666,7 @@ flavors:
hasAssetChanges: false,
usedIgnoreNativeChangesFlag: false,
hasNativeChanges: false,
linkPercentage: null,
environment: BuildEnvironmentMetadata(
shorebirdVersion: packageVersion,
operatingSystem: operatingSystem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,7 @@ Please re-run the release command for this version or create a new release.'''),
hasAssetChanges: false,
usedIgnoreNativeChangesFlag: false,
hasNativeChanges: false,
linkPercentage: null,
environment: BuildEnvironmentMetadata(
shorebirdVersion: packageVersion,
operatingSystem: operatingSystem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CreatePatchMetadata extends Equatable {
required this.hasAssetChanges,
required this.usedIgnoreNativeChangesFlag,
required this.hasNativeChanges,
required this.linkPercentage,
required this.environment,
});

Expand All @@ -35,6 +36,7 @@ class CreatePatchMetadata extends Equatable {
bool hasAssetChanges = false,
bool usedIgnoreNativeChangesFlag = false,
bool hasNativeChanges = false,
double? linkPercentage,
BuildEnvironmentMetadata? environment,
}) =>
CreatePatchMetadata(
Expand All @@ -43,6 +45,7 @@ class CreatePatchMetadata extends Equatable {
hasAssetChanges: hasAssetChanges,
usedIgnoreNativeChangesFlag: usedIgnoreNativeChangesFlag,
hasNativeChanges: hasNativeChanges,
linkPercentage: linkPercentage,
environment: environment ?? BuildEnvironmentMetadata.forTest(),
);
// coverage:ignore-end
Expand Down Expand Up @@ -83,6 +86,12 @@ class CreatePatchMetadata extends Equatable {
/// behavior in a patch.
final bool hasNativeChanges;

/// The percentage of code that was linked in the patch.
/// Generally, the higher the percentage, the better the patch performance
/// since more code will be run on the CPU as opposed to the simulator.
/// Note: link percentage is currently only available for iOS patches.
final double? linkPercentage;

/// Properties about the environment in which the patch was created.
///
/// Reason: see [BuildEnvironmentMetadata].
Expand All @@ -95,6 +104,7 @@ class CreatePatchMetadata extends Equatable {
hasAssetChanges,
usedIgnoreNativeChangesFlag,
hasNativeChanges,
linkPercentage,
environment,
];
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void main() {
usedIgnoreNativeChangesFlag: false,
hasAssetChanges: true,
hasNativeChanges: false,
linkPercentage: 99.9,
environment: BuildEnvironmentMetadata(
operatingSystem: 'linux',
operatingSystemVersion: '1.0.0',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ void main() {
hasAssetChanges: false,
usedIgnoreNativeChangesFlag: false,
hasNativeChanges: false,
linkPercentage: 99.9,
environment: BuildEnvironmentMetadata(
operatingSystem: 'macos',
operatingSystemVersion: '1.2.3',
Expand All @@ -31,6 +32,7 @@ void main() {
hasAssetChanges: false,
usedIgnoreNativeChangesFlag: false,
hasNativeChanges: false,
linkPercentage: 99.9,
environment: BuildEnvironmentMetadata(
operatingSystem: 'macos',
operatingSystemVersion: '1.2.3',
Expand All @@ -44,6 +46,7 @@ void main() {
hasAssetChanges: false,
usedIgnoreNativeChangesFlag: false,
hasNativeChanges: false,
linkPercentage: 99.9,
environment: BuildEnvironmentMetadata(
operatingSystem: 'macos',
operatingSystemVersion: '1.2.3',
Expand All @@ -61,6 +64,7 @@ void main() {
hasAssetChanges: false,
usedIgnoreNativeChangesFlag: false,
hasNativeChanges: false,
linkPercentage: null,
environment: BuildEnvironmentMetadata(
operatingSystem: 'macos',
operatingSystemVersion: '1.2.3',
Expand All @@ -74,6 +78,7 @@ void main() {
hasAssetChanges: false,
usedIgnoreNativeChangesFlag: false,
hasNativeChanges: false,
linkPercentage: null,
environment: BuildEnvironmentMetadata(
operatingSystem: 'macos',
operatingSystemVersion: '1.2.3',
Expand Down

0 comments on commit 2f2645b

Please sign in to comment.