-
Notifications
You must be signed in to change notification settings - Fork 0
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(earthly-flutter): Make sure earthly target fails when flutter tests fail #329
fix(earthly-flutter): Make sure earthly target fails when flutter tests fail #329
Conversation
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.
We do this kind of thing in the Rust builders too.
Be aware that it creates a side effect in the build.
Because the RUN melos run ... || touch fail
will not actually fail, the result of that will be cached as a success by the build system.
Any terminal output it creates to help you diagnose the problem will then only be shown on the first run.
Even the two RUN
after IF [ -f fail ]
will also cache, only the last RUN will show as failed.
For that RUN, I would be inclined to make it:
RUN echo "msg"; \
exit 1
So, at least the message is shown.
For the melos run test-report
you might be able to use tee
something like so:
RUN melos run test-report 2>&1 | tee melos-output.txt || touch fail
and then add a cat melos-output.txt
to the part where you actually fail the build.
This would have the effect of always showing the output of the melos run
on failure or success the first time, and on failure re-displaying the failure messages.
I have considered doing something like this in the Rust builders as well, but haven't implemented it yet.
As a second comment, this is like this because of the coverage results and the way they are saved. We are looking for a better solution for those, and if we can do that without using a "SAVE ARTIFACT LOCALLY" we would no longer need to do this, and the RUN could be a script which does everything, and then fails or not. Which would make this code much less cumbersome. |
The I couldn't find any simple solutions to be able to use tee so I came up with idea of printing the whole output to a file, then replaying it from the file via Earthly's TRY-FINALLY is still experimental, maybe in the future we could use it to make things less complex. |
Description
Defers the error that can be raised after running flutter unit tests until the test_reports and coverage artifacts are saved, then raises an error to indicate that the target failed.
flutter test
does not generate any test_reports therefore I'm removing the artifactsPlease confirm the following checks