Skip to content

Commit

Permalink
Attempt to fix PyPy CI (#2536)
Browse files Browse the repository at this point in the history
* Attempt to fix PyPy CI

* Fix typo for job name

* Try out setup-python's nightly pypy support

* Remove redundant shell scripting

* Final changes to CI workflow

* Bump @actions/setup-python to maybe fix issue installing PyPy nightly on Windows

* Make Windows CI pass

* Update exports for PyPy on Windows

* Bump timeout for CI on MacOS

* Lower time taken for test_handshake_over_terrible_network

* Run black

The segfault on Windows is something to look into eventually: not now.
  • Loading branch information
A5rocks authored Mar 11, 2023
1 parent 4b6117b commit e45c9d5
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 67 deletions.
60 changes: 31 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['3.7', '3.8', '3.9', '3.10']
python: ['3.7', '3.8', '3.9', '3.10', 'pypy-3.8-nightly', 'pypy-3.9-nightly']
arch: ['x86', 'x64']
lsp: ['']
lsp_extract_file: ['']
extra_name: ['']
exclude:
- python: 'pypy-3.8-nightly'
arch: 'x86'
- python: 'pypy-3.9-nightly'
arch: 'x86'
include:
- python: '3.8'
arch: 'x64'
Expand All @@ -35,16 +40,20 @@ jobs:
# lsp: 'http://download.pctools.com/mirror/updates/9.0.0.2308-SDavfree-lite_en.exe'
# lsp_extract_file: ''
# extra_name: ', with non-IFS LSP'
- python: '3.8' # <- not actually used
arch: 'x64'
pypy_nightly_branch: 'py3.8'
extra_name: ', pypy 3.8 nightly'

continue-on-error: >-
${{
(
endsWith(matrix.python, '-dev')
|| endsWith(matrix.python, '-nightly')
)
&& true
|| false
}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
# This allows the matrix to specify just the major.minor version while still
# expanding it to get the latest patch version including alpha releases.
Expand Down Expand Up @@ -74,29 +83,19 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['pypy-3.7', 'pypy-3.8', 'pypy-3.9', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12-dev']
python: ['pypy-3.7', 'pypy-3.8', 'pypy-3.9', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12-dev', 'pypy-3.8-nightly', 'pypy-3.9-nightly']
check_formatting: ['0']
pypy_nightly_branch: ['']
extra_name: ['']
include:
- python: '3.8'
check_formatting: '1'
extra_name: ', check formatting'
- python: '3.7' # <- not actually used
pypy_nightly_branch: 'py3.7'
extra_name: ', pypy 3.7 nightly'
- python: '3.8' # <- not actually used
pypy_nightly_branch: 'py3.8'
extra_name: ', pypy 3.8 nightly'
- python: '3.9' # <- not actually used
pypy_nightly_branch: 'py3.9'
extra_name: ', pypy 3.9 nightly'
continue-on-error: >-
${{
(
matrix.check_formatting == '1'
|| matrix.pypy_nightly_branch == 'py3.7'
|| endsWith(matrix.python, '-dev')
|| endsWith(matrix.python, '-nightly')
)
&& true
|| false
Expand All @@ -105,7 +104,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
if: "!endsWith(matrix.python, '-dev')"
with:
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
Expand All @@ -119,7 +118,6 @@ jobs:
- name: Run tests
run: ./ci.sh
env:
PYPY_NIGHTLY_BRANCH: '${{ matrix.pypy_nightly_branch }}'
CHECK_FORMATTING: '${{ matrix.check_formatting }}'
# Should match 'name:' up above
JOB_NAME: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})'
Expand Down Expand Up @@ -159,22 +157,26 @@ jobs:
macOS:
name: 'macOS (${{ matrix.python }})'
timeout-minutes: 10
timeout-minutes: 15
runs-on: 'macos-latest'
strategy:
fail-fast: false
matrix:
python: ['3.7', '3.8', '3.9', '3.10']
include:
- python: '3.8' # <- not actually used
arch: 'x64'
pypy_nightly_branch: 'py3.8'
extra_name: ', pypy 3.8 nightly'
python: ['3.7', '3.8', '3.9', '3.10', 'pypy-3.8-nightly', 'pypy-3.9-nightly']
continue-on-error: >-
${{
(
endsWith(matrix.python, '-dev')
|| endsWith(matrix.python, '-nightly')
)
&& true
|| false
}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
cache: pip
Expand Down
34 changes: 0 additions & 34 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,6 @@ function curl-harder() {
return 1
}

################################################################
# Bootstrap python environment, if necessary
################################################################

### PyPy nightly ###

if [ "$PYPY_NIGHTLY_BRANCH" != "" ]; then
JOB_NAME="pypy_nightly_${PYPY_NIGHTLY_BRANCH}"
curl-harder -o pypy.tar.bz2 http://buildbot.pypy.org/nightly/${PYPY_NIGHTLY_BRANCH}/pypy-c-jit-latest-linux64.tar.bz2
if [ ! -s pypy.tar.bz2 ]; then
# We know:
# - curl succeeded (200 response code)
# - nonetheless, pypy.tar.bz2 does not exist, or contains no data
# This isn't going to work, and the failure is not informative of
# anything involving Trio.
ls -l
echo "PyPy3 nightly build failed to download – something is wrong on their end."
echo "Skipping testing against the nightly build for right now."
exit 0
fi
tar xaf pypy.tar.bz2
# something like "pypy-c-jit-89963-748aa3022295-linux64"
PYPY_DIR=$(echo pypy-c-jit-*)
PYTHON_EXE=$PYPY_DIR/bin/pypy3

if ! ($PYTHON_EXE -m ensurepip \
&& $PYTHON_EXE -m pip install virtualenv \
&& $PYTHON_EXE -m virtualenv testenv); then
echo "pypy nightly is broken; skipping tests"
exit 0
fi
source testenv/bin/activate
fi

################################################################
# We have a Python environment!
################################################################
Expand Down
2 changes: 1 addition & 1 deletion trio/_core/tests/test_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async def read_region(start, end):

assert buffer == data

with pytest.raises(BufferError):
with pytest.raises((BufferError, TypeError)):
await _core.readinto_overlapped(handle, b"immutable")
finally:
kernel32.CloseHandle(handle)
Expand Down
2 changes: 1 addition & 1 deletion trio/_core/tests/tutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def gc_collect_harder():
# garbage collection, because executing their __del__ method to print the
# warning can cause them to be resurrected. So we call collect a few times
# to make sure.
for _ in range(4):
for _ in range(5):
gc.collect()


Expand Down
6 changes: 5 additions & 1 deletion trio/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@
SCM_J1939_DEST_ADDR, SCM_J1939_DEST_NAME, SCM_J1939_ERRQUEUE,
SCM_J1939_PRIO, SO_J1939_ERRQUEUE, SO_J1939_FILTER, SO_J1939_PROMISC,
SO_J1939_SEND_PRIO, UDPLITE_RECV_CSCOV, UDPLITE_SEND_CSCOV, IP_RECVTOS,
TCP_KEEPALIVE, SO_INCOMING_CPU
TCP_KEEPALIVE, SO_INCOMING_CPU, FD_ACCEPT, FD_CLOSE, FD_CLOSE_BIT,
FD_CONNECT, FD_CONNECT_BIT, FD_READ, FD_WRITE, INFINITE,
WSA_FLAG_OVERLAPPED, WSA_INVALID_HANDLE, WSA_INVALID_PARAMETER,
WSA_IO_INCOMPLETE, WSA_IO_PENDING, WSA_NOT_ENOUGH_MEMORY,
WSA_OPERATION_ABORTED, WSA_WAIT_FAILED, WSA_WAIT_TIMEOUT,
)
# fmt: on
except ImportError:
Expand Down
4 changes: 3 additions & 1 deletion trio/tests/test_dtls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import trio.testing
from trio import DTLSEndpoint
import random
import sys
import attr
from contextlib import asynccontextmanager
from itertools import count
Expand Down Expand Up @@ -101,7 +102,8 @@ async def test_smoke(ipv6):

@slow
async def test_handshake_over_terrible_network(autojump_clock):
HANDSHAKES = 1000
# PyPy is not fast enough
HANDSHAKES = 500 if sys.implementation.name == "pypy" else 1000
r = random.Random(0)
fn = FakeNet()
fn.enable()
Expand Down

0 comments on commit e45c9d5

Please sign in to comment.