name: Validate

on:
  - pull_request
  - push

permissions: {}

jobs:
  validate:
    name: Lint & Test
    if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
    permissions:
      checks: write
    runs-on: ubuntu-latest
    timeout-minutes: 20
    steps:
      - name: Check out repo
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

      - name: Set up pnpm
        uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9

      - name: Set up Node.js
        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
        with:
          node-version-file: .nvmrc

      - name: Install dependencies
        run: pnpm install --frozen-lockfile

      - name: Test
        run: pnpm test:ci

      - name: Lint
        run: pnpm lint
