name: UI v2 Checks

on:
  pull_request:
    paths:
      - .github/workflows/ui-v2-checks.yml
      - ui-v2/**
      - .nvmrc
  push:
    branches:
      - main

permissions:
  contents: read

# Limit concurrency by workflow/branch combination.
#
# For pull request builds, pushing additional changes to the
# branch will cancel prior in-progress and pending builds.
#
# For builds triggered on a branch push, additional changes
# will wait for prior builds to complete before starting.
#
# https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
  build-ui:
    name: Build ui
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6

      - uses: actions/setup-node@v6
        with:
          node-version-file: "ui-v2/.nvmrc"
          cache-dependency-path: "**/package-lock.json"

      - name: Install UI dependencies
        working-directory: ./ui-v2
        run: npm ci

      - name: Setup Biome CLI
        uses: biomejs/setup-biome@v2
        with:
          working-dir: ./ui-v2

      - name: Run Biome checks
        working-directory: ./ui-v2
        run: biome ci

      - name: Lint
        working-directory: ./ui-v2
        run: npm run lint

      - name: Build UI
        working-directory: ./ui-v2
        run: npm run build

      - name: Run tests
        working-directory: ./ui-v2
        run: npm run test
