name: Checkstyle

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
  merge_group:
    types: [checks_requested]
    branches:
      - main
  workflow_dispatch:  # Enables manual trigger

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.merge_group.head_ref || github.ref }}
  cancel-in-progress: true

jobs:
  checkstyle:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v6

    - name: Set up Python
      uses: actions/setup-python@v6
      with:
        python-version: '3.10'

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r dev/fmt-requirements.txt

    - name: Run checkstyle
      run: make checkstyle
