Add CI + test-settings shim + split tests into a package (#1279) - #1280
Merged
Conversation
First PR off the testing roadmap (#1278). Three interdependent infra changes; no production code or test logic changes. 1. Test-settings shim — makeabilitylab/settings_test.py sets MIGRATION_MODULES={'website': None} so the test DB is built directly from the current models, sidestepping the gitignored, per-environment website/migrations/ history. Durable fix for the "column already exists" test-DB flakiness (#1267). Also reads DATABASE_HOST/PORT from env so CI can point at its Postgres service. 2. GitHub Actions CI — .github/workflows/test.yml runs the suite on every push to master and every PR, against a postgres:16 service container, mirroring the Dockerfile's ImageMagick/Ghostscript deps. Reports status only (free/unlimited for this public repo); does not block pushes. 3. Split website/tests.py (~1,580 lines) into a website/tests/ package: tests/base.py (DatabaseTestCase + fixtures) plus test_*.py by concern. Pure move — 99 tests before and after, all passing. Docs (CLAUDE.md, CONTRIBUTING.md, docs/DEPLOYMENT.md) updated to use the shim and document CI. Verified: `manage.py test website --settings=makeabilitylab.settings_test` runs 99 tests OK on a clean test DB with no manual DROP DATABASE step. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
settings.py wires a RotatingFileHandler to the container path /code/media/debug.log. Django evaluates LOGGING at startup, so on a host without that dir (a GitHub Actions runner) django.setup() raised FileNotFoundError before any test ran. The test shim now swaps the 'file' handler for a logging.NullHandler, keeping every logger's handler reference valid while never touching disk. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1279. First PR off the testing roadmap (#1278).
What & why
We started writing automated tests a few days ago (#1267), but nothing runs them automatically — and we auto-deploy
masterto the test server on every push, with no checks in between. This PR closes that gap with three interdependent, infra-only changes (no production code or test logic changed).1. Test-settings shim —
makeabilitylab/settings_test.pySets
MIGRATION_MODULES = {'website': None}so the test runner builds thewebsiteschema directly from the current models instead of replaying the gitignored, per-environmentwebsite/migrations/history. This is the durable fix for thecolumn "..." already existstest-DB flakiness (#1267) — and a prerequisite for CI, since a clean runner has no migrations on disk. Also readsDATABASE_HOST/DATABASE_PORTfrom env so CI can point at its Postgres service (defaults inheritHOST='db'for local container runs).2. GitHub Actions CI —
.github/workflows/test.ymlRuns
manage.py test website --settings=makeabilitylab.settings_teston every push tomasterand every PR, against apostgres:16service container, after installing the same ImageMagick/Ghostscript/libpq deps the Dockerfile uses (so the Talk thumbnail path works). GitHub Actions is free + unlimited for this public repo. It reports status only — a red ✗ + email on failure; it does not block the push or the deploy. No branch protection configured.3. Split
website/tests.py→website/tests/packageThe ~1,580-line monolith becomes one
test_*.pyper concern (Django auto-discovers them), with shared DB fixtures intests/base.py. Pure move: 99 tests before, 99 after, all passing.test_bio_utils.pytest_publication.pyget_persontest_project.pytest_artifact.pytest_video.pyget_age_in_mstest_serve_pdf.pytest_views.pytest_data_health.pyDocs updated (
CLAUDE.md,CONTRIBUTING.md,docs/DEPLOYMENT.md) to use the shim and document CI.Verification
docker exec makeabilitylabwebsite-website-1 python manage.py test website --settings=makeabilitylab.settings_test→ Ran 99 tests … OK, on a clean test DB with no manualDROP DATABASEstep.Out of scope (later PRs, tracked in #1278)
Coverage reporting, test backfill (
delete_unused_files, view smoke-sweep), Pa11y-in-CI, factory_boy (#1272).🤖 Generated with Claude Code