lerna: lerna run prints "success" next to failed packages
Let’s assume I want to run all unit tests from all packages in my monorepo. So I’d call lerna run --no-bail test
. I’d specify --no-bail
because I don’t want to abort on the first error. I want to see which packages succeed and which fail. When Lerna is done, it prints a table that looks like this:
lerna success run Ran npm script ‘test’ in 5 packages in 0.3s: lerna success - package01 lerna success - package02 lerna success - package03 lerna success - package04 lerna success - package05
The problem is that Lerna prints “success” next to each package, even if the script for that package actually failed.
Expected Behavior
I’d expect “success” to be printed only if the error code of the packages’s script was zero. Otherwise, I’d expect “failure” or something similar to be printed next to the failed package.
Current Behavior
Currently, Lerna prints “success” next to every single package, even if its script failed and returned a non-zero exit code.
Steps to Reproduce (for bugs)
- Set up a monorepo with multiple packages.
- Create a script “test” in each monorepo. Make some scripts succeed (by calling “true” on Unix), make others fail (by calling “false” on Unix).
- Run
lerna run --no-bail test
lerna.json
{
"packages": ["packages/*"],
"version": "1.0.0",
"npmClient": "yarn",
"useWorkspaces": true
}
Context
I want to run the same task on all packages (no fail-fast) and see which packages succeeded and which didn’t.
Your Environment
Executable | Version |
---|---|
lerna --version |
3.13.1 |
npm --version |
5.6.0 |
yarn --version |
1.13.0 |
node --version |
v8.11.3 |
OS | Version |
---|---|
macOS High Sierra | 10.13.6 |
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 24
- Comments: 16 (3 by maintainers)
I still believe that this is fundamentally broken. I would expect that
--no-bail
:stderr
), exactly like without--no-bail
success
1
(or something else?)I would really, really like to fix this, as I think
--no-bail
is basically pretty much useless otherwise, at least to me. Do you think we can / should fix the behavior of--no-bail
or rather add a new flag and maybe deprecate--no-bail
?Digging through log files of a huge mono-repo across all packages to determine which package failed is cumbersome.
Instead, something like this would be nice, when
--no-bail
is used:Hi! just wanted to add to what @buschtoens said. i was expecting the same, or at least get a list of which packages failed.
when running a whole suite of tests in a monorepo, it’s almost impossible to follow the stdout or stderr.
not sure what is the use-case of no-bail if it doesn’t report errors. so i would suggest to fix it.
also, it seems to be designed this way, or at least we test against it: https://github.com/lerna/lerna/blob/62901748f818516d58efdfd955eacb447e270351/commands/exec/__tests__/exec-command.test.js#L74
Agreed. I have to just text search for “FAIL” in my build output, which is a little haphazard. Lerna should only be reporting success for zero exit codes.
Surprised this issue has been open this long with no comments for several months.
A problem is that when running with
--no-bail
, onlystdout
is being output, even when there is an error. Further, all output, even for failed packages, use either info or success log levels. This ends up hiding useful output in error cases.If you run without
--no-bail
, then bothstdout
andstderr
is printed, along with log level error being used.Where I just experienced this issue, jest ran all of the unit tests successfully, but failed because of a coverage threshold. The actual error was output to
stderr
by jest, but lerna just dropped it. In ci this makes it much harder to diagnose issues.If lerna would print
stderr
in failure cases along withstdout
when using--no-bail
, and optionally use the error log level, then the logging would be much more useful.success
is the log level, not a qualitative assertion of the result. I’m pretty sure the logging when the error occurs would be sufficient?That is interesting, but I came to same conclusion as @DanielSWolf and came here to report the same issue. I see bunch of green success when one of the packages failed the task.
It would be nice to either rename the log levels to not suggest more than they should (e.g. call this “info” rather than “success”) or see if there’s a way to get the actual success/failure of each package’s run result into that final summary.
I think this does not only happen for tests but any scripts that are executed by lerna? I see typescript errors but the lerna task does not fail in my CI pipeline.