Skip to content

audit: rescue stranded audit work (CI, ROM verification, integration tests, README A+, CoC) #1

audit: rescue stranded audit work (CI, ROM verification, integration tests, README A+, CoC)

audit: rescue stranded audit work (CI, ROM verification, integration tests, README A+, CoC) #1

Workflow file for this run

# Test workflow for pokemon-red-ai.
#
# Runs pytest on every push to main/develop and every PR. Matrix covers
# the Python versions listed in pyproject.toml (3.10, 3.11, 3.12).
#
# PyBoy requires SDL2 libraries to import; the apt step installs them on
# the Ubuntu runner. Tests themselves mock PyBoy so no ROM is needed.
name: Test
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch: {}
permissions:
contents: read
concurrency:
# One run per branch. Cancel in-progress runs when a new commit lands
# on the same branch — keeps CI time down on rapid pushes.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pytest:
name: pytest (py${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install SDL2 system libraries
# PyBoy imports SDL2 at module level even when running headless.
# libsdl2-2.0-0 is enough to satisfy the loader without pulling
# in X11 development headers.
run: |
sudo apt-get update
sudo apt-get install -y libsdl2-2.0-0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: |
requirements.txt
pyproject.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# requirements.txt pins all runtime deps including pyboy/torch.
# -e . installs the project itself so test imports resolve.
pip install -r requirements.txt
pip install -e .
pip install pytest pytest-cov
- name: Run pytest
# --strict-markers is set in pyproject.toml; -ra surfaces skip/xfail.
# Coverage runs only on the Python version the paper will report
# (3.12) to keep the matrix fast.
run: |
if [ "${{ matrix.python-version }}" = "3.12" ]; then
pytest --cov=pokemon_red_ai --cov-report=term-missing --cov-report=xml
else
pytest
fi
- name: Upload coverage artifact
if: matrix.python-version == '3.12'
uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: coverage.xml
if-no-files-found: warn
verify-event-flags:
name: Verify event-flag IDs against pret/pokered
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Verify
# Pure stdlib — no project install needed. Fetches the live
# disassembly and diffs against BOULDER_PATH_FLAGS. Catches the
# class of bug that PR #45 fixed. Defensive: this script lands
# in PR #45; on branches based on an earlier main, skip rather
# than fail.
run: |
if [ -f scripts/verify_event_flag_ids.py ]; then
python scripts/verify_event_flag_ids.py
else
echo "::warning::scripts/verify_event_flag_ids.py not present; skipping"
fi