diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..1dbc0c7 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,33 @@ +name: Tests + +on: + pull_request: + branches: [main] + push: + branches: [main] + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + steps: + # The Viron submodule is deliberately not checked out: the test suite stubs it in + # sys.modules, and only main.py needs it at runtime. + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + + # render_window.py imports pygame, and tests/test_headless_run.py drives the real + # pygame with SDL's dummy drivers, so it has to be installed even though most tests mock it. + - name: Install dependencies + run: python -m pip install pygame + + - name: Check syntax + run: python -m py_compile main.py graphik.py __init__.py render_window.py headless_run.py usage_reporting.py trace_client.py + + - name: Run unit tests + run: python -m unittest discover -s tests diff --git a/README.md b/README.md index f9760b9..f237252 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,8 @@ python -m unittest discover -s tests Run the command from the repository root, so that `main.py` and `render_window.py` are importable. +The same command, preceded by a `py_compile` syntax check of the top-level modules, is run by the `Tests` GitHub Actions workflow (`.github/workflows/tests.yml`) on every pull request targeting `main` and on every push to `main`. The workflow checks the repository out without the `Viron` submodule, since the suite does not need it. + ### Running without Docker or a display `headless_run.py` drives `main()` end to end when neither a Viron server nor a display is available. The real Pygame, `RenderWindow` and `Graphik` are used, rendering to SDL's `dummy` video and audio drivers (unless `SDL_VIDEODRIVER` or `SDL_AUDIODRIVER` is already set); only Viron is replaced, by in-memory services with one location per grid cell. Like the test suite, it needs neither the `Viron/` submodule nor Python 3.10+.