chore: Generate coverage reports and upload them. #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Combined Coverage Report | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
coverage: | |
name: Generate Combined Coverage | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.x' | |
channel: 'stable' | |
- name: Install dependencies | |
run: | | |
dart pub global activate melos | |
dart pub global activate coverage | |
dart pub global activate combine_coverage | |
melos bootstrap | |
- name: Run tests with coverage for all packages | |
run: | | |
# Create directory for combined coverage | |
mkdir coverage | |
# Run tests for each package and generate coverage | |
cd packages | |
for d in */ ; do | |
cd "$d" | |
if [ -f "pubspec.yaml" ]; then | |
echo "Running tests for $d" | |
if [[ "$d" == "supabase_flutter/"* ]]; then | |
flutter test --coverage --concurrency=1 | |
else | |
if [[ "$d" == "postgrest/"* ]]; then | |
cd ../../infra/postgrest | |
docker compose down | |
docker compose up -d | |
cd ../../packages/postgrest | |
elif [[ "$d" == "gotrue/"* ]]; then | |
cd ../../infra/gotrue | |
docker compose down | |
docker compose up -d | |
cd ../../packages/gotrue | |
elif [[ "$d" == "storage_client/"* ]]; then | |
cd ../../infra/storage_client | |
docker compose down | |
docker compose up -d | |
cd ../../packages/storage_client | |
fi | |
dart test --coverage=coverage | |
dart pub global run coverage:format_coverage --packages=.dart_tool/package_config.json --report-on=lib --lcov -o coverage/lcov.info -i coverage | |
fi | |
fi | |
cd .. | |
done | |
cd .. | |
- name: Combine coverage reports | |
run: | | |
dart pub global run combine_coverage:combine_coverage --repo-path="./" --output-directory="coverage" | |
- name: Upload combined coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: combined-coverage-report | |
path: coverage/lcov.info |