-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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(package-graph): Flatten cycles to avoid skipping packages #2185
fix(package-graph): Flatten cycles to avoid skipping packages #2185
Conversation
e5917a0
to
10ded5e
Compare
b619ccb
to
0f0dae2
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.
I will mark this PR as ready after I have tested it with Babel.
I suggest reviewing it with whitespace diff disabled (https://github.com/lerna/lerna/pull/2185/files?w=1)
Oh this PR makes lerna warn about 6 cycles in Babel (instead of about 30), making it way more actionable to resolve 😄 And it seems to correctly update every package 😎 |
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 very impressed by this PR, thanks so much! (and huge apologies for the pain!)
|
||
Cycles: | ||
B -> C -> D -> E -> B | ||
B -> C -> F -> G -> B |
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 love the graphs!
b9d9352
to
031ecf3
Compare
I have no idea why the exec+run tests are flaking (inconsistently!) in CI. I'm fixing that now, then I'll merge. |
…, avoid environmental variability
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.
Really great work! I love how you solved the problem at the right abstraction and simplified the way we should reason about cycles. I had to re-read the visits()
function a few times to "get it". Especially lines 378-380, 384 and 391 in package-graph/index.js
. There's a lot going on!
I'm grateful you were able to solve this so well, and I'm sorry this was a problem in the first place. I learned a lot reviewing your code!
| | ||
+---+ +---+ <----\ | ||
| A | --> | C | | | ||
+---+ +---+ <-\ | |
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.
nit: C and D's dependency lines should only point one direction each, right?
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.
Good catch, I've fixed this
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.
Thanks!
@evocateur Thanks for your new commits |
ok ok i'm done tweaking i swear |
@nicolo-ribaudo @bweggersen Huge thanks for all your help! |
Thanks to a gracious fix to Lerna by the Babel community, this issue (originally reported in my lerna/lerna#2107) is no longer an issue in new versions of Lerna, thanks to the fix provided in lerna/lerna#2185. Ref: lerna/lerna#2185 Ref: lerna/lerna#2107
v3.16 includes lerna/lerna#2185, which fixes an issue we had in the v7.5 releases
> In the same spirit as `apollo-server`: > apollographql/apollo-server@585085d4d8dd7ab Thanks to a gracious fix to Lerna by the Babel community, this issue (originally reported in my lerna/lerna#2107) is no longer an issue in new versions of Lerna, thanks to the fix provided in lerna/lerna#2185. Ref: lerna/lerna#2185 Ref: lerna/lerna#2107 cc @JakeDawkins cc @trevor-scheer
* Stop pinning Lerna to pre v3.14.0. > In the same spirit as `apollo-server`: > apollographql/apollo-server@585085d4d8dd7ab Thanks to a gracious fix to Lerna by the Babel community, this issue (originally reported in my lerna/lerna#2107) is no longer an issue in new versions of Lerna, thanks to the fix provided in lerna/lerna#2185. Ref: lerna/lerna#2185 Ref: lerna/lerna#2107 cc @JakeDawkins cc @trevor-scheer * chore(deps): update dependency lerna to v3.16.4
Description
To correctly handle cycles, I wrote an algorithm which flattens cycles into single nodes. Then every cycled, when it becomes a "leaf node", can be normally executed.
Example:
Becomes
Now that there aren't anymore nodes,
E
andB
can be executed since they are leaf nodes. The graph becomes:C + D
now is a leaf node, soC
andD
can be executed. The cycle is then removed from the graph.At this point,
A
becomes a leaf node and can be executed.Note that two cycles might have an intersection (or be nested): in that case they are handled as a single cycle.
Context
Fixes #2107
Need to check: #2165 (@alcferreira)
How Has This Been Tested?
It fixed our problem in the Babel publishing process.
Types of changes
Checklist: