How to 'fail' (exit code != 0) a melos script if a single step failed?
Hi,
I'm using Melos 6.3.2 for my monorepo project, and defined a melos script that runs all unit tests (from all sub-projects) and also does some reporting and coverage analysis. Simplified and shortened excerpt from the melos.yaml:
test:
steps:
- melos exec --no-flutter --dir-exists=test dart test
- melos exec --flutter --dir-exists=test flutter test
I run it with melos run test. My problem is: When a single test of the first step fails, the whole melos script still exits with 0 and says "SUCCESS" at the end, so the failure may stay unnoticed.
I also tried using run instead, but the behaviour was the same:
test:
run: |
melos exec --no-flutter --dir-exists=test dart test
melos exec --flutter --dir-exists=test flutter test
My question: How can I make the whole script fail if any of its steps failed? I'm not asking about "fail fast" because I'd prefer to still run all tests (so that I can create a report of failing tests).
Thanks in advance for any advice!
This was fixed and released in Melos 7.0.0-dev.8. So if you can, I would recommend you to migrate to Melos v7, it will be moved to stable when the next Flutter version is released.
Thanks! I can't migrate now, but I will try as soon as possible. Just to be sure: By "next Flutter version released", you mean Flutter 3.33 or newer, don't you?
Hey, @aardjon 👋🏼 Have you tried with this?
test:
run: >
melos exec --no-flutter --dir-exists=test dart test
&&
melos exec --flutter --dir-exists=test flutter test
@mrverdant13 that is not using the steps feature, which this issue is about. But yes, not using steps can be a workaround.
Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.