name: check

on:
  workflow_dispatch:
  pull_request:
    paths-ignore:
    - 'Firestore/**'
  push:
    branches: main

concurrency:
    group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
    cancel-in-progress: true

jobs:
  check:
    # Don't run on private repo.
    if: github.repository == 'Firebase/firebase-ios-sdk'
    runs-on: ubuntu-latest
    env:
      MINT_PATH: ${{ github.workspace }}/mint
    steps:
    - uses: actions/checkout@v4

    - uses: actions/setup-python@v5
      with:
        python-version: 3.11

    - name: Cache Mint packages
      uses: actions/cache@v4
      with:
        path: ${{ env.MINT_PATH }}
        key: ${{ runner.os }}-mint-${{ hashFiles('**/Mintfile') }}
        restore-keys: ${{ runner.os }}-mint-

    - name: Setup check
      run:  |
        eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
        scripts/setup_check.sh

    - name: Check
      run:  |
        eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
        # Add Homebrew clang-format to first in PATH
        export PATH="/home/linuxbrew/.linuxbrew/opt/clang-format/bin:$PATH"
        scripts/check.sh --test-only
