name: Validate

on:
  pull_request:
  push:
    branches: [main]

permissions:
  contents: read

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          fetch-depth: 0
          persist-credentials: false
      - name: Check committed changes
        env:
          CI_EVENT_NAME: ${{ github.event_name }}
          CI_PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
          CI_PUSH_BEFORE_SHA: ${{ github.event.before }}
        run: scripts/check-committed-diff.sh
      - name: Set up Node.js
        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
        with:
          node-version: 22
          cache: npm
      - name: Install dependencies
        run: npm ci
      - name: Install the pinned Chromium browser
        run: npx playwright install --with-deps chromium
      - name: Run offline tests
        run: npm test
      - name: Run loopback-only egress tests
        run: npm run test:egress
