-
Notifications
You must be signed in to change notification settings - Fork 66
144 lines (123 loc) · 5.03 KB
/
Copy pathtest.yml
File metadata and controls
144 lines (123 loc) · 5.03 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
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