name: Tests

on:
  push:
    branches:
      - main
  pull_request:
    # This is the default list, but I don't know how to YAML an empty pull_request:
    types: [opened, reopened, synchronize]

permissions:
  contents: read

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-node@v3
        with:
          node-version: 24.5
          cache: 'npm'
          cache-dependency-path: package-lock.json

      - name: NPM install
        run: npm ci

      - name: Lint
        run: npm run lint

      - name: Check formatting
        run: npm run format:check

  tests-local:
    runs-on: ubuntu-latest
    env:
      WIREIT_LOGGER: quiet-ci
      WIREIT_PARALLEL: 1

    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-node@v3
        with:
          node-version: 24.5
          cache: 'npm'
          cache-dependency-path: package-lock.json

      # - uses: google/wireit@setup-github-actions-caching/v2

      - name: Log Node and NPM versions
        run: node --version && npm --version
        
      - name: NPM install
        run: npm ci

      - name: Install playwright browsers
        run: npx playwright install --with-deps

      - name: Build
        run: npm run build

      - name: Test
        env:
          BROWSERS: preset:local
          CONCURRENT_BROWSERS: 3
        run: npm run test

  windows-tools:
    runs-on: windows-latest
    env:
      WIREIT_LOGGER: quiet-ci
      WIREIT_PARALLEL: 1

    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-node@v3
        with:
          node-version: 24.5
          cache: 'npm'
          cache-dependency-path: package-lock.json

      # - uses: google/wireit@setup-github-actions-caching/v2

      - name: NPM install
        run: npm ci

      - name: Install playwright browsers
        run: npx playwright install --with-deps

      - name: Test
        env:
          RUN_BROWSER_TESTS: false
        run: npm run test:windows
