name: '[CI] React Native'

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
  workflow_dispatch:

jobs:
  ci:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Enable Corepack
        run: corepack enable

      - name: Install dependencies (with retry)
        run: |
          set -euxo pipefail
          echo "@jsr:registry=https://npm.jsr.io" >> .npmrc
          yarn config set npmRegistryServer https://registry.npmjs.org/
          for i in 1 2 3 4 5; do
            yarn install && break || {
              echo "Attempt $i failed, waiting 30s..."
              sleep 30
            }
          done

      - name: Run eslint
        run: |
          set -euxo pipefail
          yarn lint
