-
Notifications
You must be signed in to change notification settings - Fork 58
295 lines (264 loc) · 8.82 KB
/
tests.yaml
File metadata and controls
295 lines (264 loc) · 8.82 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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
name: Tests
on:
push:
branches:
- master
- '*'
tags:
- '**'
pull_request:
branches:
- master
jobs:
tests:
name: "unit / ${{ matrix.name }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- {name: '3.14', python: '3.14', os: ubuntu-latest, tox: py314}
- {name: '3.13', python: '3.13', os: ubuntu-latest, tox: py313}
- {name: '3.12', python: '3.12', os: ubuntu-latest, tox: py312}
- {name: '3.11', python: '3.11', os: ubuntu-latest, tox: py311}
- {name: '3.10', python: '3.10', os: ubuntu-latest, tox: py310}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: pip
- name: update pip
run: |
pip install -U wheel
pip install -U setuptools
python -m pip install -U pip
- run: pip install tox
- name: run tests
run: tox -e ${{ matrix.tox }} -- -m "not e2e and not django"
django:
name: "django / ${{ matrix.django }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- {django: '4.2', tox: django42}
- {django: '5.2', tox: django52}
- {django: '6.0', tox: django60}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
- name: update pip
run: |
pip install -U wheel
pip install -U setuptools
python -m pip install -U pip
- run: pip install tox
- name: run django tests
run: tox -e ${{ matrix.tox }}
docs:
name: "docs"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
- name: install dependencies
run: |
pip install -e ".[html]"
pip install sphinx -r docs/requirements.txt
- name: build docs
run: sphinx-build -W -b html docs docs/_build/html
- name: run doctests
run: sphinx-build -b doctest docs docs/_build/doctest
typecheck:
name: "typecheck"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
- name: update pip
run: |
pip install -U wheel
pip install -U setuptools
python -m pip install -U pip
- run: pip install tox
- name: run mypy
run: tox -e typecheck
e2e:
name: "e2e / ${{ matrix.name }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- {name: '3.14', python: '3.14', os: ubuntu-latest, tox: py314}
services:
mailpit:
image: axllent/mailpit
ports:
- 1025:1025
- 8025:8025
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: pip
- name: update pip
run: |
pip install -U wheel
pip install -U setuptools
python -m pip install -U pip
- run: pip install tox
- name: run e2e tests
env:
SMTP_TEST_SUBJECT_SUFFIX: "github-actions sha:${{ github.sha }} run_id:${{ github.run_id }}"
SMTP_TEST_MAIL_FROM: python-emails-tests@lavr.me
SMTP_TEST_MAIL_TO: python-emails-tests@lavr.me
SMTP_TEST_SETS: LOCAL
SMTP_TEST_LOCAL_HOST: 127.0.0.1
SMTP_TEST_LOCAL_PORT: 1025
SMTP_TEST_LOCAL_WITHOUT_TLS: true
run: tox -e ${{ matrix.tox }} -- -m e2e
publish_rtd:
name: "publish read the docs"
needs:
- tests
- django
- docs
- typecheck
- e2e
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-latest
env:
RTD_API_TOKEN: ${{ secrets.RTD_API_TOKEN }}
RTD_PROJECT_SLUG: python-emails
steps:
- name: Trigger Read the Docs build
run: |
set -euo pipefail
: "${RTD_API_TOKEN:?RTD_API_TOKEN secret is required}"
api_base="https://app.readthedocs.org/api/v3/projects/${RTD_PROJECT_SLUG}"
auth_header="Authorization: Token ${RTD_API_TOKEN}"
get_version_details() {
local version_slug="$1"
local response_file="${2:-version.json}"
curl \
--silent \
--show-error \
--output "${response_file}" \
--write-out '%{http_code}' \
--header "${auth_header}" \
"${api_base}/versions/${version_slug}/"
}
wait_for_version_slug() {
local version_name="$1"
for attempt in {1..12}; do
local status_code
local version_slug
status_code="$(
curl \
--silent \
--show-error \
--output versions.json \
--write-out '%{http_code}' \
--get \
--header "${auth_header}" \
--data-urlencode "type=tag" \
--data-urlencode "verbose_name=${version_name}" \
"${api_base}/versions/"
)"
if [[ "${status_code}" == "200" ]]; then
version_slug="$(
jq \
--raw-output \
--arg version_name "${version_name}" \
'.results[] | select(.verbose_name == $version_name) | .slug' \
versions.json | head -n 1
)"
if [[ -n "${version_slug}" && "${version_slug}" != "null" ]]; then
printf '%s\n' "${version_slug}"
return 0
fi
fi
sleep 5
done
echo "Read the Docs version '${version_name}' was not found after sync."
if [[ -f versions.json ]]; then
cat versions.json
fi
return 1
}
trigger_build() {
local version_slug="$1"
echo "Triggering Read the Docs build for version slug '${version_slug}'."
curl \
--fail-with-body \
--silent \
--show-error \
--request POST \
--header "${auth_header}" \
"${api_base}/versions/${version_slug}/builds/"
}
if [[ "${GITHUB_REF_TYPE}" == "branch" ]]; then
trigger_build latest
exit 0
fi
version_name="${GITHUB_REF_NAME}"
curl \
--fail-with-body \
--silent \
--show-error \
--request POST \
--header "${auth_header}" \
"${api_base}/sync-versions/"
version_slug="$(wait_for_version_slug "${version_name}")"
status_code="$(get_version_details "${version_slug}")"
if [[ "${status_code}" != "200" ]]; then
echo "Failed to fetch Read the Docs version details for '${version_slug}'."
cat version.json
exit 1
fi
active="$(jq -r '.active' version.json)"
hidden="$(jq -r '.hidden' version.json)"
echo "Read the Docs version '${version_slug}' status: active=${active}, hidden=${hidden}."
if [[ "${active}" == "true" && "${hidden}" == "false" ]]; then
trigger_build "${version_slug}"
exit 0
fi
echo "Activating and unhiding Read the Docs version '${version_slug}'."
curl \
--fail-with-body \
--silent \
--show-error \
--request PATCH \
--header "${auth_header}" \
--header "Content-Type: application/json" \
--data '{"active": true, "hidden": false}' \
"${api_base}/versions/${version_slug}/"
status_code="$(get_version_details "${version_slug}")"
if [[ "${status_code}" != "200" ]]; then
echo "Failed to re-fetch Read the Docs version details for '${version_slug}' after PATCH."
cat version.json
exit 1
fi
active="$(jq -r '.active' version.json)"
hidden="$(jq -r '.hidden' version.json)"
echo "Read the Docs version '${version_slug}' updated status: active=${active}, hidden=${hidden}."
if [[ "${active}" == "true" && "${hidden}" == "false" ]]; then
trigger_build "${version_slug}"
exit 0
fi
echo "Read the Docs version '${version_slug}' is still not buildable after PATCH."
cat version.json
exit 1