Skip to main content

Flutter Package

This workflow runs helpful checks on a Flutter package according to the steps below. As with any workflow, it can be customized.

Steps

The Flutter package workflow consists of the following steps:

  1. Setup Flutter
  2. Set SSH Key (if provided)
  3. Install dependencies
  4. Run Setup (if provided)
  5. Format
  6. Analyze
  7. Bloc Lint (if enabled)
  8. Run tests (includes coverage collection and enforcement)

Inputs

analyze_directories

Optional A space-separated list of folders that should be analyzed.

Default "lib test"

format_directories

Optional A space-separated list of folders that should be formatted.

Default "lib test"

concurrency

Optional The number of concurrent test suites run.

Default 4

coverage_excludes

Optional Space-separated list of globs to exclude files from the coverage report (e.g. '**/*.g.dart **/gen/*.dart').

Default ""

flutter_channel

Optional The Flutter release channel to use (e.g. stable).

Default "stable"

flutter_version

Optional The Flutter SDK version to use (e.g. 3.24.0).

Default ""

format_line_length

Optional The preferred line length preferred for running the dart format command. Be aware that this does not change the behavior of the analysis step and longer lines could still make the workflow fail if the rule lines_longer_than_80_chars is used.

min_coverage

Optional The minimum coverage percentage allowed.

Default 100

setup

Optional A command that should be executed immediately after dependencies are installed.

Default ""

working_directory

Optional The path to the root of the Flutter package.

Default "."

test_optimization

Optional Enable the test optimization.

Default true

Note: Since the optimization process groups tests into a single file, golden tests will not work properly. Consider disabling optimizations if you are using golden tests.

test_recursion

Optional Whether to recursively run tests in nested directories.

Default false

runs_on

Optional The operating system on which to run the workflow.

Default "ubuntu-latest"

package_get_excludes

Optional List of paths to exclude from packages get. Supports globs to describe file patterns.

Default "!*"

platform

Optional The platform to run tests on (e.g., chrome, android, ios).

Default ""

report_on

Optional A comma-separated list of folders that should be checked in code coverage.

Default "lib"

run_bloc_lint

Optional Whether to run bloc lint on the package.

Default true

run_skipped

Optional Run skipped tests instead of skipping them.

Default false

show_uncovered

Optional Whether to show uncovered lines when coverage is below 100%. Implicitly enables coverage collection when used alone.

Default true

collect_coverage_from

Optional Whether to collect coverage from imported files only or all files. Counting untested files against coverage (all) results in stricter enforcement.

Allowed values imports, all

Default "imports"

Secrets

ssh_key

Optional An SSH key used to access private repositories when installing dependencies.

Example Usage

name: My Flutter Workflow

on: pull_request

jobs:
build:
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/flutter_package.yml@v1
with:
coverage_excludes: '**/*.g.dart'
flutter_channel: 'stable'
flutter_version: '3.35.0'
working_directory: 'examples/my_flutter_package'
test_recursion: true
secrets:
ssh_key: ${{secrets.EXAMPLE_KEY}}