name: htmx 4 CI

on:
  push:
    branches: [four, four-dev]
  pull_request:
    branches: [four, four-dev]
  workflow_dispatch:

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

jobs:
  htmx_tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: oven-sh/setup-bun@v2
      - uses: actions/cache@v4
        with:
          path: ~/.bun/install/cache
          key: bun-${{ runner.os }}-${{ hashFiles('bun.lock', 'package.json') }}
          restore-keys: bun-${{ runner.os }}-
      - run: bun install --frozen-lockfile
      - uses: actions/cache@v4
        with:
          path: ~/.cache/ms-playwright
          key: playwright-${{ runner.os }}-${{ hashFiles('bun.lock', 'package.json') }}
          restore-keys: playwright-${{ runner.os }}-
      - run: bunx playwright install --with-deps chromium
      - run: bun run test

  website_tests:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: www
    steps:
      - uses: actions/checkout@v4
      - uses: oven-sh/setup-bun@v2
      - uses: actions/cache@v4
        with:
          path: ~/.bun/install/cache
          key: bun-www-${{ runner.os }}-${{ hashFiles('www/bun.lock') }}
          restore-keys: bun-www-${{ runner.os }}-
      - run: bun install --frozen-lockfile
      - uses: actions/cache@v4
        with:
          path: ~/.cache/ms-playwright
          key: playwright-${{ runner.os }}-${{ hashFiles('www/bun.lock') }}
          restore-keys: playwright-${{ runner.os }}-
      - run: bunx playwright install --with-deps chromium
      - run: bun run build
      - run: bun run test

  content:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: python3 src/scripts/content/check.py
