Skip to content

Add CI + test-settings shim + split tests into a package (#1279) - #1280

Merged
jonfroehlich merged 2 commits into
masterfrom
1279-ci-test-shim-package-split
Jun 15, 2026
Merged

Add CI + test-settings shim + split tests into a package (#1279)#1280
jonfroehlich merged 2 commits into
masterfrom
1279-ci-test-shim-package-split

Conversation

@jonfroehlich

Copy link
Copy Markdown
Member

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 master to 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.py

Sets MIGRATION_MODULES = {'website': None} so the test runner builds the website schema directly from the current models instead of replaying the gitignored, per-environment website/migrations/ history. This is the durable fix for the column "..." already exists test-DB flakiness (#1267) — and a prerequisite for CI, since a clean runner has no migrations on disk. Also reads DATABASE_HOST/DATABASE_PORT from env so CI can point at its Postgres service (defaults inherit HOST='db' for local container runs).

2. GitHub Actions CI — .github/workflows/test.yml

Runs manage.py test website --settings=makeabilitylab.settings_test on every push to master and every PR, against a postgres:16 service 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.pywebsite/tests/ package

The ~1,580-line monolith becomes one test_*.py per concern (Django auto-discovers them), with shared DB fixtures in tests/base.py. Pure move: 99 tests before, 99 after, all passing.

Module Classes
test_bio_utils.py role/contributions/mentor-mentee sentences, HTML escaping, oxford-comma, humanize-duration
test_publication.py BibTeX, formatted forum name, get_person
test_project.py member count, time-worked annotation
test_artifact.py filename-drift check, raw-file label
test_video.py get_age_in_ms
test_serve_pdf.py exact/fuzzy PDF resolution
test_views.py null-author news view, talk slides URL, publications query-count
test_data_health.py name utils + all Data Health checks/auth/CSV

Docs 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_testRan 99 tests … OK, on a clean test DB with no manual DROP DATABASE step.
  • Test count unchanged across the split (99 → 99).
  • CI's own run on this PR is the live check that the workflow itself is correct.

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

jonfroehlich and others added 2 commits June 15, 2026 05:59
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add GitHub Actions CI + test-settings shim + split tests into a package

1 participant