-
Notifications
You must be signed in to change notification settings - Fork 544
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
ci: speed up PR unit-test run time #614
Conversation
Actually, I see that running the tests only takes 1.5 minutes compared to 12 minutes of installing the dependencies and 8 minutes on "Post Cache Dependencies", so not sure this optimization is required ATM. |
The same filtering flags can be used for the bootstrap stage which should greatly improve dependency installation speed. Any way you can apply that here? |
Sure, good idea. testing if it works. |
@dyladan I tested it and seem like it does not work. |
Tested the
Any idea how we can remove this dependency and test the hoist install time? |
was able to fix it with |
The hoist option cut down ci time dramatically, from about ~20 minutes to about ~10 minutes.
Will appreciate help with this issue from someone with relevant experience with these dependencies spaghetti |
Managed to fix this issue with the help of @dyladan and @rauno56 by setting Can someone help me take a look and figure out how to solve it? |
Fixed, with the help of @YanivD . This is ready for review |
Think you don't need sudo |
If the CI isn't running you can ping me on slack to approve the run |
4f6ffa7
to
ae2bd3f
Compare
Seems like this is stable now? |
Yes. stable, tested, and ready to review |
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.
the very needed and missing piece, thx !
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 so much for undertaking this tedious but beneficial work!
The credit should also go to @YanivD who solved the permissions issue |
Gave him a Co-authored-by when I merged |
Which problem is this PR solving?
According to my research, running CI unit tests on this repo currently takes ~20m, where a vast amount of the time (~12m) is spent on
lerna bootstrap
which downloads >1G of node_modules dependencies, and on "Post Cache Dependecies" which upload this >1G tp the cache.This PR decreases CI run time from ~20m to ~10m when cache action is miss for fetching node_modules from previous ci run.
A quick look at our github action workflows run, shows this is a very common case. Long CIs spends a lot the opentelemetry github organization resources and decrease fast feedback for developer on there PRs (more time to understand tests are failing in CI and fix them). Since current workflow time is linera correlated to the number of packages in the monorepo, CI time is expect to get worst as more packages will be added in the future.
Running the tests only on changed packages will allow us to do more extensive testing in the future (like running test-all-versions), because we will not waste CI time running tests on packages with no changes. According to @dyladan, this is OK with the GC.
Before (cache action miss):
After (cache action miss):
Drawbacks:
Hoisting
as mentioned in lerna hoisting documentation:
As a result, your packages will be able to import or require any of the dependencies that have been hoisted, even if you forgot to specify that dependency in your package's package.json file.
This means that if
package-foo
depends on some otherpackage-bar
, but forgot to state it in thepackage.json
, tests may still pass as it might get the dependency from the hoisted node_modules via some other package which depends onpackage-bar
.Since hoisting is only used for CI run, developer should catch this error on his local fork which is not hoisted, but of course this is not guaranteed to catch all errors.
lerna changed option
lerna since filter option will run tests on packages which have code changes from
main
branch. Ifpackage-foo
depends on another package from the same repopackage-bar
, and a PR changesbar
but notfoo
, then tests will only run forbar
, although we might want to run them also onfoo
due to the dependency.In contrib repo, there are no internal dependencies on other packages from the same monorepo, beside from
test-utils
, so I don't think this is an issue here, but look bellow for possible solution.lerna parallel
when running tests with lerna parallel, the output of the test runs is not synchronous, making it a bit less readable. since PRs here usually address a single package, I do not anticipate this to be an issue in this repo
Possible solution
I suggest that we have a daily canary test run that will execute a full test on all the packages in the repo, with no hoisting and with full
test-all-versions
configuration to catch such issues, without exhausting the CI on each commit to each PR. I can take the task of creating such workflow if we agree to add it.Short description of the changes
Use lerna hoisting to install each dependency only once to the root
node_modules
of the monorepo, instead of reinstalling it again and again into each of thenode_modules
s of each package in the repo. Size of the node_modules for each installation of contrib is >1G so the effect is dramatic.Uses the --since filter option and --parallel option for
lerna run
to execute unit tests only for packages that are changed in this specific PR. We've been using this technique in ext-js repo for long time and it's been working good for us.