-
Notifications
You must be signed in to change notification settings - Fork 0
201 lines (174 loc) · 5.59 KB
/
ci.yml
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
---
name: CI
on: # yamllint disable-line rule:truthy
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: '${{ github.head_ref || github.ref }}-${{ github.workflow }}'
cancel-in-progress: true
env:
POETRY_VERSION: '1.8.4' # keep in sync with pyproject.toml, Dockerfile
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
cache: poetry
- name: Install dependencies
run: make install-dev
- name: Lint Python
run: make lint-py
- name: Lint HTML
run: make lint-html
lint-front-end:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Install npm dependencies
run: npm ci --no-audit
- name: CSS linting
run: npm run lint:css
- name: JS linting
run: npm run lint:js
- name: Prettier
run: npm run lint:format
compile_static:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- id: node-cache
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/.nvmrc') }}-${{ hashFiles('**/package-lock.json') }}
- if: steps.node-cache.outputs.cache-hit != 'true'
run: npm ci --no-audit
- run: npm run build:prod
- uses: actions/upload-artifact@v4
with:
name: static
path: cms/static_compiled/
test-python:
runs-on: ubuntu-latest
needs:
- lint
- lint-front-end
- compile_static
env:
DJANGO_SETTINGS_MODULE: cms.settings.test
DATABASE_URL: postgres://postgres:postgres@localhost/postgres # pragma: allowlist secret
ENABLE_DJANGO_DEFENDER: 'false'
POSTGRES_HOST_AUTH_METHOD: trust
SECRET_KEY: fake_secret_key_to_run_tests # pragma: allowlist secret
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres # pragma: allowlist secret
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
cache: poetry
- name: Install dependencies
run: make install-dev
- uses: actions/download-artifact@v4
with:
name: static
path: cms/static_compiled/
- name: Fetch Design System templates
run: make load-design-system-templates
- name: collectstatic
run: poetry run ./manage.py collectstatic --verbosity 0 --noinput --clear
- name: System checks
run: poetry run ./manage.py check
- name: Check for missing migrations
run: poetry run ./manage.py makemigrations --check --noinput
- name: Create cache table
run: poetry run ./manage.py createcachetable
- name: Run migrations to work around Django bug (#35967)
run: poetry run ./manage.py migrate --noinput
- name: Test
run: make test
- name: Add coverage data to GitHub Action summary
run: |
poetry run coverage html --skip-covered --skip-empty
echo "## Coverage summary" >> "$GITHUB_STEP_SUMMARY"
poetry run coverage report --format=markdown >> "$GITHUB_STEP_SUMMARY"
- name: Upload coverage HTML report
uses: actions/upload-artifact@v4
with:
name: html-report
path: htmlcov
- name: Lint Migrations
run: DJANGO_SETTINGS_MODULE=cms.settings.dev make lint-migrations
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Docker Image
run: docker build --target web -t ons .
functional-tests:
runs-on: ubuntu-latest
strategy:
matrix:
browser:
- chromium
needs:
- lint
- lint-front-end
- compile_static
env:
DJANGO_SETTINGS_MODULE: cms.settings.functional_test
SECRET_KEY: fake_secret_key_to_run_tests # pragma: allowlist secret
PLAYWRIGHT_BROWSER: ${{ matrix.browser }}
PLAYWRIGHT_TRACES_DIR: playwright_traces
PLAYWRIGHT_TRACE: 'true'
steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
cache: poetry
- name: Install dependencies
run: make install-dev
- name: Playwright Install
run: poetry run python -m playwright install --with-deps ${{ matrix.browser }}
- uses: actions/download-artifact@v4
with:
name: static
path: cms/static_compiled/
- name: Run Functional Tests
run: make functional-tests
- name: Upload Failure Traces
uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-traces-${{ matrix.browser }}
path: playwright_traces/