ajhahn.de
← the-way-out
YAML 83 lines
# CI: lint, test, headless import smoke, plus a macOS PyInstaller build
# that uploads the .zip the in-app updater would otherwise wait for the
# operator to ship by hand. Runs on every PR and on push to main.
# Read-only token by design.

name: ci

on:
  pull_request:
  push:
    branches: [main]

concurrency:
  group: ci-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
  contents: read

jobs:
  check:
    name: lint + tests
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v4
      - name: setup-python
        uses: actions/setup-python@v5
        with:
          python-version: "3.12"
          cache: pip
      - name: install
        # Pinned to the same versions pyproject.toml declares so a green
        # CI run says the same thing as a green local run.
        run: |
          python -m pip install --upgrade pip
          pip install "pygame==2.6.1" "ruff==0.15.14" "pytest==9.0.3"
      - name: ruff
        run: ruff check .
      - name: pytest
        env:
          SDL_VIDEODRIVER: dummy
          SDL_AUDIODRIVER: dummy
        run: pytest
      - name: import smoke
        # Belt-and-braces: pytest covers the testable subset; this also
        # exercises the menu/level/editor constructors that run at
        # ``import main``. The dummy SDL drivers are required — the
        # runner has no display and no audio device.
        env:
          SDL_VIDEODRIVER: dummy
          SDL_AUDIODRIVER: dummy
        run: python -c "import main"

  build:
    name: build (macOS)
    runs-on: macos-latest
    steps:
      - name: checkout
        uses: actions/checkout@v4
      - name: setup-python
        uses: actions/setup-python@v5
        with:
          python-version: "3.12"
          cache: pip
      - name: prepare .venv
        # build_mac.sh runs from .venv/bin/python — it explicitly forbids
        # system python3 (3.14 is incompatible with PyInstaller 6.20).
        # Pre-install pygame so the script's own --upgrade pyinstaller
        # is the only network hop it has to do.
        run: |
          python -m venv .venv
          .venv/bin/pip install --upgrade pip
          .venv/bin/pip install "pygame==2.6.1"
      - name: build .app + zip
        run: ./build_mac.sh
      - name: upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: TheWayOut-mac
          path: dist/TheWayOut-mac.zip
          if-no-files-found: error