Run Flutter/Dart commands on changed files with intelligence
This project optimizes Flutter/Dart development workflows by running commands only on changed files, significantly speeding up CI/CD pipelines and local development.
Flutter Diff Action provides tools to make your development and CI workflows more efficient by focusing on what's changed:
- ⚡ Faster workflows: Run commands only on files that have changed
- 🧪 Smarter testing: Automatically find and run corresponding test files
- 📦 Mono-repo friendly: Full support for Melos-based workspaces
- 🛠️ Flexible: Works with testing, analysis, and formatting commands
This repository contains two complementary tools:
- GitHub Action: For CI/CD pipelines to efficiently run commands on changed files
- Dart CLI Tool: For local development to speed up testing and analysis workflows
Both tools intelligently identify changes, run commands only on affected files, and support mono-repo setups.
The GitHub Action component lets you run Flutter commands only on changed files in your CI/CD workflows.
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
- name: Run on changed files
uses: ProjectAJ14/flutter_diff_action@v1
with:
command: 'flutter test'
branch: ${{ github.base_ref }}
Parameter | Description | Required | Default |
---|---|---|---|
command |
Command to execute on changed files | Yes | - |
use-melos |
Enable Melos support for mono-repos | No | false |
working-dir |
Working directory for the command | No | . |
branch |
Base branch for comparison | No | main |
remote |
Remote repository name | No | origin |
debug |
Show verbose debug output | No | false |
- name: Test changed files
uses: ProjectAJ14/flutter_diff_action@v1
with:
command: 'flutter test'
- name: Analyze & test changed files
uses: ProjectAJ14/flutter_diff_action@v1
with:
command: 'flutter analyze'
debug: true
- name: Setup Melos
run: dart pub global activate melos
- name: Test changed packages
uses: ProjectAJ14/flutter_diff_action@v1
with:
command: 'flutter test'
use-melos: true
- name: Test changed files
uses: ProjectAJ14/flutter_diff_action@v1
with:
command: 'flutter test'
branch: 'develop'
- name: Test changed files
uses: ProjectAJ14/flutter_diff_action@v1
with:
command: 'flutter test'
remote: 'upstream'
name: Flutter CI
on:
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.6'
- name: Run Tests
uses: ProjectAJ14/flutter_diff_action@v1
with:
command: 'flutter test --no-pub --coverage'
branch: ${{ github.base_ref }}
use-melos: true
debug: true
- Determines changed files by comparing against the base branch
- Filters the list to relevant Dart/Flutter files
- For test commands, finds corresponding test files
- Executes the requested command only on the affected files
- Provides detailed output of results
Contributions are welcome and appreciated! Here's how you can contribute:
- Report bugs: Open an issue describing the bug and how to reproduce it
- Suggest features: Open an issue describing your idea and its benefits
- Submit PRs: Implement bug fixes or features (please open an issue first)
- Improve docs: Fix typos, clarify explanations, add examples
This project is licensed under the MIT License - see the LICENSE file for details.
Originally created by Ajay Kumar & Dipangshu Roy.
Special thanks to all contributors who have helped improve this project.