flutter_ci_guard 0.0.2
flutter_ci_guard: ^0.0.2 copied to clipboard
CI-friendly quality gates for Flutter projects. Enforce format, analyze, and test coverage thresholds with ease.
๐ก๏ธ flutter_ci_guard #
Stop technical debt before it reaches production. flutter_ci_guard is a lightweight, zero-dependency CLI tool designed to be the final gatekeeper in your Flutter CI/CD pipelines.
๐ What does it solve? #
CIs often have separate steps for formatting, linting, and testing. If one fails, you might get scattered reports. More importantly, enforcing a minimum coverage percentage usually requires complex shell scripts or heavy third-party services.
flutter_ci_guard orchestrates these "Quality Gates" into a single, reliable command that:
- ๐งน Ensures code is formatted (fails if
dart formatfinds changes). - ๐ Runs static analysis (fails if
flutter analyzefinds issues). - ๐งช Executes tests with coverage (fails if tests fail).
- ๐ Enforces coverage thresholds (fails if coverage is below your limit).
๐ฆ Installation #
Add it as a dev dependency in your pubspec.yaml:
dev_dependencies:
flutter_ci_guard: latest_version
Or install it globally:
dart pub global activate flutter_ci_guard
๐ ๏ธ Basic Usage #
Run it from the root of your Flutter project:
# Runs everything with default 80% coverage threshold
dart run flutter_ci_guard
Real-world examples #
Enforce strict 95% coverage:
dart run flutter_ci_guard --min-coverage 95
Check only analysis and coverage (skipping format and tests runtime):
# Useful if you already ran tests in a previous CI step but need to check the LCOV file
dart run flutter_ci_guard --skip-format --skip-tests --min-coverage 80
โ๏ธ Configuration Flags #
| Flag | Default | Description |
|---|---|---|
--min-coverage |
80 |
Required percentage (0-100). |
--coverage-path |
coverage/lcov.info |
Path to the generated LCOV file. |
--skip-format |
false |
Skip dart format validation. |
--skip-analyze |
false |
Skip flutter analyze. |
--skip-tests |
false |
Skip flutter test --coverage. |
--help |
- | Show usage information. |
๐ค CI/CD Integration #
GitHub Actions #
The most common way to use flutter_ci_guard is as a single "Quality Gate" step.
jobs:
check-quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
- name: Install dependencies
run: flutter pub get
- name: Run Quality Gates
run: dart run flutter_ci_guard --min-coverage 90
๐ช Exit Behavior #
flutter_ci_guard returns specific exit codes so your CI can react accordingly:
| Code | Meaning |
|---|---|
| 0 | Success (All gates passed). |
| 1 | Step Failed (Format, Analyze, or Tests failed). |
| 2 | Low Coverage (Coverage is below the threshold). |
| 3 | Missing File (Coverage file not found at the specified path). |
| 4 | Parse Error (The LCOV file is malformed). |
| 64 | Invalid Args (Wrong CLI usage). |
๐ฏ Scope & Philosophy #
- Lightweight: Minimal dependencies, fast startup.
- Fail Fast: If formatting fails, it doesn't waste time running tests.
- CI-First: Designed to be the standard way to run checks in pipelines.
- Pure Dart: No need for
lcovorgenhtmlinstalled on the CI machine to check the percentage.
๐จโ๐ป Created & Maintained By #
Miguel Angel Oquendo Rincon
๐ License #
MIT License - see LICENSE for details.