name: UI tests

on:
  pull_request:
    paths:
      - .github/workflows/ui-tests.yml
      - ui/**
      - .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: '.nvmrc'
          cache-dependency-path: '**/package-lock.json'

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

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