name: Pull Request Pipeline

on:
  pull_request:

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      # Required for Flutter action
      - name: Install jq
        run: |
          apt-get update
          apt-get install -y jq 

      - name: Set up Flutter
        uses: subosito/flutter-action@v2
        with:
          channel: stable
          flutter-version: 3.41.0

      - name: Get dependencies
        run: |
          git config --global --add safe.directory /opt/hostedtoolcache/flutter/stable-3.41.0-x64
          flutter pub get

      - name: Analyze Formatting
        run: flutter analyze lib test

  test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      # Required for Flutter action
      - name: Install jq
        run: |
          apt-get update
          apt-get install -y jq 

      - name: Set up Flutter
        uses: subosito/flutter-action@v2
        with:
          channel: stable
          flutter-version: 3.41.0

      - name: Get dependencies
        run: |
          git config --global --add safe.directory /opt/hostedtoolcache/flutter/stable-3.41.0-x64
          flutter pub get

      - name: Run tests
        run: flutter test
