Update Badges #25
This file contains hidden or 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: Update Badges | |
| on: | |
| push: | |
| branches: | |
| - master | |
| schedule: | |
| - cron: '0 0 * * 0' # Run weekly on Sunday at midnight | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-badges: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17' | |
| - name: Install SQLite | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y sqlite3 libsqlite3-dev | |
| - name: Set up Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: '3.24.5' | |
| - name: Install Dependencies | |
| run: flutter pub get | |
| - name: Generate Mocks | |
| run: flutter pub run build_runner build --delete-conflicting-outputs | |
| - name: Generate Database Migrations Schema | |
| run: flutter pub run drift_dev schema generate drift_schemas/ test/generated_migrations/ | |
| - name: Run Tests with Coverage and Reports | |
| run: | | |
| mkdir -p test-reports | |
| flutter test --coverage --file-reporter json:test-reports/results.json > test-reports/test_run.log || true | |
| - name: Calculate Coverage Percentage | |
| id: coverage | |
| run: python3 .github/scripts/calculate_coverage.py | |
| - name: Calculate Test Statistics | |
| id: test_stats | |
| run: python3 .github/scripts/calculate_test_stats.py | |
| - name: Create Coverage Badge | |
| uses: emibcn/badge-action@v2.0.2 | |
| with: | |
| label: 'Coverage' | |
| status: '${{ steps.coverage.outputs.percent }}%' | |
| color: '${{ steps.coverage.outputs.color }}' | |
| path: '.github/badges/coverage.svg' | |
| - name: Create Tests Badge | |
| uses: emibcn/badge-action@v2.0.2 | |
| with: | |
| label: 'Tests' | |
| status: '${{ steps.test_stats.outputs.summary }}' | |
| color: '${{ steps.test_stats.outputs.color }}' | |
| path: '.github/badges/tests.svg' | |
| - name: Commit and Push Badges | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: "chore: auto-update test and coverage badges" | |
| file_pattern: ".github/badges/coverage.svg .github/badges/tests.svg" |