name: Build Check

on:
  push:
    branches-ignore:
      - 'build'
    paths:
      - 'src/**'
      - 'demos/**/*.ts'
      - 'samples/**/*.ts'
      - 'package.json'
      - 'package-lock.json'
      - 'tsconfig*.json'
      - 'rollup.config.js'
      - 'vitest.config.ts'
      - '.github/workflows/build-check.yml'
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v6

      - name: Setup Node.js
        uses: actions/setup-node@v6
        with:
          node-version: '24'
          cache: 'npm'

      - name: Cache Node Modules
        id: cache-node-modules
        uses: actions/cache@v5
        with:
          path: node_modules
          key: ${{ runner.os }}-node-root-${{ hashFiles('package-lock.json') }}

      - name: Install dependencies
        if: steps.cache-node-modules.outputs.cache-hit != 'true'
        run: npm ci

      - name: Build project
        run: npm run build

      - name: Run tests
        run: npm run test
