From 64c6d6f8f11f3c69c7ee71979b077a28a2e52f7a Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 30 Jan 2024 13:12:54 -0500 Subject: [PATCH] [tool] Exempt federated impl examples from CHANGELOG 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. --- .../lib/src/common/package_state_utils.dart | 24 +++++++++++++++---- .../test/common/package_state_utils_test.dart | 21 ++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/script/tool/lib/src/common/package_state_utils.dart b/script/tool/lib/src/common/package_state_utils.dart index 51b76957cc5..400bcaea2bf 100644 --- a/script/tool/lib/src/common/package_state_utils.dart +++ b/script/tool/lib/src/common/package_state_utils.dart @@ -86,13 +86,29 @@ Future 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; } } diff --git a/script/tool/test/common/package_state_utils_test.dart b/script/tool/test/common/package_state_utils_test.dart index 0f7a83afa1d..7dcd2bf94af 100644 --- a/script/tool/test/common/package_state_utils_test.dart +++ b/script/tool/test/common/package_state_utils_test.dart @@ -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: ['example/lib/main.dart']); + + const List changedFiles = [ + '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 {