GitHub Action
Dart Coverage Assistant
A no-brainer tool to generate coverage reports for your Dart projects. Plug and play, both for your existing CI, or in a new project.
- No configuration needed, just add the action to your workflow
- Automatically finds all projects in your repository
- Doesn't run any tests by default, so it works with your existing CI
- Can run tests for you (good if you have no CI yet)
- Post a sticky comment on every PR
- Updates automatically if you make changes
- Shows coverage for every project in your repository
- Can show differences between the current and the base branch
- Choose between multiple rules:
- Fail the action if total repo coverage drops below threshold
- Fail the action if any single project coverage drops below threshold
- Fail the action if total repo coverage decreases in PR
- Fail the action if any single project coverage decreases in PR
- Show off your coverage in your README or on your website, without signing up to a third party service
- Generate badges on
push
events - Can be configured to either push new badges to the current branch, or open a PR with them.
Getting started with dart-coverage-assistant
is easy. It works out of the box
with your existing CI pipeline to give you the power of coverage reporting. If
you don't have a CI yet, it can also run your tests for you.
jobs:
flutter-check:
name: Build Check
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
# ---
# Your existing steps...
# ---
- name: ๐ Generate Coverage
id: coverage-report
uses: whynotmake-it/dart-coverage-assistant@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
lower_threshold: 50
upper_threshold: 90
generate_badges: pr
[!IMPORTANT] With this setup, this action will assume, that your projects have up-to-date coverage. This can be achieved by either running the tests like
flutter test --coverage
in the steps before this action, or always running them locally. Check the section below for more information about configuration options.
If you just want a drop-in CI pipeline, just copy the following into your
.github/workflows/main.yml
file. This will run your tests and generate a
coverage report for you.
name: Continuous Integration
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
flutter-check:
name: Build Check
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: ๐ Checkout
uses: actions/checkout@v4
- name: ๐ฆ Setup Flutter
uses: subosito/flutter-action@v2
with:
sdk: 'stable'
- name: ๐ Generate Coverage
id: coverage-report
uses: whynotmake-it/dart-coverage-assistant@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
testing_command: flutter test --coverage
lower_threshold: 50
upper_threshold: 90
generate_badges: pr
Below you will find a short list of all available configuration options, and what they do.
lower_threshold
(optional, default:0
): The lower threshold for code coverage, anything below this is considered a failure.upper_threshold
(optional, default:0
): The threshold for the coverage to be considered 'good', anything below this is considered critical.compare_against_base
(optional, default:true
): Whether to compare against the base when running in a PR.enforce_threshold
(optional, default:'total'
): Whether the action should fail if the coverage is below the lower threshold. Can be set to "none", "single", or "total".enforce_forbidden_decrease
(optional, default:'none'
): Whether the action should fail if the coverage decreases. Can be set to "none", "single", or "total".generate_badges
(optional, default:none
): Whether to generate badges for the coverage on "push" workflow triggers. Can be set to "push" (push new badges, make sure your branch is not protected), "pr" (open a pull request with the changes, make sure you allow Actions to open PRs on your Repo), or "none" (no badge generation).
- Big thanks to @JohannSchramm for his help and being an inspiration for this project.