-
Notifications
You must be signed in to change notification settings - Fork 1.1k
398 lines (350 loc) · 13.4 KB
/
test.yaml
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# Try to get a short workflow name and a job name that start with Python
# version to make it easier to check the status inside GitHub UI.
#
# When using external actions check that the extenral repos are permitted via
# the GitHub configuration at https://github.com/twisted/twisted/settings/actions
#
name: CI
on:
push:
branches: [ trunk ]
tags:
- twisted-*
pull_request:
branches: [ trunk ]
# Only have a run a single parallel for each branch.
# Runs for trunk are queues.
# Older runs for non-trunk branches are cancelled and the jobs are executed
# only for the latest push to the branch.
concurrency:
group: ${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/trunk' }}
defaults:
run:
shell: bash
env:
# Set to 'yes' to open a tunnel to GitHub's VMs through tmate on failures.
# Also increase timeout-minutes for the relevant OS when debugging remotely
# and you need a longer session.
TMATE_DEBUG: 'no'
jobs:
testing:
name: ${{ matrix.python-version }}-${{ matrix.job-name || 'lnx-default-tests' }}
# We have Ubuntu as the base for running agains multiple Python versions.
runs-on: "${{ matrix.runs-on || 'ubuntu-20.04'}}"
env:
# By default we run all tests with all deps with coverage.
TOXENV: "${{ matrix.tox-env || 'alldeps-withcov-posix' }}"
# As of April 2021 GHA VM have 2 CPUs - Azure Standard_DS2_v2
# Trial distributed jobs enabled to speed up the CI jobs.
# On Windows, we don't yet enable distributed tests as is not yet
# supported.
TRIAL_ARGS: "${{ matrix.trial-args || '-j 4' }}"
strategy:
fail-fast: false
# The matrix is designed to run by default various Python versions with
# the default OS and tests suite.
# Default values should be declared via empty string, to allow them
# to be omitted when extending the matrix.
matrix:
# Run on latest minor release of each major Python version.
python-version: ['3.8', '3.9', '3.10']
# Just use the default OS.
runs-on: ['']
# Human readable short description for this job.
job-name: ['']
# This is the main tox target.
# It is later extended with more jobs that should run in a specific
# OS + Python version configuration.
tox-env: ['']
# We just go with the default arguments.
trial-args: ['']
# By default, tests are executed without disabling IPv6.
noipv6: ['']
# By default, tests are executed without extra platform dependencies.
platform-deps: ['']
# By default, tests are executed directly via tox.
tox-wrapper: ['']
# Tests are executed with the default target which is the full test suite.
trial-target: ['']
# By default the coverate is not skipped.
skip-coverage: ['']
# Here the matrix is extended with variations of the default
# value.
include:
# Windows, minimum Python version with select reactor.
- python-version: '3.7'
runs-on: 'windows-2022'
tox-env: 'alldeps-withcov-windows'
job-name: 'win-default-tests-select'
# Distributed trial is not yet suported on Windows so we overwrite
# the default trial-args to remove concurrent runs and to
# select a reactor.
trial-args: '--reactor=select'
# Windows, latest Python version with iocp reactor.
- python-version: '3.10'
runs-on: 'windows-2022'
tox-env: 'alldeps-withcov-windows'
job-name: 'win-default-tests-iocp'
# Distributed trial is not yet suported on Windows.
trial-args: '--reactor=iocp'
# `noipv6` is created to make sure all is OK on an OS which doesn't
# have IPv6 available.
# Any supported Python version is OK for this job.
- python-version: '3.7'
noipv6: -noipv6
job-name: 'default-tests-noipv6'
# `nodeps` is created to make sure we don't have import errors in the
# runtime and production code.
# The minimum supported Python version should be used to maximize
# coverage of code that otherwise depends on backports.
# Distributed test run is disabled here so that we also have
# end to end functional test usage for non-distributed trial runs.
# When updating the minimum Python version here, also update the
# `python_requires` from `setup.cfg`.
- python-version: '3.7.1'
tox-env: nodeps-withcov-posix
job-name: 'nodeps-test'
# On PYPY coverage is very slow (5min vs 30min) as there is no C
# extension.
# There is very little PYPY specific code so there is not much to
# gain from reporting coverage.
- python-version: pypy-3.7
tox-env: alldeps-nocov-posix
job-name: 'pypy-no-coverage'
skip-coverage: yes
# We still run some tests with coverage,
# as there are test with specific code branches for pypy.
- python-version: pypy-3.7
trial-target: twisted.test.test_compat twisted.test.test_defer twisted.internet.test.test_socket twisted.trial.test.test_tests
job-name: 'pypy-coverage'
# We run selected test for GTK reactor inside X virtual framebuffer.
- python-version: '3.7'
tox-env: alldeps-gtk-withcov-posix
trial-target: twisted.internet.test
platform-deps: 'gtk_platform'
tox-wrapper: 'xvfb-run -a'
job-name: 'gtk-tests'
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: pip cache
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
${{ runner.os }}-pip-${{ hashFiles('pyproject.toml', 'setup.py',
'setup.cfg', 'tox.ini') }}
restore-keys: |
${{ runner.os }}-pip-
# Make sure the matrix is defined in such a way that this is triggered
# only on Linux.
- name: Disable IPv6
if: matrix.noipv6
run: |
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1
ip a
- uses: twisted/python-info-action@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip tox coverage
# Make sure the matrix is defined in such a way that this is triggered
# only on Linux.
- name: Install GTK system deps
if: matrix.platform-deps == 'gtk_platform'
run: |
# *-dev dependencies are for pygobject
# https://gitlab.gnome.org/GNOME/pygobject/-/blob/3.42.0/setup.py#L129-L134
sudo apt-get update
sudo apt-get install -y \
libgirepository1.0-dev \
libglib2.0-dev \
libcairo2-dev \
libffi-dev \
gir1.2-gtk-3.0 \
xvfb
- name: Test
run: |
${{ matrix.tox-wrapper }} tox ${{ matrix.trial-target }}
# If one of the above steps fails, fire up tmate for remote debugging.
- name: Tmate debug on failure
if: ${{ !cancelled() && env.TMATE_DEBUG == 'yes' }}
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
- name: Prepare coverage
if: ${{ !cancelled() && !matrix.skip-coverage }}
run: |
# sub-process coverage are generated in separate files so we combine them
# to get an unified coverage for the local run.
# The XML is generate to be used with 3rd party tools like diff-cover.
python -m coverage combine
python -m coverage xml -o coverage.xml -i
python -m coverage report --skip-covered
- uses: codecov/codecov-action@v3
if: ${{ !cancelled() && !matrix['skip-coverage'] }}
with:
files: coverage.xml
name: ${{ matrix.python-version }}-${{matrix.job-name || 'lnx-default-tests' }}
fail_ci_if_error: true
static-checks:
runs-on: ubuntu-20.04
env:
TOX_PARALLEL_NO_SPINNER: 1
steps:
- uses: actions/checkout@v2
with:
# Need history on all branches for newsfragment to work.
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip tox
- name: Run the checks
run: |
python --version
tox --parallel -e lint,mypy
- name: Revert merge commit for a release branch
if: github.event_name == 'pull_request' && startsWith(github.head_ref, 'release-')
env:
BRANCH_SHA: ${{ github.event.after }}
BRANCH_NAME: ${{ github.head_ref }}
run: |
git checkout -b $BRANCH_NAME
git reset --hard $BRANCH_SHA
- name: Newsfragment
run: |
tox -q -e newsfragment
# This is called only on code changes.
# If you forgot to define the right PR title you should re-run the job.
- name: Check PR title format
if: github.event_name == 'pull_request'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_BODY: ${{ github.event.pull_request.body }}
run: python .github/scripts/check-pr-text.py
# Used to validate the narrative and API docs.
# Checks for invalid syntax or broken links.
# This is only the validation and help highlight docs errors.
# The actual docs are built and published via Read The Docs.
apidocs:
name: API docs build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip tox
- name: Build apidocs
run: |
tox -e apidocs
narrativedocs:
name: Narrative docs build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip tox
- name: Run the checks
run: |
tox -e narrativedocs
# Used for various release automation.
# This is also executed for each PR to exercise the release as much
# as possible and reduce the possibility of finding bugs in the release
# process late in the release cycle,
# The files are published only when a tag is created.
release-publish:
name: Check release and publish on twisted-* tag
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Test
run: |
python -m pip install --upgrade pip tox pep517
rm -rf dist/*
tox -e release-prepare
- uses: twisted/python-info-action@v1
- name: Files to be pushed to PyPi
run: ls -R dist/
- name: Check matched tag version and branch version - on tag
if: startsWith(github.ref, 'refs/tags/twisted-')
run: python admin/check_tag_version_match.py "${{ github.ref }}"
- name: Publish to PyPI - on tag
if: startsWith(github.ref, 'refs/tags/twisted-')
uses: pypa/gh-action-pypi-publish@v1
with:
password: ${{ secrets.PYPI_UPLOAD_TOKEN }}
- name: Update stable branch - on stable tag
if: startsWith(github.ref, 'refs/tags/twisted-')
env:
STABLE_BRANCH: stable
STABLE_REF_RE: '.*twisted-[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'
run: |
if [[ $GITUB_REF =~ $STABLE_REF_RE ]]; then
echo "Pushing current tag to stable branch..."
git config --global user.name '$GITHUB_ACTOR'
git config --global user.email '$GITHUB_ACTOR@users.noreply.github.com'
echo '::group::git fetch'
git fetch origin
echo '::endgroup::'
git log -1
git checkout -b $STABLE_BRANCH origin/$STABLE_BRANCH
git reset --hard $GITHUB_SHA
git push --force
echo "Done"
else
echo "Branch not updated for not stable releases: $GITUB_REF"
fi
# We have this job so that the PR can be blocked on a single job.
# In this way, each time a job is modified,
# we don't have to go to GitHub UI and reconfigure branch protection.
# See GitHub support answer for this hack.
# https://gist.github.com/altendky/2e3483a1f7e1ba21cc97de75db9b7d1c
all-successful:
# Is very important to force running this always, as otherwise it will be
# skipped by default.
if: always()
runs-on: ubuntu-latest
# Here should be the list of all the other jobs defined in this file.
needs:
- testing
- narrativedocs
- apidocs
- static-checks
- release-publish
steps:
- name: Require all successes
shell: python
env:
RESULTS: ${{ toJSON(needs.*.result) }}
run: |
import json
import os
import sys
results = json.loads(os.environ["RESULTS"])
sys.exit(0 if all(result == "success" for result in results) else 1)