-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
303 lines (281 loc) · 10.6 KB
/
test.yml
File metadata and controls
303 lines (281 loc) · 10.6 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
296
297
298
299
300
301
302
303
name: Tests
on:
workflow_dispatch:
push:
branches: [main, master, 'release*']
tags: ['*']
pull_request:
paths-ignore:
- 'docs/**'
- 'mypyc/doc/**'
- '**/*.rst'
- '**/*.md'
- .gitignore
- CREDITS
- LICENSE
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
main:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Make sure to run mypyc compiled unit tests for both
# the oldest and newest supported Python versions
- name: Test suite with py310-ubuntu, mypyc-compiled
python: '3.10'
os: ubuntu-24.04-arm
toxenv: py
tox_extra_args: "-n 4"
test_mypyc: true
- name: Test suite with py311-ubuntu
python: '3.11'
os: ubuntu-24.04-arm
toxenv: py
tox_extra_args: "-n 4"
- name: Test suite with py312-ubuntu
python: '3.12'
os: ubuntu-24.04-arm
toxenv: py
tox_extra_args: "-n 4"
- name: Test suite with py313-ubuntu, mypyc-compiled
python: '3.13'
os: ubuntu-24.04-arm
toxenv: py
tox_extra_args: "-n 4"
test_mypyc: true
- name: Test suite with py314-ubuntu, mypyc-compiled
python: '3.14'
os: ubuntu-24.04-arm
toxenv: py
tox_extra_args: "-n 4"
test_mypyc: true
- name: Test suite with py314t-ubuntu, mypyc-compiled
python: '3.14t'
os: ubuntu-24.04-arm
toxenv: py
tox_extra_args: "-n 4"
test_mypyc: true
- name: Test suite with py314-windows-64
python: '3.14'
os: windows-latest
toxenv: py
tox_extra_args: "-n 4"
# - name: Test suite with py315-dev-ubuntu
# python: '3.15-dev'
# os: ubuntu-24.04-arm
# toxenv: py
# tox_extra_args: "-n 4"
# # allow_failure: true
# test_mypyc: true
- name: mypyc runtime tests with py313-macos
python: '3.13'
os: macos-latest
toxenv: py
tox_extra_args: "-n 3 mypyc/test/test_run.py mypyc/test/test_external.py"
- name: mypyc runtime tests with py310-ubuntu
python: '3.10'
os: ubuntu-latest
toxenv: py
tox_extra_args: "-n 3 mypyc/test/test_run.py mypyc/test/test_external.py"
# This is broken. See
# - https://github.com/python/mypy/issues/17819
# - https://github.com/python/mypy/pull/17822
# - name: mypyc runtime tests with py310-debug-build-ubuntu
# python: '3.10'
# os: ubuntu-latest
# toxenv: py
# tox_extra_args: "-n 4 mypyc/test/test_run.py mypyc/test/test_external.py"
# debug_build: true
- name: Parallel tests with py314-ubuntu, interpreted
python: '3.14'
os: ubuntu-24.04-arm
toxenv: py
tox_extra_args: "-n 4 --mypy-num-workers=4 mypy/test/testcheck.py"
dev_ast_serialize: true
- name: Parallel tests with py314-ubuntu, mypyc-compiled
python: '3.14'
os: ubuntu-24.04-arm
toxenv: py
tox_extra_args: "-n 4 --mypy-num-workers=4 mypy/test/testcheck.py"
test_mypyc: true
dev_ast_serialize: true
# Skip Windows tests until we publish ast_serialize wheels on PyPI.
# - name: Parallel tests with py314-windows-64, interpreted
# python: '3.14'
# os: windows-latest
# toxenv: py
# tox_extra_args: "-n 2 --mypy-num-workers=2 mypy/test/testcheck.py -k 'incremental or modules or classes'"
- name: Type check our own code (py310-ubuntu)
python: '3.10'
os: ubuntu-latest
toxenv: type
- name: Type check our own code (py310-windows-64)
python: '3.10'
os: windows-latest
toxenv: type
# We also run these checks with pre-commit in CI,
# but it's useful to run them with tox too,
# to ensure the tox env works as expected
- name: Formatting and code style with Black + ruff
python: '3.10'
os: ubuntu-latest
toxenv: lint
name: ${{ matrix.name }}
timeout-minutes: 60
env:
TOX_SKIP_MISSING_INTERPRETERS: False
VIRTUALENV_SYSTEM_SITE_PACKAGES: ${{ matrix.dev_ast_serialize && 1 || 0 }}
# Rich (pip) -- Disable color for windows + pytest
FORCE_COLOR: ${{ !(startsWith(matrix.os, 'windows-') && startsWith(matrix.toxenv, 'py')) && 1 || 0 }}
# Tox
PY_COLORS: 1
# Python -- Disable argparse help colors (3.14+)
PYTHON_COLORS: 0
# Mypy (see https://github.com/python/mypy/issues/7771)
TERM: xterm-color
MYPY_FORCE_COLOR: 1
MYPY_FORCE_TERMINAL_WIDTH: 200
# Pytest
PYTEST_ADDOPTS: --color=yes
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Latest dev build
if: ${{ endsWith(matrix.python, '-dev') }}
run: |
git clone --depth 1 https://github.com/python/cpython.git /tmp/cpython --branch $( echo ${{ matrix.python }} | sed 's/-dev//' )
cd /tmp/cpython
echo git rev-parse HEAD; git rev-parse HEAD
git show --no-patch
sudo apt-get update -q
sudo apt-get install -q -y --no-install-recommends \
build-essential gdb lcov libbz2-dev libffi-dev libgdbm-dev liblzma-dev libncurses5-dev \
libreadline6-dev libsqlite3-dev libssl-dev lzma lzma-dev tk-dev uuid-dev zlib1g-dev
./configure --prefix=/opt/pythondev
make -j$(nproc)
sudo make install
sudo ln -s /opt/pythondev/bin/python3 /opt/pythondev/bin/python
sudo ln -s /opt/pythondev/bin/pip3 /opt/pythondev/bin/pip
echo "/opt/pythondev/bin" >> $GITHUB_PATH
- name: Debug build
if: ${{ matrix.debug_build }}
run: |
git clone --depth 1 https://github.com/python/cpython.git /tmp/cpython --branch ${{ matrix.python }}
cd /tmp/cpython
echo git rev-parse HEAD; git rev-parse HEAD
git show --no-patch
sudo apt-get update -q
sudo apt-get install -q -y --no-install-recommends \
build-essential gdb lcov libbz2-dev libffi-dev libgdbm-dev liblzma-dev libncurses5-dev \
libreadline6-dev libsqlite3-dev libssl-dev lzma lzma-dev tk-dev uuid-dev zlib1g-dev
./configure CFLAGS="-DPy_DEBUG -DPy_TRACE_REFS -DPYMALLOC_DEBUG" --with-pydebug -with-trace-refs --prefix=/opt/pythondev
make -j$(nproc)
sudo make install
sudo ln -s /opt/pythondev/bin/python3 /opt/pythondev/bin/python
sudo ln -s /opt/pythondev/bin/pip3 /opt/pythondev/bin/pip
echo "/opt/pythondev/bin" >> $GITHUB_PATH
- uses: actions/setup-python@v5
if: ${{ !(matrix.debug_build || endsWith(matrix.python, '-dev')) }}
with:
python-version: ${{ matrix.python }}
- name: Install tox
run: |
echo PATH; echo $PATH
echo which python; which python
echo which pip; which pip
echo python version; python -c 'import sys; print(sys.version)'
echo debug build; python -c 'import sysconfig; print(bool(sysconfig.get_config_var("Py_DEBUG")))'
echo os.cpu_count; python -c 'import os; print(os.cpu_count())'
echo os.sched_getaffinity; python -c 'import os; print(len(getattr(os, "sched_getaffinity", lambda *args: [])(0)))'
pip install setuptools==75.1.0 tox==4.26.0
- name: Compiled with mypyc
if: ${{ matrix.test_mypyc }}
run: |
pip install -r test-requirements.txt
CC=clang MYPYC_OPT_LEVEL=0 MYPY_USE_MYPYC=1 pip install -e .
# To speed-up process until ast_serialize is on PyPI.
- name: Checkout pinned ast_serialize
if: ${{ matrix.dev_ast_serialize }}
uses: actions/checkout@v4
with:
persist-credentials: false
repository: mypyc/ast_serialize
ref: da5a16cf268dbec63ed6b2e6b715470576e2d1a6
path: ast_serialize
- if: ${{ matrix.dev_ast_serialize }}
uses: PyO3/maturin-action@v1
with:
target: aarch64
args: --release --out dist
working-directory: ast_serialize
- if: ${{ matrix.dev_ast_serialize }}
run: |
pip install ast_serialize/dist/ast_serialize-0.1.0-cp39-abi3-manylinux_2_34_aarch64.whl
echo 'no way' > test_ast_serialize.py
python3 -c 'import ast_serialize; print(ast_serialize.parse("test_ast_serialize.py")[1])'
rm test_ast_serialize.py
- name: Setup tox environment
run: |
tox run -e ${{ matrix.toxenv }} --notest
- name: Test
run: tox run -e ${{ matrix.toxenv }} --skip-pkg-install -- ${{ matrix.tox_extra_args }}
continue-on-error: ${{ matrix.allow_failure == 'true' }}
- name: Mark as success (check failures manually)
if: ${{ matrix.allow_failure == 'true' }}
run: exit 0
python_32bits:
runs-on: ubuntu-latest
name: Test mypyc suite with 32-bit Python
timeout-minutes: 60
env:
TOX_SKIP_MISSING_INTERPRETERS: False
# Rich (pip)
FORCE_COLOR: 1
# Tox
PY_COLORS: 1
# Mypy (see https://github.com/python/mypy/issues/7771)
TERM: xterm-color
MYPY_FORCE_COLOR: 1
MYPY_FORCE_TERMINAL_WIDTH: 200
# Pytest
PYTEST_ADDOPTS: --color=yes
CXX: i686-linux-gnu-g++
CC: i686-linux-gnu-gcc
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install 32-bit build dependencies
run: |
sudo dpkg --add-architecture i386 && \
sudo apt-get update && sudo apt-get install -y \
zlib1g-dev:i386 \
libgcc-s1:i386 \
g++-i686-linux-gnu \
gcc-i686-linux-gnu \
libffi-dev:i386 \
libssl-dev:i386 \
libbz2-dev:i386 \
libncurses-dev:i386 \
libreadline-dev:i386 \
libsqlite3-dev:i386 \
liblzma-dev:i386 \
uuid-dev:i386
- name: Compile, install, and activate 32-bit Python
uses: gabrielfalcao/pyenv-action@v13
with:
default: 3.11.1
command: python -c "import platform; print(f'{platform.architecture()=} {platform.machine()=}');"
- name: Install tox
run: pip install setuptools==75.1.0 tox==4.26.0
- name: Setup tox environment
run: tox run -e py --notest
- name: Test
run: tox run -e py --skip-pkg-install -- -n 4 mypyc/test/