Update flutter_coverage.yml #1
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: Flutter Test | |
on: [push, pull_request] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: stable | |
- name: Install dependencies | |
run: flutter pub get | |
- name: Run tests with coverage | |
run: flutter test --coverage | |
- name: Generate coverage report | |
run: | | |
sudo apt-get install -y lcov | |
genhtml -o coverage coverage/lcov.info | |
- name: Calculate Coverage Percentage | |
id: coverage | |
run: | | |
COVERAGE_PERCENT=$(lcov --summary coverage/lcov.info | grep -Po '\d+\.\d+%' | head -1) | |
echo "coverage=$COVERAGE_PERCENT" >> $GITHUB_ENV | |
- name: Generate Coverage Badge with Shields.io | |
run: | | |
curl -o coverage/coverage-badge.svg "https://img.shields.io/badge/coverage-${{ env.coverage }}25-green" | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./coverage |