name: Checks
on:
  push:
    branches:
      - main
      - test-buildscript*
      - dev/*
    paths-ignore:
      - "README.md"

  pull_request:
    branches:
      - main
    paths-ignore:
      - "README.md"

jobs:
  checks:
    name: Checks
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Ref
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Restore NPM Cached Files
        uses: actions/cache@v4
        id: npm-cache
        with:
          path: |
            ~/.npm
            ./tools/node_modules
          key: ${{ runner.os }}-npm-${{ hashFiles('./tools/package-lock.json') }}
          restore-keys: ${{ runner.os }}-npm-

      - name: Setup NodeJS v20
        uses: actions/setup-node@v4
        with:
          node-version: 20
          check-latest: true

      - name: Setup NPM Packages
        if: steps.npm-cache.outputs.cache-hit != 'true'
        working-directory: ./tools
        run: npm ci

      - name: Check Buildscripts
        working-directory: ./tools
        run: npm run check

      - name: Check QB
        working-directory: ./tools
        run: npm run gulp checkQB
