name: Checks

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  setup:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
      - uses: ./.github/actions/setup
      - uses: ./.github/actions/build
      - uses: ./.github/actions/upload-pkg
      - run: pnpm lint

  test:
    runs-on: ${{ matrix.os }}
    timeout-minutes: 15
    needs: [setup]
    strategy:
      matrix:
        os: [windows-latest, ubuntu-latest, macos-latest]
        node-version: [16, 18, 20]

    steps:
      - uses: actions/checkout@v4
      - uses: ./.github/actions/setup
        with:
          node-version: ${{ matrix.node-version }}
      - uses: ./.github/actions/download-pkg
      - run: pnpm test

  other-check:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    needs: [setup]
    env:
      WORKING_DIR_SITE: site
    steps:
      - uses: actions/checkout@v4
      - uses: ./.github/actions/setup
      - uses: ./.github/actions/download-pkg

      # site checks
      - run: pnpm check
        working-directory: ${{ env.WORKING_DIR_SITE }}
      - run: pnpm build
        working-directory: ${{ env.WORKING_DIR_SITE }}