Skip to content

Commit 37cea6b

Browse files
authored
Merge pull request #100 from oremanj/use-gh-actions
Move CI to Github Actions
2 parents 723a7f7 + dc5846c commit 37cea6b

File tree

10 files changed

+317
-177
lines changed

10 files changed

+317
-177
lines changed

.appveyor.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- "dependabot/**"
7+
pull_request:
8+
9+
jobs:
10+
Windows:
11+
name: 'Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})'
12+
timeout-minutes: 20
13+
runs-on: 'windows-latest'
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
python: ['3.6', '3.7', '3.8', '3.9']
18+
arch: ['x86', 'x64']
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v2
22+
- name: Setup python
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: '${{ matrix.python }}'
26+
architecture: '${{ matrix.arch }}'
27+
- name: Run tests
28+
run: ./ci.sh
29+
shell: bash
30+
env:
31+
# Should match 'name:' up above
32+
JOB_NAME: 'Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})'
33+
34+
Ubuntu:
35+
name: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})'
36+
timeout-minutes: 10
37+
runs-on: 'ubuntu-latest'
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
# No pypy-3.7 because Trio doesn't support it (nightly is fine, it has a fix we need)
42+
python: ['pypy-3.6', '3.6', '3.7', '3.8', '3.9', '3.6-dev', '3.7-dev', '3.8-dev', '3.9-dev']
43+
check_formatting: ['0']
44+
check_docs: ['0']
45+
pypy_nightly_branch: ['']
46+
extra_name: ['']
47+
include:
48+
- python: '3.8'
49+
check_formatting: '1'
50+
extra_name: ', check formatting'
51+
- python: '3.8'
52+
check_docs: '1'
53+
extra_name: ', check docs'
54+
# pypy3.7-nightly produces an "OSError: handle is closed" in the
55+
# bowels of multiprocessing after all tests appear to complete successfully
56+
# - python: '3.7' # <- not actually used
57+
# pypy_nightly_branch: 'py3.7'
58+
# extra_name: ', pypy 3.7 nightly'
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v2
62+
- name: Setup python
63+
uses: actions/setup-python@v2
64+
if: "!endsWith(matrix.python, '-dev')"
65+
with:
66+
python-version: '${{ matrix.python }}'
67+
- name: Setup python (dev)
68+
uses: deadsnakes/action@v2.0.2
69+
if: endsWith(matrix.python, '-dev')
70+
with:
71+
python-version: '${{ matrix.python }}'
72+
- name: Install python testsuite
73+
if: endsWith(matrix.python, '-dev')
74+
run: |
75+
version=$(echo $PYVERSION | sed 's/-dev//')
76+
sudo apt-get install -y --no-install-recommends libpython${version}-testsuite
77+
env:
78+
PYVERSION: '${{ matrix.python }}'
79+
- name: Run tests
80+
run: ./ci.sh
81+
env:
82+
PYPY_NIGHTLY_BRANCH: '${{ matrix.pypy_nightly_branch }}'
83+
CHECK_FORMATTING: '${{ matrix.check_formatting }}'
84+
CHECK_DOCS: '${{ matrix.check_docs }}'
85+
# Should match 'name:' up above
86+
JOB_NAME: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})'
87+
88+
macOS:
89+
name: 'macOS (${{ matrix.python }})'
90+
timeout-minutes: 10
91+
runs-on: 'macos-latest'
92+
strategy:
93+
fail-fast: false
94+
matrix:
95+
python: ['3.6', '3.7', '3.8', '3.9']
96+
steps:
97+
- name: Checkout
98+
uses: actions/checkout@v2
99+
- name: Setup python
100+
uses: actions/setup-python@v2
101+
with:
102+
python-version: '${{ matrix.python }}'
103+
- name: Run tests
104+
run: ./ci.sh
105+
env:
106+
# Should match 'name:' up above
107+
JOB_NAME: 'macOS (${{ matrix.python }})'

.readthedocs.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# https://docs.readthedocs.io/en/latest/yaml-config.html
2+
version: 2
3+
24
formats:
35
- htmlzip
46
- epub
57

6-
requirements_file: ci/rtd-requirements.txt
7-
88
python:
9-
version: 3
10-
pip_install: True
9+
version: 3.7
10+
install:
11+
- requirements: docs-requirements.txt
12+
13+
sphinx:
14+
fail_on_warning: true

.travis.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

