Skip to content

ci: publish.yml for testing purposes #12

ci: publish.yml for testing purposes

ci: publish.yml for testing purposes #12

name: Create coverage badge
on:
push:
branches: [main]
paths:
- .github/workflows/coverage-badge.yml
- lib/**
- test/**
- integration_test/**
- scripts/clean_coverage.sh
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: Run unit tests and collect coverage information
run: flutter test --coverage
- name: Clean Coverage
run: ./scripts/clean_coverage.sh
- name: Install lcov (coverage tool)
run: sudo apt install -y lcov
- name: Extract coverage percentage
id: coverage-extractor
run: |
coverage=$(lcov --summary coverage/lcov.info | grep 'lines' | awk '{print $2}' | sed 's/%//' | sed 's/.0$//')
echo "COVERAGE=$coverage" >> $GITHUB_OUTPUT
- name: Output coverage percentage
run: |
echo "The code coverage percentage is ${{ steps.coverage-extractor.outputs.COVERAGE }}"
# For a detailed guide, refer to: https://bitspittle.dev/blog/2022/kover-badge
- name: Update dynamic badge gist
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 48575fd9d18dc33989ab0eb602af3b53 # https://gist.github.com/EchoEllet/48575fd9d18dc33989ab0eb602af3b53
filename: kraft-launcher-coverage-badge.json
label: coverage
message: ${{ steps.coverage-extractor.outputs.COVERAGE }}%
valColorRange: ${{ steps.coverage-extractor.outputs.COVERAGE }}
minColorRange: 0
maxColorRange: 100