ci: code coverage badge #4
Workflow file for this run
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: Create coverage badge | |
on: | |
push: | |
branches: [main] | |
# TODO(EchoEllet): For testing only, remove | |
pull_request: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Flutter (Stable) | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: stable | |
cache: true | |
- name: Install Package Dependencies | |
run: flutter pub get | |
- name: Collect coverage info | |
run: flutter test --coverage | |
- name: Install lcov | |
run: sudo apt install -y lcov | |
- name: Extract coverage percentage | |
id: coverage-extractor | |
run: | | |
percentage=$(lcov --summary coverage/lcov.info | grep 'lines' | awk '{print $2}' | sed 's/%//' | sed 's/.0$//') | |
echo "COVERAGE=$percentage" >> $GITHUB_OUTPUT | |
- name: Print the coverage percentage for testing | |
run: | | |
echo "The coverage percentage is ${{ steps.coverage-extractor.outputs.COVERAGE }}" | |
- name: Update dynamic badge gist | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: e115a2922ddd4f9f897b6e2c15d6c071 # https://gist.github.com/EchoEllet/e115a2922ddd4f9f897b6e2c15d6c071 | |
filename: native-image-picker-macos-coverage-badge.json | |
label: 'Dart Coverage' | |
message: ${{ steps.coverage-extractor.outputs.COVERAGE }}% | |
valColorRange: ${{ steps.coverage-extractor.outputs.COVERAGE }} | |
minColorRange: 0 | |
maxColorRange: 100 |