github-actions-analyze-dart
github-actions-analyze-dart copied to clipboard
A Github Action to analyze your project's Dart code
GitHub Action — Analyze Dart
This GitHub Action (written in JavaScript) allows you to leverage GitHub Actions to analyze your Dart project's Dart code, including Flutter. This runs both the dart analyze and dartfmt commands under the hood.
Usage
Pre-requisites
Create a workflow .yml file in your .github/workflows directory. An example workflow is available below. For more information, reference the GitHub Help Documentation for Creating a workflow file.
Inputs
For more information on these inputs, see the Workflow syntax for GitHub Actions
fail-on-infos: The action fails if any info was found. This will always fail on errors. Optional. Default:falsefail-on-warnings: The action fails if any warning was found. This will always fail on errors. Optional. Default:falseworking-directory: The working directory. Optional. Default:./line-length: The maximum line length. Optional. The formatter will use its default:80
Outputs
None.
Sample Workflow Summary:

Sample Files Changed:

Dart workflow
- Your workflow must install Dart before using this action. Suggestion: Dart starter workflow.
- Use the action. For example:
on: push
name: Sample Workflow
jobs:
build:
name: Example
runs-on: ubuntu-latest
container:
image: google/dart:latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: dart pub get
- name: Analyze Dart
uses: zgosalvez/github-actions-analyze-dart@v1
Flutter workflow
- Your workflow must install Flutter before using this action. Suggestion: Flutter action.
- Use the action. For example:
on: push
name: Sample Workflow
jobs:
build:
name: Example
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Flutter
uses: subosito/flutter-action@v1
- run: flutter pub get
- name: Analyze Dart
uses: zgosalvez/github-actions-analyze-dart@v2
Custom Workflow
After following the common workflow above, lint rules can be customized. For more details see:
pedanticfor rules enforced internally at Googleeffective_dartfor rules corresponding to the Effective Dart style guide
Flutter Workflows
This is used in my opinionated GitHub Actions: Flutter Workflows repository along with other actions for a complete end-to-end DevOps experience.
License
The scripts and documentation in this project are released under the MIT License