-
-
Notifications
You must be signed in to change notification settings - Fork 7
306 lines (293 loc) · 8.47 KB
/
ci-cd.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
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
name: Test suite
on:
create: # is used for publishing to PyPI and TestPyPI
push: # only publishes pushes to the main branch to TestPyPI
branches: # any branch but not tag
- >-
**
tags-ignore:
- >-
**
pull_request:
schedule:
- cron: 1 0 * * * # Run daily at 0:01 UTC
jobs:
lint:
uses: ./.github/workflows/reusable-linters.yml
tests:
if: >- # https://twitter.com/webKnjaZ/status/1308803017001652225
github.event_name != 'create' ||
github.event.ref_type == 'tag'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
python-version:
- 3.9
- 2.7
- pypy-3.7
- 3.8
- 3.7
- 3.6
- 3.5
- pypy-2.7
- pypy-3.6
- 3.10.0-alpha - 3.10.0
os:
- ubuntu-20.04
- ubuntu-18.04
- ubuntu-16.04
- macOS-11.0
- macOS-latest
- windows-latest
- windows-2016
exclude:
# NOTE: macOS PyPy jobs are excluded because installing cryptography
# NOTE: needs openssl headers that aren't present at the moment.
# TODO: Remove the exclusions once this is addressed.
- os: macOS-11.0
python-version: pypy-2.7
- os: macOS-latest
python-version: pypy-2.7
- os: macOS-11.0
python-version: pypy-3.6
- os: macOS-latest
python-version: pypy-3.6
- os: macOS-11.0
python-version: pypy-3.7
- os: macOS-latest
python-version: pypy-3.7
continue-on-error: >-
${{
contains(matrix.python-version, 'alpha')
&& true
|| false
}}
timeout-minutes: 7 # NOTE: default is 360 (6h)
env:
PYTEST_ADDOPTS: >-
${{
(
matrix.python-version == 'pypy-2.7' &&
startsWith(matrix.os, 'ubuntu-')
) &&
'-p no:warnings' || ''
}}
PY_COLORS: 1
TOXENV: python
TOX_PARALLEL_NO_SPINNER: 1
steps:
- name: >-
Log platform.platform()
run: >-
python -m platform
- name: >-
Log platform.version()
run: |
import platform
print(platform.version())
shell: python
- name: >-
Log platform.uname()
run: |
import platform
print(platform.uname())
shell: python
- name: >-
Log platform.release()
run: |
import platform
print(platform.release())
shell: python
- name: Windows system info
run: systeminfo
if: >-
startsWith(matrix.os, 'windows-')
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Pip cache
uses: actions/cache@v2
with:
path: >-
${{
runner.os == 'Linux' &&
'~/.cache/pip'
|| ''
}}${{
runner.os == 'macOS' &&
'~/Library/Caches/pip'
|| ''
}}${{
runner.os == 'Windows' &&
'~\AppData\Local\pip\Cache'
|| ''
}}
key: >-
${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}-${{
hashFiles('setup.py') }}-${{ hashFiles('tox.ini') }}-${{
hashFiles('pyproject.toml') }}-${{
hashFiles('.pre-commit-config.yaml') }}-${{
hashFiles('pytest.ini') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install tox
run: >-
python -m
pip install
--upgrade
tox
# macOS-latest + CPython completes in 4s-1m26s
# macOS-11.0 + CPython completes in 3s-18s
# ubuntu-16.04 + CPython completes in 2s-8s
# ubuntu-16.04 + PyPy completes in 5s-16s
# ubuntu-18.04 + CPython completes in 3s-6s
# ubuntu-18.04 + PyPy completes in 4s-14s
# ubuntu-20.04 + CPython completes in 3s-8s
# ubuntu-20.04 + PyPy completes in 10s-15s
# windows-latest + CPython completes in 5s-25s
# windows-latest + PyPy completes in 22s-50s
# windows-2016 + CPython completes in 7s-24s
# windows-2016 + PyPy completes in 22s-41s
timeout-minutes: 2
- name: 'Initialize tox envs: ${{ matrix.env.TOXENV }}'
run: >-
python -m
tox
--parallel auto
--parallel-live
-vv
--skip-missing-interpreters false
--notest
# macOS-latest + CPython completes in 11s-1m40s
# macOS-11.0 + CPython completes in 14s-18s
# ubuntu-16.04 + CPython completes in 9s-16s
# ubuntu-16.04 + PyPy completes in 14s-21s
# ubuntu-18.04 + CPython completes in 9s-15s
# ubuntu-18.04 + PyPy completes in 16s-24s
# ubuntu-20.04 + CPython completes in 10s-12s
# ubuntu-20.04 + PyPy completes in 16s-24s
# windows-latest + CPython completes in 17s-31s
# windows-latest + PyPy completes in 37s-44s
# windows-2016 + CPython completes in 18s-26s
# windows-2016 + PyPy completes in 37s-49s
timeout-minutes: 2
- name: Test with tox
run: >-
python -m
tox
--parallel auto
--parallel-live
-vv
# macOS-latest + CPython completes in 9-2m12s
# macOS-11.0 + CPython completes in 8s-1m13s
# ubuntu-16.04 + CPython completes in 8s-13s
# ubuntu-16.04 + PyPy completes in 13s-16s
# ubuntu-18.04 + CPython completes in 8s-13s
# ubuntu-18.04 + PyPy completes in 13s-15s
# ubuntu-20.04 + CPython completes in 8s-14s
# ubuntu-20.04 + PyPy completes in 13s-16s
# windows-latest + CPython completes in 7s-9s
# windows-latest + PyPy completes in 13s-24s
# windows-2016 + CPython completes in 7s-11s
# windows-2016 + PyPy completes in 13s-20s
timeout-minutes: 3
- name: Dump test logs on failure
if: failure()
shell: bash
run: |
for log in magicbus/test/*.log
do
echo Dumping "'${log}'"...
cat "${log}"
done
check: # This job does nothing and is only used for the branch protection
if: always()
needs:
- lint
- tests
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
publish:
name: Validate metadata and optionally publish 🐍📦 to PyPI
needs:
- check
runs-on: ${{ matrix.os }}
strategy:
# NOTE: Even though it's one job, it's easier to keep the params in one
# NOTE: place using a matrix:
matrix:
python-version:
- 3.9
os:
- ubuntu-latest
env:
PY_COLORS: 1
TOXENV: build-dists,metadata-validation
TOX_PARALLEL_NO_SPINNER: 1
steps:
- uses: actions/checkout@master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Pip cache
uses: actions/cache@v2
with:
path: >-
${{
runner.os == 'Linux' &&
'~/.cache/pip'
|| ''
}}${{
runner.os == 'macOS' &&
'~/Library/Caches/pip'
|| ''
}}${{
runner.os == 'Windows' &&
'~\AppData\Local\pip\Cache'
|| ''
}}
key: >-
${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}-${{
hashFiles('setup.py') }}-${{ hashFiles('tox.ini') }}-${{
hashFiles('pyproject.toml') }}-${{
hashFiles('.pre-commit-config.yaml') }}-${{
hashFiles('pytest.ini') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install tox
run: >-
python -m
pip install
--upgrade
tox
- name: 'Initialize tox envs: ${{ matrix.env.TOXENV }}'
run: >-
python -m
tox
--parallel auto
--parallel-live
-vv
--skip-missing-interpreters false
--notest
- name: Build dists with tox
run: >-
python -m
tox
--parallel auto
--parallel-live
-vv
- name: Publish to pypi.org
if: >- # "create" workflows run separately from "push" & "pull_request"
github.event_name == 'create' &&
github.event.ref_type == 'tag'
uses: pypa/gh-action-pypi-publish@release/v1