name: Check Scripts

on:
  pull_request:
    branches:
      - master
    paths:
      - scripts/**
      - package.json
      - yarn.lock
      - .prettierrc
      - tsconfig.json
  workflow_dispatch:

jobs:
  check-node-scripts:
    name: Check Node.js Scripts
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20.x'
          check-latest: true
      - name: Cache Node.js dependencies
        uses: actions/cache@v4
        id: cache-node
        with:
          path: node_modules
          key: ${{ runner.os }}-node-dev-${{ hashFiles('yarn.lock') }}
          restore-keys: ${{ runner.os }}-node-dev-
      - name: Install Node.js dependencies
        if: steps.cache-node.outputs.cache-hit != 'true'
        run: yarn --frozen-lockfile
      - name: Check Prettier Format
        run: yarn scripts:format:check
      - name: Check TypeScript Compile
        run: yarn tsc

  check-python-scripts:
    name: Check Python Scripts
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.10'
      - name: Install uv
        uses: astral-sh/setup-uv@v6
        with:
          version: "latest"
      - name: Install Python dependencies
        run: uv sync --group dev
      - name: Run All Python Unit Tests
        run: |
          uv run python3 -m unittest
