-
-
Notifications
You must be signed in to change notification settings - Fork 5
Update release spec to only list changed packages #23
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
Conversation
|
c703a77
to
d422085
Compare
6c124d0
to
34ccbf1
Compare
Rebased! |
34ccbf1
to
3b55821
Compare
This has been rebased again and is now ready for review. |
This PR adds a new property to the Package object, `hasChangesSinceLatestRelease`. This property is computed when a package is read from a project by running a diff between the last-created Git tag associated with that package and whatever the HEAD commit happens to be, then checking to see whether any of the files changed belong to that package. If they do, then `hasChangesSinceLatestRelease` is true, otherwise it's false. This property is then used to filter the list of packages that are placed within the release spec template when it is generated. There are a couple of things to consider here: * "the last-created Git tag associated with that package" — how do we know this? How do we map a package's version to a tag? We have to account for tags that were created by `action-create-release-pr` in the past as well as the tags that this tool will create in the future. We also have to know what kind of package this is — whether it's the root package of a monorepo or a workspace package — because the set of possible tags will differ. These differences are documented in `readMonorepoRootPackage` and `readMonorepoWorkspacePackage`. * What happens if a repo has no tags? Then all of the packages in that repo are considered to have changed, as they have yet to receive their initial release, so they will all be included in the release spec template.
3b55821
to
00b7396
Compare
src/package.ts
Outdated
generateMonorepoRootPackageReleaseTagNames(rootPackageVersion.toString()); | ||
const tagNameMatchingLatestRelease = [ | ||
...expectedWorkspacePackageReleaseTagNames, | ||
...expectedRootPackageReleaseTagNames, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it's worth printing a console warning if the fallback root tag is used? This should only happen in rare circumstances, like when using this tool for the first time on a monorepo that didn't previously have workspace tags (or at least not in the expected format).
A warning might hint that something is amiss if this happens outside of that scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we display a message to the user, I'd like it to be helpful and include a suggestion as to how they can resolve the problem, but I'm curious what that suggestion would be, because I think it differs based on whether this is the first time this tool is being used on a monorepo or not. If it is not the first time, then we can presume that all packages have been tagged properly, and so if the current release for any given package does not have the tag we expect, that is an anomaly and should be corrected. However, if it is the first time, then we can presume that no releases for any of the packages in the monorepo have tags at all, so in that case, if we say that the current release for a given package needs to be tagged properly, we might as well say that ALL releases for a given package need to be tagged properly.
So, it seems that either we need a way to tell whether this is the first time a user is using this tool, and only show this warning if it is not the first time, or we need to always show this warning, but offer another tool the user can use which will validate that all releases for all packages have proper tags and backfill them if necessary.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally I was thinking the user would just want to know the fallback occurred, since as you point out it's not necessarily a problem or something that is actionable.
If we can do better, that would be great. I'll give this some thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is not the first time, then we can presume that all packages have been tagged properly, and so if the current release for any given package does not have the tag we expect, that is an anomaly and should be corrected.
Yes, agreed. We could even throw an error in this case, this should never happen. That would be an improvement. It's distinct from the suggestion I meant to make here though.
However, if it is the first time, then we can presume that no releases for any of the packages in the monorepo have tags at all, so in that case, if we say that the current release for a given package needs to be tagged properly, we might as well say that ALL releases for a given package need to be tagged properly.
If we're just starting to use this tool, I don't think we can make any assumptions about tags. We don't know what convention, if any, they were using before.
To be clear, I was suggesting that we warn in the case where we find a root monorepo tag but not a workspace tag. We proceed silently in that circumstance in this PR at the moment.
This seems worth highlighting so that the user understands it's happening, even just for auditability. For example, if there were unpublished changes in a workspace that predate the most recent root tag, they would be missed because of us using this fallback. I don't think this scenario is likely, nor do I think it makes sense necessarily to force the user to manually add tags. But calling out that it's happening might leave an audit trail to follow up on if it happens and someone is confused as to why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough! Added warning in 565c2a5.
Generally this looks good! I left some comments on minor problems, and left one suggestion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! one suggestion thread pending but it's non-blocking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR adds a new property to the Package object,
hasChangesSinceLatestRelease
. This property is computed when a packageis read from a project by running a diff between the last-created Git
tag associated with that package and whatever the HEAD commit happens to
be, then checking to see whether any of the files changed belong to that
package. If they do, then
hasChangesSinceLatestRelease
is true,otherwise it's false. This property is then used to filter the list of
packages that are placed within the release spec template when it is
generated.
There are a couple of things to consider here:
know this? How do we map a package's version to a tag? We have to
account for tags that were created by
action-create-release-pr
in thepast as well as the tags that this tool will create in the future. We
also have to know what kind of package this is — whether it's the root
package of a monorepo or a workspace package — because the set of
possible tags will differ. These differences are documented in
readMonorepoRootPackage
andreadMonorepoWorkspacePackage
.repo are considered to have changed, as they have yet to receive their
initial release, so they will all be included in the release spec
template.
Fixes #8.