name: frontend

on:
  push:
    branches:
      - "**"
  pull_request:
  workflow_dispatch:

jobs:
  frontend:
    runs-on: ubuntu-latest

    steps:
      - name: Check out repository
        uses: actions/checkout@v4

      - name: Set up Node
        uses: actions/setup-node@v4
        with:
          node-version: "22"
          cache: npm
          cache-dependency-path: frontend/package-lock.json

      - name: Install dependencies
        working-directory: frontend
        run: npm ci

      - name: Check codegen is in sync
        working-directory: frontend
        run: |
          npm run codegen
          git diff --exit-code src/api/schema.d.ts

      - name: Lint
        working-directory: frontend
        run: npm run lint

      - name: Type-check
        working-directory: frontend
        run: npm run typecheck

      - name: Test
        working-directory: frontend
        run: npm run test

      - name: Build
        working-directory: frontend
        run: npm run build
