name: test-web

# Web SPA: vitest + svelte-check. Runs on push to dev/main and PRs to
# main, scoped to web/** changes only — Go-only or Flutter-only diffs
# don't trigger this workflow.

on:
  push:
    branches: [dev, main]
    paths:
      - 'web/**'
      - '.forgejo/workflows/test-web.yml'
  pull_request:
    branches: [main]
    paths:
      - 'web/**'
      - '.forgejo/workflows/test-web.yml'

jobs:
  test:
    runs-on: go-ci

    defaults:
      run:
        working-directory: web

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Node
        # `cache: 'npm'` removed — the Forgejo Actions cache server at
        # 172.18.0.27:41161 isn't reachable from this runner's container,
        # so setup-node spent 4m41s burning the npm cache restore on
        # ETIMEDOUT before failing open. npm ci still works deterministically
        # from package-lock.json; just re-fetches from the registry on each
        # run. Restore the cache option once the runner-host network reaches
        # the cache server.
        uses: actions/setup-node@v4
        with:
          node-version: '22'

      - name: Install deps
        run: npm ci

      - name: Type-check + svelte-check
        run: npm run check

      - name: Vitest
        run: npm test
