name: CI

on:
  # 合并 PR 后触发（branch protection 保证只有 merge 能到达这里）
  push:
    branches: [main, dev]
  # PR 提交/更新时触发，main 和 dev 都接受 PR
  pull_request:
    branches: [main, dev]

jobs:
  lint:
    name: Lint
    runs-on: self-hosted

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Flutter (stable)
        uses: subosito/flutter-action@v2
        with:
          channel: stable
          cache: true

      - name: Install Melos
        run: dart pub global activate melos

      - name: Deep clean
        run: melos run clean:deep

      - name: Bootstrap
        run: melos bootstrap

      - name: Generate code
        run: melos run gen

      - name: Analyze
        run: melos run analyze

