-
Notifications
You must be signed in to change notification settings - Fork 379
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
fix(monorepos): github-release not created #669
fix(monorepos): github-release not created #669
Conversation
Codecov Report
@@ Coverage Diff @@
## master #669 +/- ##
==========================================
+ Coverage 85.15% 85.38% +0.22%
==========================================
Files 48 49 +1
Lines 5894 5945 +51
Branches 549 531 -18
==========================================
+ Hits 5019 5076 +57
+ Misses 874 868 -6
Partials 1 1
Continue to review full report at Codecov.
|
__snapshots__/github-release.js
Outdated
@@ -111,13 +111,13 @@ exports['GitHubRelease extractLatestReleaseNotes php-yoshi extracts appropriate | |||
|
|||
` | |||
|
|||
exports['GitHubRelease createRelease creates and labels release on GitHub 1'] = { | |||
'tag_name': 'v1.0.3', | |||
exports['GitHubRelease createRelease creates releases for submodule in monorepo 1'] = { |
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.
I'm having a hard time with the snapshot files. when I run npm test
any change introduced re-writes all '
-> "
for the entire file. Here I've tried to hand curate the appropriate changes but I'd really like to understand what my issue is with the auto-writing.
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.
@joeldodge79 rather than manually updating the snapshot files, you can run:
npm run test:snap
and it will capture the current state of things.
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.
Even running npm run test:snap
I still get the '
-> "
problem so the diff (see below) is totally useless :-( I'm having a hard time tracking down why my environment wants to make these changes (something with prettier somehow?) any thoughts?
diff --git a/__snapshots__/commit-split.js b/__snapshots__/commit-split.js
index e8ec512..9e7e5ff 100644
--- a/__snapshots__/commit-split.js
+++ b/__snapshots__/commit-split.js
@@ -1,569 +1,569 @@
exports['CommitSplit partitions commits based on path from root directory by default 1'] = {
- 'PubSub': [
+ "PubSub": [
{
- 'sha': '0a8477108a26aeb21d7af06e62be4ae5cb00ad42',
- 'message': 'fix: Update PubSub timeouts. (#1967)',
- 'files': [
- 'PubSub/src/V1/resources/subscriber_client_config.json',
- 'PubSub/synth.metadata'
+ "sha": "0a8477108a26aeb21d7af06e62be4ae5cb00ad42",
+ "message": "fix: Update PubSub timeouts. (#1967)",
+ "files": [
+ "PubSub/src/V1/resources/subscriber_client_config.json",
+ "PubSub/synth.metadata"
]
}
],
src/util/package-branch.ts
Outdated
// limitations under the License. | ||
|
||
// map from a packageName to the prefix used in release branch creation. | ||
export function packageBranch(packageName: string) { |
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.
not super thrilled with this approach but it felt better than copy/pasting this around
- better name?
- better scoping (per releaser somehow? right now this just handles specific node/npm remapping)
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.
@joeldodge79 I might call it parsePackageName
and have it return a scope
, and name
, which are the names given to the two parts of the package name?
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.
I'm going to suggest another route. updated PR coming soon
@@ -125,11 +125,14 @@ export class Node extends ReleasePR { | |||
// A releaser can implement this method to automatically detect | |||
// the release name when creating a GitHub release, for instance by returning | |||
// name in package.json, or setup.py. | |||
static async lookupPackageName(gh: GitHub): Promise<string | undefined> { | |||
static async lookupPackageName( |
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.
it seems like some code above (L71) could be DRYed out using this method unless I'm missing something?
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.
nm, I see you need contents
further down so L71 should probably just stay as is.
@joeldodge79 I think this fix might step on your toes a bit: We had a bug where we weren't successfully looking up package names in the action, I'll get it merged shortly. |
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.
A few nits 👍 this is great work, it's awesome to have another person digging into the mono-repo logic, I think it's almost getting there 😆
@@ -78,6 +78,14 @@ export class GitHubRelease { | |||
} | |||
|
|||
async createRelease(): Promise<ReleaseResponse | undefined> { | |||
// Attempt to lookup the package name from a well known location, such | |||
// as package.json, if none is provided: | |||
if (!this.packageName && this.releaseType) { |
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.
I've just been specifying package-name in my monorepo implementations, this seems smarter.
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.
I moved this up to ensure the same packageName
was used for tag creation on L133 as for finding the release PR (L93). IIRC I was doing something stupid like trying to set package-name
to something different from package.json (or maybe just not setting it at all?).
src/github.ts
Outdated
@@ -584,7 +585,7 @@ export class GitHub { | |||
// it's easiest/safest to just pull this out by string search. | |||
const version = match[2]; | |||
if (!version) continue; | |||
if (prefix && match[1] !== prefix) { | |||
if (prefix && match[1] !== packageBranch(prefix)) { |
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.
could we drop the @foo/
prefix before passing it into this method? I think the reason I didn't bump into this error is that I've been setting packageName
when using the monorepo functionality.
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.
I don't fully understand your comment. In
before passing it into this method
does "this method" refer to the method we're in (findMergedReleasePR
) or packageBranch
? you meant the former... I think it's reasonable to move packageBranch(prefix)
up to packageBranch(this.packageName)
in the parent call site
src/util/package-branch.ts
Outdated
// limitations under the License. | ||
|
||
// map from a packageName to the prefix used in release branch creation. | ||
export function packageBranch(packageName: string) { |
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.
@joeldodge79 I might call it parsePackageName
and have it return a scope
, and name
, which are the names given to the two parts of the package name?
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.
I'm going to push an update for further discussion
@@ -78,6 +78,14 @@ export class GitHubRelease { | |||
} | |||
|
|||
async createRelease(): Promise<ReleaseResponse | undefined> { | |||
// Attempt to lookup the package name from a well known location, such | |||
// as package.json, if none is provided: | |||
if (!this.packageName && this.releaseType) { |
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.
I moved this up to ensure the same packageName
was used for tag creation on L133 as for finding the release PR (L93). IIRC I was doing something stupid like trying to set package-name
to something different from package.json (or maybe just not setting it at all?).
src/github.ts
Outdated
@@ -584,7 +585,7 @@ export class GitHub { | |||
// it's easiest/safest to just pull this out by string search. | |||
const version = match[2]; | |||
if (!version) continue; | |||
if (prefix && match[1] !== prefix) { | |||
if (prefix && match[1] !== packageBranch(prefix)) { |
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.
I don't fully understand your comment. In
before passing it into this method
does "this method" refer to the method we're in (findMergedReleasePR
) or packageBranch
? you meant the former... I think it's reasonable to move packageBranch(prefix)
up to packageBranch(this.packageName)
in the parent call site
@@ -125,11 +125,14 @@ export class Node extends ReleasePR { | |||
// A releaser can implement this method to automatically detect | |||
// the release name when creating a GitHub release, for instance by returning | |||
// name in package.json, or setup.py. | |||
static async lookupPackageName(gh: GitHub): Promise<string | undefined> { | |||
static async lookupPackageName( |
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.
nm, I see you need contents
further down so L71 should probably just stay as is.
gh: GitHub, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
path?: string | ||
): Promise<string | undefined> { |
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.
will add a test
src/util/package-branch.ts
Outdated
// limitations under the License. | ||
|
||
// map from a packageName to the prefix used in release branch creation. | ||
export function packageBranch(packageName: string) { |
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.
I'm going to suggest another route. updated PR coming soon
1ddbae0
to
95376ad
Compare
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.
@bcoe I annotated some changes in the last commit. It might be worth a few minutes syncing in person too if you have time.
if (this.packageName === undefined) { | ||
throw Error( | ||
`could not determine package name for release repo = ${this.repoUrl}` | ||
); | ||
} |
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.
moved this up in my last commit so that the type checker knows that this.packageName
is defined (for passing to packageBranchPrefix
)
this.monorepoTags | ||
? packageBranchPrefix(this.packageName, this.releaseType) | ||
: undefined |
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.
Feedback: moved this packageBranchPrefix
call up out of this.gh.findMergedReleasePR
@@ -551,10 +551,12 @@ export class GitHub { | |||
async findMergedReleasePR( | |||
labels: string[], | |||
perPage = 100, | |||
prefix: string | undefined = undefined, | |||
branchPrefix: string | undefined = undefined, |
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.
cosmetic/readability change. I'm not married to it but as I was trying to reason about what this parameter really is this name made more sense to me (especially given the tag lookup functions taking both a prefix
and a branchPrefix
)
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.
I like this change 👍
I actually recently stopped accepting the two prefixes, which seemed like a hack that wasn't working, and switched to checking for -
, /
and @
if we've fallen back to looking up by tag.
// limitations under the License. | ||
|
||
// map from a packageName to the prefix used in release branch creation. | ||
export function packageBranchPrefix(packageName: string, releaseType?: string) { |
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.
I kept the name more generically related to converting a package name into a branch prefix. I added the releaseType
argument to support future releasers possibly needing to make a similar transformation.
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.
I like this approach 👍 I'd added some of this handling for Node.js, because I know the domain well, but I could certainly imagine us wanting similar behavior for other languages.
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.
This looks great to me 👍 with the caveat that it's complex enough that I'd love for us to test it in the real world.
When we land, this repository I'd expect to continue working without any configuration changes -- we can use it as a test 😄
@@ -551,10 +551,12 @@ export class GitHub { | |||
async findMergedReleasePR( | |||
labels: string[], | |||
perPage = 100, | |||
prefix: string | undefined = undefined, | |||
branchPrefix: string | undefined = undefined, |
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.
I like this change 👍
I actually recently stopped accepting the two prefixes, which seemed like a hack that wasn't working, and switched to checking for -
, /
and @
if we've fallen back to looking up by tag.
// limitations under the License. | ||
|
||
// map from a packageName to the prefix used in release branch creation. | ||
export function packageBranchPrefix(packageName: string, releaseType?: string) { |
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.
I like this approach 👍 I'd added some of this handling for Node.js, because I know the domain well, but I could certainly imagine us wanting similar behavior for other languages.
bcaaf28
to
aa7339f
Compare
@bcoe some udpates:
|
aa7339f
to
d8cfed6
Compare
d8cfed6
to
7c56589
Compare
fixes a couple of issues: 1. if node releaser doesn't specify packageName then github-release wasn't filtering merged PRs correctly. 2. when solving the above, we need to be consistent about the relationship between packageName and the release branch name.
7c56589
to
d737545
Compare
@bcoe ok, I think I'm done (for this round anyway). Let me know if you have a chance to push this through to master on release-please-action and I'll test it again. |
fixes a couple of issues:
wasn't filtering merged PRs correctly.
relationship between packageName and the release branch name.
Fixes #668