Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Coverage.py configuration (#1278 item 4 — testing roadmap).
#
# We measure the `website` app only: that's the code we own and want to
# backfill. Django itself, third-party packages, and the vendored in-repo forks
# (image_cropping/, sortedm2m_filter_horizontal_widget/) are deliberately out of
# scope. Coverage is REPORT-ONLY in CI — there is no --fail-under gate yet; the
# percentage is a signal for targeting backfill (item 5), not a pass/fail bar.
#
# Run locally (inside the container, after `pip install -r requirements-dev.txt`):
# coverage run manage.py test website --settings=makeabilitylab.settings_test
# coverage report # text table with missing line numbers
# coverage html # browsable htmlcov/ report

[run]
source = website
# Branch coverage: also tracks whether both sides of an if/else were taken,
# not just whether a line ran. More honest signal for view/utility logic.
branch = True
omit =
# The tests themselves aren't production code.
website/tests/*
# Per-environment migrations are gitignored and disabled in the test
# settings (MIGRATION_MODULES = {'website': None}), so they never execute.
website/migrations/*

[report]
# Show the line numbers that aren't covered, so the report points at the gaps.
show_missing = True
# exclude_also ADDS to coverage's built-in defaults (which already include
# "pragma: no cover"), rather than replacing them.
exclude_also =
def __repr__
raise NotImplementedError
if __name__ == .__main__.:
if TYPE_CHECKING:
25 changes: 23 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,29 @@ jobs:
- name: Install Python dependencies
run: pip install -r requirements.txt

- name: Run tests
run: python manage.py test website --settings=makeabilitylab.settings_test --verbosity=2
# coverage.py is a test-only tool (lives in requirements-dev.txt) — install
# it directly here rather than pulling all of requirements-dev.txt, which
# would drag in Playwright. Keep this pin in sync with requirements-dev.txt.
- name: Install coverage
run: pip install coverage==7.14.1

# `coverage run` wraps the same test command and propagates its exit code,
# so a test failure still fails this step (red ✗ + email). Config is in
# .coveragerc (measures the `website` app, branch coverage on).
- name: Run tests with coverage
run: coverage run manage.py test website --settings=makeabilitylab.settings_test --verbosity=2

# Report-only: no --fail-under gate. Print to the log and also publish a
# table to the run's Summary so the number is visible without opening logs.
# Skipped automatically if the test step above failed.
- name: Coverage report
run: |
coverage report
{
echo "## Coverage — website app"
echo
coverage report --format=markdown
} >> "$GITHUB_STEP_SUMMARY"

# Browser end-to-end tests (member-page "Load more"/"Load all", bio toggle,
# section nav). Kept in a SEPARATE job from `test` so the fast unit/integration
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ docker_makelab_build.log
a11y-report.json
repomix-output.xml
codebase-analysis.md

# coverage.py artifacts (#1278 item 4) — the data file and HTML/XML reports are
# written into the repo root (the container's CWD is the bind-mounted /code).
.coverage
.coverage.*
htmlcov/
coverage.xml
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ A superuser is required to use `/admin` and add content; create one with `python
- When fixing a bug reachable through a real queryset, URL, or view, add a regression test in the matching style before applying the fix (matches the tests-first workflow).
- **Always use the `--settings=makeabilitylab.settings_test` shim.** It sets `MIGRATION_MODULES = {'website': None}` so the test DB is built directly from the current models, sidestepping the gitignored, per-environment `website/migrations/` history. This is the durable fix for #1267 — without it, a fresh test DB can fail at creation with `column "..." already exists` (old workaround: `docker exec makeabilitylabwebsite-db-1 psql -U admin -d postgres -c "DROP DATABASE IF EXISTS test_makeability;"`).
- **CI:** `.github/workflows/test.yml` runs this same command on every push to `master` and every PR (free/unlimited for this public repo). It reports a green ✓ / red ✗ — it does not block pushes or the deploy. See the testing roadmap in #1278.
- **Coverage (#1278 item 4):** the CI `test` job wraps the suite in `coverage run` and publishes a table to the run's Summary; config is in `.coveragerc` (measures the `website` app, branch coverage on). It's **report-only** — no `--fail-under` gate; the number targets backfill. Run locally inside the container: `pip install -r requirements-dev.txt`, then `coverage run manage.py test website --settings=makeabilitylab.settings_test && coverage report` (or `coverage html` for a browsable `htmlcov/`).
- Accessibility (Pa11y CI + Axe, WCAG 2.0 AA): start the site, then `docker-compose -f docker-compose-local-dev.yml --profile testing run --rm a11y`. URLs to scan are configured in `.pa11yci.json`. Run this before submitting UI changes.

## Deployment
Expand Down
18 changes: 17 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ This document outlines how to set up your local development environment and our
- [Running the Test Suite](#running-the-test-suite)
- [When to add a test](#when-to-add-a-test)
- [Troubleshooting](#troubleshooting-tests)
- [Continuous integration](#continuous-integration)
- [Test coverage](#test-coverage)
- [Accessibility Testing](#accessibility-testing)
- [Running Accessibility Checks](#running-accessibility-checks)
- [Configuring Tests](#configuring-tests)
Expand Down Expand Up @@ -290,7 +292,21 @@ If you forget the shim and the legacy `manage.py test website` fails at test-DB

### Continuous integration

`.github/workflows/test.yml` runs the suite (with the test-settings shim, against a Postgres 16 service container) on every push to `master` and every pull request. GitHub Actions is free and unlimited for this public repo. A failing run shows a red ✗ on the commit/PR and emails the author — it **reports** status, it does not block the push or the test-server deploy. The broader testing roadmap (coverage, Pa11y-in-CI, test backfill) is tracked in [#1278](https://github.com/makeabilitylab/makeabilitylabwebsite/issues/1278).
`.github/workflows/test.yml` runs the suite (with the test-settings shim, against a Postgres 16 service container) on every push to `master` and every pull request. GitHub Actions is free and unlimited for this public repo. A failing run shows a red ✗ on the commit/PR and emails the author — it **reports** status, it does not block the push or the test-server deploy. Each run also measures coverage (see [Test coverage](#test-coverage)). The remaining testing roadmap (Pa11y-in-CI, test backfill) is tracked in [#1278](https://github.com/makeabilitylab/makeabilitylabwebsite/issues/1278).

### Test coverage

The CI `test` job wraps the suite in [`coverage`](https://coverage.readthedocs.io/) and posts a per-file table to the run's **Summary** tab. Coverage is **report-only** — there is no `--fail-under` gate, so a low number never fails CI; it's a signal for deciding what to backfill next (#1278 item 5). Configuration is in `.coveragerc`: it measures the `website` app with branch coverage on, and leaves the vendored forks (`image_cropping/`, `sortedm2m_filter_horizontal_widget/`) and third-party packages out of scope.

To see coverage locally, inside the container:

```bash
# coverage lives in requirements-dev.txt (test-only, not in the prod image)
pip install -r requirements-dev.txt
coverage run manage.py test website --settings=makeabilitylab.settings_test
coverage report # text table with the uncovered line numbers
coverage html # browsable htmlcov/index.html
```

## Accessibility Testing

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ makeabilitylabwebsite/
| [CONTRIBUTING.md](CONTRIBUTING.md) | Local development setup, workflow, and pull request guidelines |
| [docs/DEPLOYMENT.md](docs/DEPLOYMENT.md) | Production servers, logging, and data management |
| [.pa11yci.json](.pa11yci.json) | Accessibility test configuration (Pa11y + Axe) |
| [.coveragerc](.coveragerc) | Test-coverage configuration (coverage.py; reported in CI) |
| [Troubleshooting Wiki](https://github.com/makeabilitylab/makeabilitylabwebsite/wiki/Troubleshooting) | Common issues and solutions |

## 🤝 Contributing
Expand Down
6 changes: 6 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@
# lockstep (a mismatch makes `playwright install` download the wrong revision).
-r requirements.txt
playwright==1.60.0

# coverage.py — test-coverage measurement (#1278 item 4). Used locally
# (`coverage run manage.py test ...`, see .coveragerc) and pinned identically in
# the CI `test` job, which installs it directly rather than pulling all of
# requirements-dev.txt (it has no need for Playwright). Keep the two pins in sync.
coverage==7.14.1
Loading