name: Node

on:
  pull_request:
  push:
    branches-ignore: "dependabot/**"

permissions:
  contents: read

env:
  NODE_VERSION: 22.x

jobs:
  build-and-test:
    runs-on: ubuntu-latest
    name: Build & lint

    steps:
      - name: Checkout
        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

      - name: Use Node.js ${{ env.NODE_VERSION }}
        uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
        with:
          node-version: ${{ env.NODE_VERSION }}
          cache: npm
          cache-dependency-path: '**/package-lock.json'

      - name: Install npm dependencies
        run: npm ci

      - name: Build
        run: npm run build

      # Lint must happen after build as we lint generated files.
      - name: Lint
        run: npm run lint
