Skip to content

Commit

Permalink
[tool] Exempt federated impl examples from CHANGELOG (flutter#6018)
Browse files Browse the repository at this point in the history
The example app of a federated example is effectively test-only code, so treat changes to it (other than the one published file) as dev-only for the purposes of deciding what to flag for CHANGELOGs.
  • Loading branch information
stuartmorgan authored Jan 30, 2024
1 parent 07d1ad3 commit 95f2e50
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
24 changes: 20 additions & 4 deletions script/tool/lib/src/common/package_state_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,29 @@ Future<PackageChangeState> checkPackageChangeState(
continue;
}

// Some other changes don't need version changes, but might benefit from
// changelog changes.
final bool isUnpublishedExampleChange =
_isUnpublishedExampleChange(components, package);

// Since examples of federated plugin implementations are only intended
// for testing purposes, any unpublished example change in one of them is
// effectively a developer-only change.
if (package.isFederated &&
package.isPlatformImplementation &&
isUnpublishedExampleChange) {
continue;
}

// Anything that is not developer-only might benefit from changelog
// changes. This errs on the side of flagging, so that someone checks to
// see if it should be mentioned there or not.
needsChangelogChange = true;

// Most changes that aren't developer-only need version changes.
if (
// One of a few special files example will be shown on pub.dev, but
// for anything else in the example publishing has no purpose.
!_isUnpublishedExampleChange(components, package)) {
// for anything else in the example, publishing isn't necessary (even
// if it is relevant to mention in the CHANGELOG for the future).
!isUnpublishedExampleChange) {
needsVersionChange = true;
}
}
Expand Down
21 changes: 21 additions & 0 deletions script/tool/test/common/package_state_utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,27 @@ void main() {
expect(state.needsChangelogChange, true);
});

test(
'requires neither a changelog nor version change for README.md when '
'code example is present in a federated plugin implementation',
() async {
final RepositoryPackage package = createFakePlugin(
'a_plugin_android', packagesDir.childDirectory('a_plugin'),
extraFiles: <String>['example/lib/main.dart']);

const List<String> changedFiles = <String>[
'packages/a_plugin/a_plugin_android/example/README.md',
];

final PackageChangeState state = await checkPackageChangeState(package,
changedPaths: changedFiles,
relativePackagePath: 'packages/a_plugin/a_plugin_android');

expect(state.hasChanges, true);
expect(state.needsVersionChange, false);
expect(state.needsChangelogChange, false);
});

test(
'does not requires changelog or version change for build.gradle '
'test-dependency-only changes', () async {
Expand Down

0 comments on commit 95f2e50

Please sign in to comment.