Skip to content

Create lint.yml workflow #6

Create lint.yml workflow

Create lint.yml workflow #6

Workflow file for this run

name: Run code static analysis
on:
push:
branches: ["main"]
pull_request:
concurrency:
group: lint-${{ github.ref }}
cancel-in-progress: true
jobs:
find-packages:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.find-packages.outputs.packages }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Find packages
id: find-packages
run: |
packages=$(find . -type f -name pubspec.yaml -exec dirname {} \; | sed -e 's,^\./,,' | sort -u | awk '{print}' ORS='", "')
echo "packages=[\"${packages::-4}\"]" >> $GITHUB_OUTPUT
lint:
name: Run lint
runs-on: ubuntu-latest
needs: find-packages
strategy:
fail-fast: false
matrix:
packages: ${{ fromJson(needs.find-packages.outputs.packages) }}
defaults:
run:
working-directory: ${{ matrix.packages }}
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Check if has Flutter SDK on pubspec.yaml
id: has-flutter-sdk
run: |
if grep -q 'sdk: *flutter' pubspec.yaml; then
echo "has-flutter-sdk=true" >> $GITHUB_OUTPUT
else
echo "has-flutter-sdk=false" >> $GITHUB_OUTPUT
fi
- name: Setup Dart
uses: dart-lang/setup-dart@v1
if: steps.has-flutter-sdk.outputs.has-flutter-sdk == 'false'
- name: Setup Flutter
uses: subosito/flutter-action@v1
if: steps.has-flutter-sdk.outputs.has-flutter-sdk == 'true'
- name: Get dependencies
run: |
dart pub get
- name: Analyze code
run: |
dart analyze --fatal-infos --fatal-warnings .
- name: Check code formatting
if: always()
run: |
dart format --output=none --set-exit-if-changed .