add: adding support for code coverage

This commit is contained in:
Patrick Stewart 2024-10-20 21:52:47 -07:00
parent 848ffd4988
commit f8db3107b9
4 changed files with 28 additions and 1 deletions

4
.gitignore vendored
View file

@ -5,6 +5,10 @@
.packages
build/
# Coverage files
coverage/
coverage_report/
# Files and directories created by developer
spike/
devbox.d/

17
.melos/coverage.yaml Normal file
View file

@ -0,0 +1,17 @@
scripts:
_: &coverage_scripts
coverage:
run: >
melos exec -c 1 --fail-fast -- "dart pub add --dev coverage && dart test --coverage=coverage && dart pub global activate coverage && dart pub global run coverage:format_coverage -l --packages=.dart_tool/package_config.json --report-on=lib/ -i coverage -o coverage/lcov.info && dart pub remove coverage"
description: Run tests with coverage and generate LCOV report for each package
coverage_report:
run: >
melos exec -c 1 --fail-fast -- "
if [ -s coverage/lcov.info ]; then
genhtml -o coverage_report coverage/lcov.info;
echo 'Coverage report generated successfully.';
else
echo 'No valid coverage data found. Skipping report generation.';
fi
"
description: Generate HTML coverage report from LCOV data for each package, if valid data exists

View file

@ -62,6 +62,12 @@ scripts:
docs:serve:custom:
run: "melos exec --scope=\"$MELOS_SCOPE\" -- \"echo 'Serving docs for {MELOS_PACKAGE_NAME}' && dhttpd --path doc --port \\${DOC_PORT:-8080}\"\n"
description: Serve generated documentation for specified packages (use with MELOS_SCOPE and optionally DOC_PORT env vars)
coverage:
run: "melos exec -c 1 --fail-fast -- \"dart pub add --dev coverage && dart test --coverage=coverage && dart pub global activate coverage && dart pub global run coverage:format_coverage -l --packages=.dart_tool\/package_config.json --report-on=lib\/ -i coverage -o coverage\/lcov.info && dart pub remove coverage\"\n"
description: Run tests with coverage and generate LCOV report for each package
coverage_report:
run: "melos exec -c 1 --fail-fast -- \" if [ -s coverage\/lcov.info ]; then\n genhtml -o coverage_report coverage\/lcov.info;\n echo 'Coverage report generated successfully.';\nelse\n echo 'No valid coverage data found. Skipping report generation.';\nfi \"\n"
description: "Generate HTML coverage report from LCOV data for each package, if valid data exists"
test:
run: melos exec -c 1 --fail-fast -- "dart test"
description: Run tests for all packages