-
Notifications
You must be signed in to change notification settings - Fork 367
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
feat(manifest): node workspace package dependency updates #844
Conversation
Codecov Report
@@ Coverage Diff @@
## master #844 +/- ##
==========================================
+ Coverage 93.78% 94.07% +0.29%
==========================================
Files 64 68 +4
Lines 9218 9809 +591
Branches 939 1014 +75
==========================================
+ Hits 8645 9228 +583
- Misses 570 578 +8
Partials 3 3
Continue to review full report at Codecov.
|
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 this is the behemoth PR that represents that last piece of functionality we need for the looker-open-source/sdk-codegen
release requirements. not my usual style to drop a 3K LOC PR but, well, here it is (and 2/3rds of the LOC is test code).
I could split it up if you'd like but I think it's at least useful to see the whole picture. I left a bunch of inline comments as a guide
return changelogUpdater.updateContent(changelog); | ||
} | ||
|
||
private async setChangelogEntry( |
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.
all this changelog entry manipulation got a bit exasperating at the end but it seems to work pretty well now. There may be a better way of doing it but I was just trying to jam through to the finish line... really wanted to see changelog entries for lerna-based dependency updates.
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.
See comment about us moving towards a better markdown generator that actually understands the tree.
8491fb1
to
62e3988
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.
Left some initial comments.
The big thing that jumps out at me, is that the assertions are getting pretty large when confirming actualChanges
. For what is partially text content like this, I feel this is where snpshots can really shine.
Here are the snapshots I use for c8, our test coverage library. I feel like they read very well, and it's clear when they beak -- perhaps the problem with the snapshots in relese-please is just that we need a helper for structured objects, that helps output their contents in a format that's slightly more diffable?
package.json
Outdated
@@ -51,6 +51,7 @@ | |||
"@types/yargs": "^16.0.0", | |||
"c8": "^7.0.0", | |||
"chai": "^4.2.0", | |||
"chai-better-shallow-deep-equal": "^1.1.0", |
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.
When possible, I'd rather use the built in assert.strictDeepEqual, I like trying to dogfood Node.js with as few dependencies as possible.
@@ -61,9 +62,14 @@ | |||
"dependencies": { | |||
"@conventional-commits/parser": "^0.4.1", | |||
"@iarna/toml": "^2.2.5", | |||
"@lerna/collect-updates": "^4.0.0", | |||
"@lerna/package": "^3.16.0", |
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's nice that lerna is decomposed like this.
// 3. currently unsupported but possible future support: | ||
// - `snapshot` | ||
// - `label` | ||
export type ManifestPackage = Pick< |
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 the use of Pick
here, my colleague @SurferJeffAtGoogle was walking me through some of these advanced TypeScript features the other day.
return changelogUpdater.updateContent(changelog); | ||
} | ||
|
||
private async setChangelogEntry( |
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.
See comment about us moving towards a better markdown generator that actually understands the tree.
@@ -2049,4 +2049,80 @@ describe('Manifest', () => { | |||
}); | |||
} | |||
}); | |||
|
|||
describe('plugins', () => { | |||
it('runs the node-workspace plugin', async function () { |
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 additional comments in this test would help me. Shouldn't we see @pkg2
being updated as well since it depends on @pkg1
which was updated? I only see updates for @pkg1
and python
.
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 you look at the snapshot it captured the @pkg2
updates. Perhaps confusing because I'm only checking the logging that Manifest
is performing here, not any logging the plugin is doing. Given how the plugin is instantiated via the config it's hard to inject a logger (though I could probably stub it). Or I could just remove the Manifest
logging for this test case to avoid confusion.
I'll get around to moving the logging out of this file into the snapshot too at some point.
test/plugins/node-workspace.ts
Outdated
'\n\nAll notable changes to this project will be ' + | ||
'documented in this file.' + | ||
'\n\n### [2.2.3](https://www.github.com/fake/repo/compare' + | ||
'/pkgB-v2.2.2...pkgB-v2.2.3) (1983-10-10)' + |
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 think that these assertions are going to become a bit fragile, as even subtle changes to the markdown generation will lead to a bunch of fiddling in tests.
Having confirmed the behavior manually (i.e., now that you trust the approach), I would be tempted to move the assertion into a snapshot -- at which point, we should just see small stylistic differences in the snapshot as changes are made to content.
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.
absolutely. converted the log tracking and the changes to snapshots
|
||
/** | ||
* skeleton only representing what we use. | ||
*/ |
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.
Can we pull any of these typings in from DefinitelyTyped
rather than floating them ourselves?
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.
They don't currently exist there. What I've added here is pretty sparse coverage for the relevant packages. I was hoping to avoid taking on the load of publishing them there which I feel like would require a more comprehensive effort (also, never done it before...)
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.
Can you add an expected usage example for this feature?
Is the plugin a Javascript/Typescript function in the release repo? or in the release-please repo?
I can add documentation on how to use this for sure. I wanted to get it out for some initial feedback first though in case it needs to change significantly before writing up a doc Yes, the "plugin" exists in the release-please repo (currently just the one: In the real world I've used this for our @bcoe I think I've covered your initial around of feedback (mostly converting to snapshots). |
bde90b7
to
04d732d
Compare
|
||
const sandbox = sinon.createSandbox(); | ||
|
||
function stringifyActual(actual: ManifestPackageWithPRData[]) { |
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 the approach of using this stringifyActual
helper 👍
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 is looking good to me, pending @chingor13's comments.
@chingor13 I added a section to the manifest docs |
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.
Small nit about README, I think this is looking good though.
docs/manifest-releaser.md
Outdated
Unlike the individual releasers, which only have the context of the source files | ||
relevant to one package, a plugin receives all the current changes for all | ||
updated packages as well as the configuration containing every package. One | ||
place this is particularly useful is for monorepos that have intra-repo local |
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 think it would be worth breaking this paragraph in half, the first half can talk about how the plugins work:
- what they're passed, and what they should output.
In this section I'd then have a code snippet that demonstrates the tiniest potential plugin that someone might right, e.g,. adding one additional update? it can be a toy example.
The second paragraph can then describe why plugins would be useful, exactly as you have right now.
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.
let me know what you think of my num-packages
plugin :-)
Introduces the concept of a "plugin" that can run after release-please has generated changes but before the PR is created. In order to support plugin releaser-post-processing (before submitting the PR) we want to provide the whole contents of the changed file to the plugin.
5e8dc9c
to
a99a535
Compare
thanks for landing this @bcoe Are there any docs on local/branch testing release-please changes in the action? I want to test the dynamic importing of plugins in the action and make changes if needed |
Introduces the concept of a "plugin" that can run after release-please
has generated changes but before the PR is created.
In order to support plugin releaser-post-processing (before submitting
the PR) we want to provide the whole contents of the changed file to the
plugin.