name: Static Code Analysis on: workflow_dispatch: pull_request: push: branches: [main] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: pre-job: runs-on: ubuntu-latest outputs: should_run: ${{ steps.found_paths.outputs.mobile == 'true' || steps.should_force.outputs.should_force == 'true' }} steps: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - id: found_paths uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3 with: filters: | mobile: - 'mobile/**' workflow: - '.github/workflows/static_analysis.yml' - name: Check if we should force jobs to run id: should_force run: echo "should_force=${{ steps.found_paths.outputs.workflow == 'true' || github.event_name == 'release' }}" >> "$GITHUB_OUTPUT" mobile-dart-analyze: name: Run Dart Code Analysis needs: pre-job if: ${{ needs.pre-job.outputs.should_run == 'true' }} runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - name: Setup Flutter SDK uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046 # v2 with: channel: 'stable' flutter-version-file: ./mobile/pubspec.yaml - name: Install dependencies run: dart pub get working-directory: ./mobile - name: Run Build Runner run: make build working-directory: ./mobile - name: Find file changes uses: tj-actions/verify-changed-files@a1c6acee9df209257a246f2cc6ae8cb6581c1edf # v20 id: verify-changed-files with: files: | mobile/**/*.g.dart mobile/**/*.gr.dart mobile/**/*.drift.dart - name: Verify files have not changed if: steps.verify-changed-files.outputs.files_changed == 'true' run: | echo "ERROR: Generated files not up to date! Run make_build inside the mobile directory" echo "Changed files: ${{ steps.verify-changed-files.outputs.changed_files }}" exit 1 - name: Run dart analyze run: dart analyze --fatal-infos working-directory: ./mobile - name: Run dart format run: dart format lib/ --set-exit-if-changed working-directory: ./mobile - name: Run dart custom_lint run: dart run custom_lint working-directory: ./mobile