name: lint-and-check

on: [ pull_request,push]

jobs:
  cli-check:
    runs-on: ubuntu-latest
    name: CLI Check
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: "20"
          cache: ${{ steps.detect-package-manager.outputs.manager }}
      - name: Enable Corepack
        run: |
          corepack enable
      - name: Restore cache
        uses: actions/cache@v4
        with:
          path: .yarn/cache
          key: ${{ runner.os }}-ui-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-ui-
      - name: Install dependencies
        run: |
          yarn install
      - name: Lint
        run: yarn cli lint --write
      - name: Build
        run: yarn cli build

  component-check:
    runs-on: ubuntu-latest
    name: Component Check
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: "20"
          cache: ${{ steps.detect-package-manager.outputs.manager }}
      - name: Enable Corepack
        run: |
          corepack enable
      - name: Restore cache
        uses: actions/cache@v4
        with:
          path: .yarn/cache
          key: ${{ runner.os }}-ui-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-ui-
      - name: Install dependencies
        run: |
          yarn install
      - name: Lint
        run: yarn react lint --write
      - name: TypeScript Compile
        run: yarn react tsc