name: Lint

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: "3.10"

      - name: Install pre-commit hook
        run: |
          python -m pip install pre-commit
          pre-commit install

      - name: Run pre-commit checks
        run: SKIP=no-commit-to-branch pre-commit run --all-files --show-diff-on-failure

      - name: Run sgl-kernel clang-format checks
        uses: DoozyX/clang-format-lint-action@v0.18.1
        with:
          source: sgl-kernel
          extensions: h,c,cpp,hpp,cu,cuh,cc
          clangFormatVersion: 18
          style: file
