name: Verify API
on:
  push:
    branches:
      - main
      - release-*
    paths:
      - 'scripts/*'
      - 'api-generator/*'
  pull_request:
    branches:
      - main
      - release-*
    paths:
      - 'scripts/**'
      - 'api-generator/**'
jobs:
  verify:
    timeout-minutes: 30
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Download drivers
        run: scripts/download_driver.sh
      - name: Regenerate APIs
        run: scripts/generate_api.sh
      - name: Build & Install
        run: mvn -B install -D skipTests --no-transfer-progress
      - name: Install browsers
        run: mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install --with-deps" -f playwright/pom.xml --no-transfer-progress
      - name: Update browser versions in README
        run: scripts/update_readme.sh
      - name: Verify API is up to date
        run: |
          if [[ -n $(git status -s) ]]; then
            echo "ERROR: generated interfaces/docs differ from the current sources:"
            git diff
            exit 1
          fi
