name: Expo Updates CLI

on:
  push:
    branches: [main]
    paths:
      - .github/workflows/expo-updates-cli.yml
      - packages/expo-updates/cli/**
      - yarn.lock
  pull_request:
    paths:
      - .github/workflows/expo-updates-cli.yml
      - packages/expo-updates/cli/**
      - yarn.lock

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

jobs:
  test:
    runs-on: ubuntu-20.04
    steps:
      - name: 👀 Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 100
      - name: ♻️ Restore caches
        uses: ./.github/actions/expo-caches
        id: expo-caches
        with:
          yarn-workspace: 'true'
      - name: 🧶 Install workspace node modules
        if: steps.expo-caches.outputs.yarn-workspace-hit != 'true'
        run: yarn install --frozen-lockfile
      - name: 🛠 Build expo-updates CLI
        run: yarn build:cli
        working-directory: packages/expo-updates
      - name: 🧪 Run expo-updates CLI tests
        run: yarn test:cli
        working-directory: packages/expo-updates
