Improvements/tests and confidence #3
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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| analyze-and-test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: stable | |
| flutter-version: 3.44.3 | |
| cache: true | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Verify formatting | |
| run: dart format --output=none --set-exit-if-changed . | |
| - name: Analyze | |
| run: flutter analyze --fatal-infos | |
| - name: Run tests with coverage | |
| run: flutter test --coverage | |
| - name: Install lcov | |
| run: sudo apt-get update && sudo apt-get install -y lcov | |
| - name: Enforce coverage floor | |
| run: | | |
| PCT=$(lcov --summary coverage/lcov.info 2>/dev/null \ | |
| | grep -oE 'lines.*: [0-9.]+%' | grep -oE '[0-9.]+' | head -1) | |
| echo "Line coverage: ${PCT}% (min 85%)" | |
| awk -v p="$PCT" -v m="85" 'BEGIN { exit (p+0 >= m+0) ? 0 : 1 }' | |
| - name: Upload coverage artifact | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage | |
| path: coverage/lcov.info | |
| if-no-files-found: warn | |
| - name: Upload coverage to Codecov | |
| if: always() | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: coverage/lcov.info | |
| fail_ci_if_error: false | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |