Skip to content

Commit

Permalink
fix(earthly-flutter): Make sure earthly target fails when flutter tes…
Browse files Browse the repository at this point in the history
…ts fail (#329)

* fix(earthly-flutter): Make sure earthly target fails when flutter tests fail

* chore(earthly-flutter): retain error logs in case of unit tests failure
  • Loading branch information
dtscalac authored Oct 7, 2024
1 parent b26c3d4 commit 8135d23
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions earthly/flutter/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,31 @@ UNIT_TESTS:

IF [ -f melos.yaml ]
RUN echo "Running unit tests with melos."
RUN melos run test-report

# We always want to save the test_reports and coverage
# therefore we must defer the error reported here until later.
RUN melos run test-report > melos-output.txt 2>&1 || touch fail

# If not failed then print the output immediately,
# if it has failed then it's printed at the end of the function when exiting.
IF [ ! -f fail ]
RUN cat melos-output.txt
END

WAIT
SAVE ARTIFACT test_reports AS LOCAL test_reports
SAVE ARTIFACT coverage AS LOCAL coverage
END

# Defer the failure to here.
IF [ -f fail ]
RUN echo "Error occurred when running: melos run test-report"; \
cat melos-output.txt; \
exit 1
END
ELSE
RUN echo "Running flutter test"
RUN flutter test
WAIT
SAVE ARTIFACT test_reports AS LOCAL test_reports
END
END

# Build web app and save artifacts locally if needed.
Expand Down

0 comments on commit 8135d23

Please sign in to comment.