name: CI

on:
  pull_request:
  push:
    branches:
      - main

jobs:
  commitlint:
    if: github.event_name == 'pull_request'
    runs-on: ubuntu-latest
    name: Commitlint
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Commitlint
        uses: wagoid/commitlint-github-action@v6

  tests:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        node: ["20.x", "22.x", "24.x"]
        eslint: [9]
    name: Node.js ${{ matrix.node }} with ESLint ${{ matrix.eslint }}
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v4
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node }}
          cache: npm
      - name: Install Dependencies
        run: |
          npm ci
          npm install --no-save eslint@${{ matrix.eslint }}
        env:
          NODE_ENV: development
          HUSKY: 0
      - name: Unit Tests
        run: npm run test:unit
        env:
          NODE_ENV: production
      - name: Lockfile Lint Test
        run: npm run test:lockfile
      - name: Lint
        run: npm run test:lint
