name: Python

env:
    APT_DEPS: git python3 python3-pip python3-venv python3-gi python3-cairo python3-dbus python3-pyudev python3-psutil python3-evdev python3-yaml python3-xlib python3-pillow gir1.2-gtk-3.0

on:
    pull_request:

jobs:
    static:
        runs-on: debian
        container: node:26-trixie-slim

        steps:
            - name: Checkout
              uses: actions/checkout@v4

            - name: Install tools
              run: |
                  apt-get update
                  apt-get install -y --no-install-recommends git python3 python3-pip python3-venv
                  python3 -m venv .venv
                  . .venv/bin/activate
                  pip install --no-cache-dir ruff

            - name: Format check
              run: |
                  . .venv/bin/activate
                  ruff format --check .

            - name: Lint
              run: |
                  . .venv/bin/activate
                  ruff check .

    verify:
        if: always()
        runs-on: debian
        container: node:26-trixie-slim

        steps:
            - name: Checkout
              uses: actions/checkout@v4

            - name: Install tools
              run: |
                  apt-get update
                  apt-get install -y --no-install-recommends $APT_DEPS build-essential python3-dev
                  python3 -m venv --system-site-packages .venv
                  . .venv/bin/activate
                  pip install --no-cache-dir basedpyright nuitka .

            - name: Type check
              run: |
                  . .venv/bin/activate
                  basedpyright

            - name: Test
              run: |
                  . .venv/bin/activate
                  cd cli
                  python -m pytest tests/ -v

            - name: Nuitka module check
              run: |
                  . .venv/bin/activate
                  nuitka --module --include-package=zshell cli/src/zshell/