Skip to content

chore: version constraints #6

chore: version constraints

chore: version constraints #6

Workflow file for this run

name: Checkout
on:
workflow_dispatch:
push:
branches:
- "main"
pull_request:
branches:
- "main"
- "develop"
- "feature/**"
- "bugfix/**"
- "hotfix/**"
- "support/**"
paths:
- "**/pubspec.yaml"
- "**/pubspec.lock"
- "packages/**/lib/**.dart"
- "packages/**/test/**.dart"
- "example/**.dart"
permissions:
contents: read
actions: read
checks: write
env:
FLUTTER_TEST_REPORT: ${{github.workspace}}/flutter-test-report.json
jobs:
setup:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
flutter-file-changed: ${{ steps.filter.outputs.flutter-file-changed }}
flutter-lower-bound: ${{ steps.flutter-version-constraint.outputs.lower-bound }}
flutter-upper-bound: ${{ steps.flutter-version-constraint.outputs.upper-bound }}
steps:
- uses: actions/checkout@v4
- name: Filter changed files
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
flutter-file-changed:
- '**.dart'
- '**.yaml'
- 'pubspec.lock'
- name: Get Flutter SDK version constraint
id: flutter-version-constraint
# Extract the lower bound from pubspec.yaml and the upper bound from .fvmrc
run: |
sdk_constraint=$(cat pubspec.yaml | yq .environment.flutter)
lower_bound=$(echo "$sdk_constraint" | grep -oP '(?<=\>=)[0-9]+\.[0-9]+\.[0-9]+' | head -1)
upper_bound=$(cat .fvmrc | jq -r .flutter)
echo "lower-bound=$lower_bound" >> "$GITHUB_OUTPUT"
echo "upper-bound=$upper_bound" >> "$GITHUB_OUTPUT"
- name: Print output values
run: |
echo "flutter-file-changed=${{ steps.filter.outputs.flutter-file-changed }}"
checkout:
needs: setup
if: ${{ needs.setup.outputs.flutter-file-changed == 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
flutter-version:
- ${{ needs.setup.outputs.flutter-lower-bound }}
- ${{ needs.setup.outputs.flutter-upper-bound }}
name: "🧪 Check code with analysis, format, and tests"
timeout-minutes: 10
defaults:
run:
working-directory: ./
steps:
- name: 📦 Get the .github actions
uses: actions/checkout@v4
with:
sparse-checkout: |
.github
- name: 🚂 Setup Flutter and dependencies
uses: ./.github/actions/setup
with:
flutter-version: ${{ matrix.flutter-version }}
- name: 👷 Install Dependencies
timeout-minutes: 1
run: |
flutter pub get
- name: 🚦 Check code format
id: check-format
timeout-minutes: 1
run: |
find packages/**/lib packages/**/test -name "*.dart" ! -name "*.*.dart" -print0 | xargs -0 dart format --set-exit-if-changed --line-length 120
- name: 📈 Check for Warnings
id: check-analyzer
timeout-minutes: 1
run: |
flutter analyze --fatal-infos --fatal-warnings
- name: 🧪 Unit & Widget tests
timeout-minutes: 2
run: |
ls -d packages/* | xargs flutter test --file-reporter="json:${{ env.FLUTTER_TEST_REPORT }}" --concurrency=6 --coverage
- name: Write test report
uses: dorny/test-reporter@v1
# PRs from forks have no write permissions.
if: github.event.pull_request.head.repo.fork == false && (success() || failure())
with:
name: Test Report (Flutter ${{ matrix.flutter-version }})
path: ${{ env.FLUTTER_TEST_REPORT }}
reporter: flutter-json