ci.sh

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#!/bin/bash
2+
3+
set -ex -o pipefail
4+
5+
# Log some general info about the environment
6+
uname -a
7+
env | sort
8+
9+
if [ "$JOB_NAME" = "" ]; then
10+
JOB_NAME="${TRAVIS_OS_NAME}-${TRAVIS_PYTHON_VERSION:-unknown}"
11+
fi
12+
13+
# Curl's built-in retry system is not very robust; it gives up on lots of
14+
# network errors that we want to retry on. Wget might work better, but it's
15+
# not installed on azure pipelines's windows boxes. So... let's try some good
16+
# old-fashioned brute force. (This is also a convenient place to put options
17+
# we always want, like -f to tell curl to give an error if the server sends an
18+
# error response, and -L to follow redirects.)
19+
function curl-harder() {
20+
for BACKOFF in 0 1 2 4 8 15 15 15 15; do
21+
sleep $BACKOFF
22+
if curl -fL --connect-timeout 5 "$@"; then
23+
return 0
24+
fi
25+
done
26+
return 1
27+
}
28+
29+
################################################################
30+
# Bootstrap python environment, if necessary
31+
################################################################
32+
33+
### PyPy nightly (currently on Travis) ###
34+
35+
if [ "$PYPY_NIGHTLY_BRANCH" != "" ]; then
36+
JOB_NAME="pypy_nightly_${PYPY_NIGHTLY_BRANCH}"
37+
curl-harder -o pypy.tar.bz2 http://buildbot.pypy.org/nightly/${PYPY_NIGHTLY_BRANCH}/pypy-c-jit-latest-linux64.tar.bz2
38+
if [ ! -s pypy.tar.bz2 ]; then
39+
# We know:
40+
# - curl succeeded (200 response code)
41+
# - nonetheless, pypy.tar.bz2 does not exist, or contains no data
42+
# This isn't going to work, and the failure is not informative of
43+
# anything involving Trio.
44+
ls -l
45+
echo "PyPy3 nightly build failed to download – something is wrong on their end."
46+
echo "Skipping testing against the nightly build for right now."
47+
exit 0
48+
fi
49+
tar xaf pypy.tar.bz2
50+
# something like "pypy-c-jit-89963-748aa3022295-linux64"
51+
PYPY_DIR=$(echo pypy-c-jit-*)
52+
PYTHON_EXE=$PYPY_DIR/bin/pypy3
53+
54+
if ! ($PYTHON_EXE -m ensurepip \
55+
&& $PYTHON_EXE -m pip install virtualenv \
56+
&& $PYTHON_EXE -m virtualenv testenv); then
57+
echo "pypy nightly is broken; skipping tests"
58+
exit 0
59+
fi
60+
source testenv/bin/activate
61+
fi
62+
63+
################################################################
64+
# We have a Python environment!
65+
################################################################
66+
67+
python -c "import sys, struct, ssl; print('#' * 70); print('python:', sys.version); print('version_info:', sys.version_info); print('bits:', struct.calcsize('P') * 8); print('openssl:', ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO); print('#' * 70)"
68+
69+
python -m pip install -U pip setuptools wheel
70+
python -m pip --version
71+
72+
python setup.py sdist --formats=zip
73+
python -m pip install dist/*.zip
74+
75+
if python -c 'import sys; sys.exit(sys.version_info >= (3, 7))'; then
76+
# Python < 3.7, select last ipython with 3.6 support
77+
# macOS requires the suffix for --in-place or you get an undefined label error
78+
sed -i'.bak' 's/ipython==[^ ]*/ipython==7.16.1/' test-requirements.txt
79+
sed -i'.bak' 's/traitlets==[^ ]*/traitlets==4.3.3/' test-requirements.txt
80+
git diff test-requirements.txt
81+
fi
82+
83+
# See https://github.com/python-trio/trio/issues/334
84+
YAPF_VERSION=0.20.0
85+
86+
if [ "$CHECK_FORMATTING" = "1" ]; then
87+
pip install yapf==${YAPF_VERSION}
88+
if ! yapf -rpd setup.py trio_asyncio; then
89+
cat <<EOF
90+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
91+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
92+
93+
Formatting problems were found (listed above). To fix them, run
94+
95+
pip install yapf==${YAPF_VERSION}
96+
yapf -rpi setup.py trio_asyncio
97+
98+
in your local checkout.
99+
100+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
101+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
102+
EOF
103+
exit 1
104+
fi
105+
exit 0
106+
fi
107+
108+
if [ "$CHECK_DOCS" = "1" ]; then
109+
python -m pip install -r docs-requirements.txt
110+
cd docs
111+
# -n (nit-picky): warn on missing references
112+
# -W: turn warnings into errors
113+
sphinx-build -nW -b html source build
114+
else
115+
# Actual tests
116+
python -m pip install -r test-requirements.txt
117+
118+
# We run the tests from inside an empty directory, to make sure Python
119+
# doesn't pick up any .py files from our working dir. Might have been
120+
# pre-created by some of the code above.
121+
mkdir empty || true
122+
cd empty
123+
124+
# We have to copy .coveragerc into this directory, rather than passing
125+
# --cov-config=../.coveragerc to pytest, because codecov.sh will run
126+
# 'coverage xml' to generate the report that it uses, and that will only
127+
# apply the ignore patterns in the current directory's .coveragerc.
128+
cp ../.coveragerc .
129+
if pytest -ra --junitxml=../test-results.xml --cov=trio_asyncio --verbose ../tests; then
130+
PASSED=true
131+
else
132+
PASSED=false
133+
fi
134+
135+
# The codecov docs recommend something like 'bash <(curl ...)' to pipe the
136+
# script directly into bash as its being downloaded. But, the codecov
137+
# server is flaky, so we instead save to a temp file with retries, and
138+
# wait until we've successfully fetched the whole script before trying to
139+
# run it.
140+
curl-harder -o codecov.sh https://codecov.io/bash
141+
bash codecov.sh -n "${JOB_NAME}"
142+
143+
$PASSED
144+
fi

0 commit comments

Comments
 (0)