Merge pull request #220 from trilobitech/renovate/actions-deploy-page… #521
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Code checks workflow | |
| on: | |
| push: | |
| branches: [ 'main' ] | |
| pull_request: | |
| branches: [ '**' ] | |
| paths: | |
| - '**.dart' | |
| - '**/pubspec.*' | |
| - '*.yaml' | |
| - assets/** | |
| - .fvm/fvm_config.json | |
| - .tool-versions | |
| - .github/workflows/code-quality.yml | |
| concurrency: | |
| group: qa-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| lint: | |
| name: Run lint on affected files | |
| runs-on: ubuntu-latest | |
| needs: check-changes | |
| if: ${{ needs.check-changes.outputs.changed_files }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7.0.1 | |
| - id: versions | |
| name: Read .tool-versions | |
| uses: marocchino/tool-versions-action@v1 | |
| - name: Setup Flutter SDK | |
| uses: subosito/flutter-action@v2.23.0 | |
| with: | |
| channel: stable | |
| flutter-version: ${{ steps.versions.outputs.flutter }} | |
| - name: Cache pub packages | |
| uses: actions/cache@v6 | |
| with: | |
| path: ~/.pub-cache | |
| key: ${{ runner.os }}-pub-cache-${{ hashFiles('**/pubspec.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pub-cache- | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Setup Firebase Options | |
| run: | | |
| tee lib/firebase_options.dart <<EOF | |
| class DefaultFirebaseOptions { | |
| static const currentPlatform = null; | |
| } | |
| EOF | |
| - name: Analyze code | |
| if: ${{ needs.check-changes.outputs.changed_files }} | |
| run: | | |
| dart analyze --fatal-infos --fatal-warnings \ | |
| ${{ needs.check-changes.outputs.changed_files }} | |
| check-format: | |
| name: Check code formatting on affected files | |
| runs-on: ubuntu-latest | |
| needs: check-changes | |
| if: ${{ needs.check-changes.outputs.changed_dart_files }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7.0.1 | |
| - id: versions | |
| name: Read .tool-versions | |
| uses: marocchino/tool-versions-action@v1 | |
| - name: Setup Flutter SDK | |
| uses: subosito/flutter-action@v2.23.0 | |
| with: | |
| channel: stable | |
| flutter-version: ${{ steps.versions.outputs.flutter }} | |
| - name: Cache pub packages | |
| uses: actions/cache@v6 | |
| with: | |
| path: ~/.pub-cache | |
| key: ${{ runner.os }}-pub-cache-${{ hashFiles('**/pubspec.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pub-cache- | |
| - name: Setup Firebase Options | |
| run: | | |
| tee lib/firebase_options.dart <<EOF | |
| class DefaultFirebaseOptions { | |
| static const currentPlatform = null; | |
| } | |
| EOF | |
| - name: Get files to check | |
| id: files-to-check | |
| run: | | |
| changed_dart_files="${{ needs.check-changes.outputs.changed_dart_files }}" | |
| # if no dart files changed, get all dart files in the repository | |
| if [ "$changed_dart_files" == '.' ]; then | |
| changed_dart_files=$(find . -type f -name '*.dart' -not -path '*/.dart_tool/*' | xargs) | |
| fi | |
| # get excluded files from analysis_options.yaml | |
| excluded_files=$(yq eval '.analyzer.exclude | .[]' analysis_options.yaml | xargs) | |
| # filter $changed_dart_files to exclude $excluded_files | |
| changed_dart_files=$(echo "$changed_dart_files" | tr ' ' '\n' \ | |
| | grep -vE "$(echo "$excluded_files" | sed 's/ /|/g' | sed 's/\*/.*/g' | sed 's#/#/#g')" \ | |
| | tr '\n' ' ' | xargs) | |
| echo "value=$changed_dart_files" >> $GITHUB_OUTPUT | |
| - name: Check code formatting | |
| run: | | |
| dart format --output=none --set-exit-if-changed \ | |
| ${{ steps.files-to-check.outputs.value }} | |
| unit-tests: | |
| name: Run unit tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7.0.1 | |
| - id: versions | |
| name: Read .tool-versions | |
| uses: marocchino/tool-versions-action@v1 | |
| - name: Setup Flutter SDK | |
| uses: subosito/flutter-action@v2.23.0 | |
| with: | |
| channel: stable | |
| flutter-version: ${{ steps.versions.outputs.flutter }} | |
| - name: Cache pub packages | |
| uses: actions/cache@v6 | |
| with: | |
| path: ~/.pub-cache | |
| key: ${{ runner.os }}-pub-cache-${{ hashFiles('**/pubspec.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pub-cache- | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Setup Firebase Options | |
| run: | | |
| tee lib/firebase_options.dart <<EOF | |
| class DefaultFirebaseOptions { | |
| static const currentPlatform = null; | |
| } | |
| EOF | |
| - name: Run unit tests | |
| run: flutter test --coverage | |
| - name: Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| files: ./coverage/lcov.info | |
| check-changes: | |
| name: Check changed files | |
| runs-on: ubuntu-latest | |
| outputs: | |
| changed_files: ${{ steps.added-and-modified-files.outputs.all || '.' }} | |
| changed_dart_files: ${{ steps.added-and-modified-files.outputs.dart || '.' }} | |
| steps: | |
| - id: event-check | |
| name: Check GitHub event | |
| run: | | |
| echo "is_pr=${{ github.event_name == 'pull_request' }}" >> $GITHUB_OUTPUT | |
| - name: Checkout repository | |
| if: ${{ steps.event-check.outputs.is_pr == 'true' }} | |
| uses: actions/checkout@v7.0.1 | |
| - id: changed-files | |
| name: Get changed files | |
| if: ${{ steps.event-check.outputs.is_pr == 'true' }} | |
| uses: tj-actions/changed-files@v46 | |
| with: | |
| files: | | |
| **/*.dart | |
| **/pubspec.yaml | |
| files_ignore: | | |
| **/generated/** | |
| **/*.freezed.dart | |
| - id: added-and-modified-files | |
| name: Get all added and modified files | |
| if: ${{ steps.event-check.outputs.is_pr == 'true' }} | |
| run: | | |
| changed_files=$(echo "${{ steps.changed-files.outputs.added_files }} ${{ steps.changed-files.outputs.modified_files }}" | xargs) | |
| changed_dart_files=$(echo "$changed_files" | tr ' ' '\n' | grep -E '\.dart$' | xargs) | |
| echo "all=$changed_files" >> $GITHUB_OUTPUT | |
| echo "dart=$changed_dart_files" >> $GITHUB_OUTPUT |