Merge pull request #19 from andro-devs/develop #33
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: Validate Workflow | |
| on: | |
| # Triggers on every 'git push' to any branch. | |
| push: | |
| # Triggers on all Pull Requests targeting any branch. | |
| pull_request: | |
| jobs: | |
| # The name of the job | |
| validate: | |
| # Set the runner environment (standard choice for Dart/Flutter) | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout the code | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| # Set up the Dart environment | |
| - name: Setup Dart | |
| uses: dart-lang/setup-dart@v1 | |
| # Fetch dependencies (important for deployment/build) | |
| - name: Get dependencies | |
| run: dart pub get | |
| # Verify the use of 'dart format' on each commit. | |
| - name: Verify formatting | |
| run: dart format --output=none --set-exit-if-changed . | |
| # Consider passing '--fatal-infos' for slightly stricter analysis. | |
| - name: Analyze project source | |
| run: dart analyze | |
| # Run tests | |
| - name: Run tests | |
| run: dart test | |
| # --- START COVERAGE GENERATION --- | |
| # 1. Run Tests and collect raw coverage data | |
| - name: Collect Raw Coverage | |
| run: | | |
| mkdir -p coverage/raw | |
| dart test --coverage=coverage/raw | |
| # 2. Format the raw data into LCOV | |
| - name: Format to LCOV | |
| # Use dart run coverage:format_coverage to convert raw JSON to lcov.info | |
| run: | | |
| LCOV_OUTPUT_PATH=coverage/lcov.info | |
| dart run coverage:format_coverage \ | |
| --lcov \ | |
| --in=coverage/raw \ | |
| --out=$LCOV_OUTPUT_PATH \ | |
| --packages=.dart_tool/package_config.json \ | |
| --report-on=lib | |
| # 3. Upload LCOV file to Codecov | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: coverage/lcov.info | |
| # Note: Token is often optional for public repos, but required for private | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: true | |
| verbose: true |