-
Notifications
You must be signed in to change notification settings - Fork 66
240 lines (208 loc) · 8.49 KB
/
Copy pathtest.yml
File metadata and controls
240 lines (208 loc) · 8.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
name: Tests
# Runs the Django test suite on every push to master (our test-server deploy
# trigger) and on every pull request. A failing run is a red ✗ + email — it
# reports status only and does not block the push or the deploy.
on:
push:
branches: [master]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
# Postgres service mirrors the local-dev / server `db` container
# (postgres:16, makeability / admin / password).
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: makeability
POSTGRES_USER: admin
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U admin -d makeability"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
# settings_test.py reads these to reach the Postgres service above.
DATABASE_HOST: localhost
DATABASE_PORT: 5432
DJANGO_ENV: DEBUG
steps:
- uses: actions/checkout@v4
# Mirror the Dockerfile's system deps: ImageMagick + Ghostscript power the
# PDF→thumbnail path that Artifact.save() runs (exercised by the Talk
# fixtures); libpq-dev is needed to build psycopg2 from source.
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends imagemagick ghostscript libpq-dev
sudo cp imagemagick-policy.xml /etc/ImageMagick-6/policy.xml
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: pip
- name: Install Python dependencies
run: pip install -r requirements.txt
# 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
# signal stays fast and isolated — a slow or flaky browser run doesn't muddy
# "did the logic break?". Like `test`, this is report-only (it doesn't block
# the push or the deploy). Playwright + its browser live in requirements-dev.txt
# only, never in the production image.
e2e:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: makeability
POSTGRES_USER: admin
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U admin -d makeability"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DATABASE_HOST: localhost
DATABASE_PORT: 5432
DJANGO_ENV: DEBUG
steps:
- uses: actions/checkout@v4
# Same ImageMagick/Ghostscript deps as `test` — the Talk fixtures the e2e
# tests create run Artifact.save()'s PDF->thumbnail path.
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends imagemagick ghostscript libpq-dev
sudo cp imagemagick-policy.xml /etc/ImageMagick-6/policy.xml
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: pip
- name: Install Python dependencies (incl. Playwright)
run: pip install -r requirements-dev.txt
# Cache the downloaded browser keyed on the pinned Playwright version, so
# only the first run (or a version bump) pays the ~120 MB download.
- name: Cache Playwright browser
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ hashFiles('requirements-dev.txt') }}
- name: Install Chromium for Playwright
run: python -m playwright install --with-deps chromium
- name: Run end-to-end tests
run: python manage.py test website.tests.test_member_e2e --settings=makeabilitylab.settings_test --verbosity=2
# Accessibility sweep (Pa11y + Axe, WCAG 2.0 AA). CONTRIBUTING requires Pa11y
# on UI changes but nothing enforced it (#1278 item 6). This wires it in.
#
# Like `test` and `e2e`, it is REPORT-ONLY — it surfaces violations in the run
# Summary but never fails the build (so a pre-existing violation doesn't sit
# red next to every master deploy). Tighten to blocking later once the current
# findings are triaged.
#
# The local `.pa11yci.json` targets the docker-compose host with the
# maintainer's real DB snapshot; CI has no snapshot, so we build a fresh DB
# from models, seed deterministic demo content (seed_demo_projects +
# seed_demo_news), serve it with a native runserver, and scan the localhost
# URLs in `.pa11yci.ci.json`.
a11y:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: makeability
POSTGRES_USER: admin
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U admin -d makeability"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DATABASE_HOST: localhost
DATABASE_PORT: 5432
# DJANGO_ENV=DEBUG -> DEBUG=True, so the dev runserver serves media/static
# and renders real error pages while pa11y scans.
DJANGO_ENV: DEBUG
DJANGO_SETTINGS_MODULE: makeabilitylab.settings_test
steps:
- uses: actions/checkout@v4
# ImageMagick + Ghostscript power the PDF->thumbnail path the demo
# publications hit on save; libpq-dev builds psycopg2.
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends imagemagick ghostscript libpq-dev
sudo cp imagemagick-policy.xml /etc/ImageMagick-6/policy.xml
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: pip
- name: Install Python dependencies
run: pip install -r requirements.txt
# Build the website schema from models (migrations are gitignored;
# settings_test sets MIGRATION_MODULES={'website': None}, so --run-syncdb
# creates the tables directly) and seed deterministic demo content.
- name: Build schema and seed demo data
run: |
python manage.py migrate --run-syncdb
python manage.py seed_demo_projects
python manage.py seed_demo_news
- name: Start dev server
run: |
python manage.py runserver 0.0.0.0:8000 --noreload &
echo "Waiting for the server to come up…"
for i in $(seq 1 30); do
if curl -sf -o /dev/null http://localhost:8000/; then
echo "Server is up."; exit 0
fi
sleep 1
done
echo "Server did not start in time"; exit 1
- name: Install pa11y-ci
run: npm install -g pa11y-ci
# Report-only: `|| true` so violations never fail the job. Output is teed
# to the log and a trimmed tail posted to the run Summary.
- name: Run Pa11y accessibility sweep
run: |
pa11y-ci --config .pa11yci.ci.json 2>&1 | tee pa11y-output.txt || true
{
echo "## Accessibility (Pa11y + Axe, WCAG2AA) — report-only"
echo
echo '```'
tail -n 60 pa11y-output.txt
echo '```'
} >> "$GITHUB_STEP_SUMMARY"