# Copyright (c) 2017-2026 Juancarlo Añez (apalala@gmail.com)
# SPDX-License-Identifier: BSD-4-Clause
# by [apalala@gmail.com](https://github.com/apalala)
# by Gemini (2026-02-03)

name: tests default
on:
  push:
    branches: [ master ]
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version:
          - '3.15'
          - '3.14'
          - '3.13'
          - '3.12'

    steps:
      - uses: actions/checkout@v4
        with:
          # fetch-depth 2 allows git diff HEAD^ HEAD to work reliably
          fetch-depth: 2
      - name: install system dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y graphviz

      - name: install python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
          allow-prereleases: true

      - name: install dependencies
        run: |
          python3 -m pip install -U pip
          python3 -m pip install -r requirements-test.txt

      - name: env
        run: |
          python3 --version
          python3 -c "import pytest"
          python3 -m tatsu --version

      - name: ruff
        run: |
          python3 -m ruff check -q --preview tatsu tests examples
      - name: ty
        run: |
          python3 -m ty check tatsu tests examples
      - name: pyright
        run: |
          python3 -m basedpyright tatsu tests examples
      - name: pytest
        run: |
          python3 -m pytest tests

  docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.14'
      - name: install dependencies
        run: |
          python -m pip install -r requirements-doc.txt
          python -m pip install sphinx
      - name: docs
        run: |
          python -m sphinx docs/ docs/_build/

  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.14'
      - name: install dependencies
        run: |
          python -m pip install build
      - name: build
        run: |
          python -m build
