audit: rescue stranded audit work (CI, ROM verification, integration tests, README A+, CoC) #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 | |
| # Install from pyproject dependency ranges, NOT requirements.txt: | |
| # the pins there are frozen from the local Python 3.13 research | |
| # venv and do not resolve on 3.10-3.12 (contourpy/protobuf | |
| # conflicts). CI validates the library install path; the exact | |
| # paper environment is documented by 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: Install SDL2 system libraries | |
| # The script imports pokemon_red_ai.game.event_flags, whose | |
| # package __init__ chain pulls in PyBoy, which needs SDL2. | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libsdl2-2.0-0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| cache: pip | |
| cache-dependency-path: pyproject.toml | |
| - name: Install package | |
| # The script's own logic is stdlib-only, but importing | |
| # BOULDER_PATH_FLAGS executes pokemon_red_ai/__init__.py, which | |
| # imports the full package (numpy, torch, pyboy, ...). | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e . | |
| - name: Verify | |
| # Fetches the live disassembly and diffs against | |
| # BOULDER_PATH_FLAGS. Catches the class of bug that PR #45 | |
| # fixed. Defensive: on branches based on an earlier main where | |
| # the script doesn't exist, 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 |