name: Melos + FVM CI

on:
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: dart-lang/setup-dart@v1
        # также актуализация Flutter, если нужен fvm

      - name: Install FVM
        run: dart pub global activate fvm

      - name: Install Flutter version via FVM
        run: fvm install

      # ВАЖНО: активируем melos через flutter, чтобы не было несовместимости
      - name: Install Melos
        run: fvm flutter pub global activate melos

      - name: Bootstrap workspace
        run: fvm flutter pub global run melos bootstrap

      - name: CodeGen
        run: fvm flutter pub global run melos run codegen

      - name: Analyze all packages
        run: fvm flutter pub global run melos run analyze

      - name: Run all tests
        run: fvm flutter pub global run melos run test
