-
Notifications
You must be signed in to change notification settings - Fork 140
160 lines (132 loc) · 4.21 KB
/
ci.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
name: CI
on:
push:
branches: [ trunk ]
pull_request:
branches: [ trunk ]
jobs:
lint:
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key:
${{ runner.os }}-pip-lint-${{ hashFiles('pyproject.toml', 'setup.py', 'tox.ini') }}
restore-keys: |
${{ runner.os }}-pip-lint-
${{ runner.os }}-pip-
- run: python -m pip install 'tox<4'
- run: tox -q -p all -e flake8,towncrier,twine,check-manifest,mypy
env:
TOX_PARALLEL_NO_SPINNER: 1
docs:
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key:
${{ runner.os }}-pip-docs-${{ hashFiles('pyproject.toml', 'setup.py', 'tox.ini') }}
restore-keys: |
${{ runner.os }}-pip-docs-
${{ runner.os }}-pip-
- run: python -m pip install 'tox<4'
- run: tox -q -e docs
test:
name: "Test ${{ matrix.python-version }} with ${{ matrix.twisted-version }} Twisted"
runs-on: ubuntu-20.04
timeout-minutes: 10
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
# Python versions common to lowest and latest
python-version: ["3.8", "3.9", "3.10", "pypy-3.9"]
twisted-version: ["lowest", "latest"]
experimental: [false]
include:
# Pythons too new for lowest
- python-version: "3.11"
twisted-version: "latest"
experimental: false
- python-version: "3.12"
twisted-version: "latest"
experimental: false
- python-version: "pypy-3.10"
twisted-version: "latest"
experimental: false
# Experimental trunk build
- python-version: "3.9"
twisted-version: "trunk"
experimental: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key:
${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml', 'setup.py', 'tox.ini') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
- name: Translate Python version to Tox factor
id: pyfactor
shell: python
run: |
table = {
"3.8": "py38",
"3.9": "py39",
"3.10": "py310",
"3.11": "py311",
"3.12": "py312",
"pypy-3.8": "pypy3",
"pypy-3.9": "pypy3",
"pypy-3.10": "pypy3",
}
factor = table["${{ matrix.python-version }}"]
print("::set-output name=value::" + factor)
- run: python -m pip install tox coveralls
- run: tox -e ${{ steps.pyfactor.outputs.value }}-twisted_${{ matrix.twisted-version }}
- run: coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: 4nctuKHTnVtbdmty2FgdO3iiWm1nb7xc4
COVERALLS_FLAG_NAME: python_${{ matrix.python-version }}-twisted_${{ matrix.twisted-version }}
COVERALLS_PARALLEL: true
# Helper so that on GitHub repo settings we can configure to single job.
# Then required jobs can be updated directly form the code,
# without having to go the GitHub repo setting -> Protected branch
# and all the clicking.
treq-required:
runs-on: ubuntu-latest
timeout-minutes: 10
if: ${{ !cancelled() }}
# Add here the jobs that should block the merge of a PR.
needs:
- lint
- docs
- test
steps:
- name: Require all successes
shell: python3 {0}
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)