Skip to content

Add pubspec.lock to version control #271

Add pubspec.lock to version control

Add pubspec.lock to version control #271

Workflow file for this run

name: Code Check
on:
push:
branches: main
pull_request:
env:
FLUTTER_TEST_REPORT: ${{github.workspace}}/flutter-test-report.json
PATTERN_CHECKER: ${{github.workspace}}/scripts/pattern_checker.sh
jobs:
# Change detection
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
dart-files: ${{ steps.filter.outputs.dart-files }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
dart-files:
- '**.dart'
# Static code analysis
analysis:
needs: changes
if: ${{ needs.changes.outputs.dart-files == 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
target: [package, cookbook]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Flutter
uses: ./.github/actions/setup_flutter
with:
target: ${{ matrix.target }}
- name: Format
run: dart format . -o none --set-exit-if-changed
working-directory: ${{ matrix.target }}
- name: Analyze
run: dart analyze
working-directory: ${{ matrix.target }}
- name: Disallowed patterns check
run: bash ${{ env.PATTERN_CHECKER }} "*.dart" "--" "debugPrint"
working-directory: ${{ matrix.target }}
# Unit testing
testing:
needs: changes
if: ${{ needs.changes.outputs.dart-files == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
checks: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Flutter
uses: ./.github/actions/setup_flutter
with:
target: package
- name: Run unit tests
run: flutter test --file-reporter="json:${{ env.FLUTTER_TEST_REPORT }}"
working-directory: package
- 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
path: ${{ env.FLUTTER_TEST_REPORT }}
reporter: flutter-json
# Final results (Used for status checks)
code-check:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: [analysis, testing]
steps:
# Fails if any of the previous jobs failed.
- run: exit 1
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
}}