@@ -170,33 +170,77 @@ PUBLISH_DRY_RUN:
170170UNIT_TESTS :
171171 FUNCTION
172172
173- IF [ -f melos.yaml ]
174- RUN echo "Running unit tests with melos."
175-
176- # We always want to save the test_reports and coverage
177- # therefore we must defer the error reported here until later.
178- RUN melos run test-report > melos-output.txt 2> &1 || touch fail
179-
180- # If not failed then print the output immediately,
181- # if it has failed then it's printed at the end of the function when exiting.
182- IF [ ! -f fail ]
183- RUN cat melos-output.txt
184- END
173+ ARG PLATFORM= native
174+ ARG REPORT= false
185175
186- WAIT
187- SAVE ARTIFACT test_reports AS LOCAL test_reports
188- SAVE ARTIFACT coverage AS LOCAL coverage
176+ IF [ -f melos.yaml ]
177+ IF [ $PLATFORM = native ]
178+ RUN echo "Running native unit tests with melos."
179+
180+ IF [ $REPORT = true ]
181+ # We always want to save the test_reports and coverage
182+ # therefore we must defer the error reported here until later.
183+ RUN melos run test-report-native > melos-output.txt 2> &1 || touch fail
184+
185+ # If not failed then print the output immediately,
186+ # if it has failed then it's printed at the end of the function when exiting.
187+ IF [ ! -f fail ]
188+ RUN cat melos-output.txt
189+ END
190+
191+ WAIT
192+ SAVE ARTIFACT test_reports AS LOCAL test_reports
193+ SAVE ARTIFACT coverage AS LOCAL coverage
194+ END
195+
196+ # Defer the failure to here.
197+ IF [ -f fail ]
198+ RUN echo "Error occurred when running: melos run test-report" ; \
199+ cat melos-output.txt; \
200+ exit 1
201+ END
202+ ELSE
203+ RUN melos run test-native
204+ END
189205 END
190-
191- # Defer the failure to here.
192- IF [ -f fail ]
193- RUN echo "Error occurred when running: melos run test-report" ; \
194- cat melos-output.txt; \
195- exit 1
206+ IF [ $PLATFORM = web ]
207+ RUN echo "Running web unit tests with melos."
208+
209+ IF [ $REPORT = true ]
210+ # We always want to save the test_reports and coverage
211+ # therefore we must defer the error reported here until later.
212+ RUN melos run test-report-web > melos-output.txt 2> &1 || touch fail
213+
214+ # If not failed then print the output immediately,
215+ # if it has failed then it's printed at the end of the function when exiting.
216+ IF [ ! -f fail ]
217+ RUN cat melos-output.txt
218+ END
219+
220+ WAIT
221+ SAVE ARTIFACT test_reports AS LOCAL test_reports
222+ SAVE ARTIFACT coverage AS LOCAL coverage
223+ END
224+
225+ # Defer the failure to here.
226+ IF [ -f fail ]
227+ RUN echo "Error occurred when running: melos run test-report" ; \
228+ cat melos-output.txt; \
229+ exit 1
230+ END
231+ ELSE
232+ RUN melos run test-web
233+ END
196234 END
197235 ELSE
198- RUN echo "Running flutter test"
199- RUN flutter test
236+ IF [ $PLATFORM = native ]
237+ RUN echo "Running flutter native test"
238+ RUN flutter test
239+ END
240+ IF [ $PLATFORM = web ]
241+ RUN echo "Running flutter web test"
242+ RUN flutter test --platform chrome
243+ END
200244 END
201245
202246# Build web app and save artifacts locally if needed.
0 commit comments