Skip to content

Commit 01fdadf

Browse files
committed
Use GitHub Actions and ReadtheDocs CI
1 parent 949b259 commit 01fdadf

File tree

6 files changed

+152
-125
lines changed

6 files changed

+152
-125
lines changed

.github/workflows/ci.yml

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
Windows:
7+
name: 'Windows (${{ matrix.python }})'
8+
runs-on: 'windows-latest'
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
python: ['3.7', '3.8', '3.9', '3.10']
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
- name: Setup python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: ${{ matrix.python }}
21+
cache: pip
22+
cache-dependency-path: test-requirements.txt
23+
- name: Run tests
24+
run: ./ci.sh
25+
shell: bash
26+
env:
27+
# Should match 'name:' up above
28+
JOB_NAME: 'Windows (${{ matrix.python }})'
29+
30+
Ubuntu:
31+
name: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})'
32+
timeout-minutes: 10
33+
runs-on: 'ubuntu-latest'
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
python: ['3.7', '3.8', '3.9', '3.10', '3.11-dev']
38+
check_formatting: ['0']
39+
extra_name: ['']
40+
include:
41+
- python: '3.10'
42+
check_formatting: '1'
43+
extra_name: ', check formatting'
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v2
47+
- name: Setup python
48+
uses: actions/setup-python@v2
49+
if: "!endsWith(matrix.python, '-dev')"
50+
with:
51+
python-version: ${{ matrix.python }}
52+
cache: pip
53+
cache-dependency-path: test-requirements.txt
54+
- name: Setup python (dev)
55+
uses: deadsnakes/[email protected]
56+
if: endsWith(matrix.python, '-dev')
57+
with:
58+
python-version: '${{ matrix.python }}'
59+
- name: Run tests
60+
run: ./ci.sh
61+
env:
62+
CHECK_FORMATTING: '${{ matrix.check_formatting }}'
63+
# Should match 'name:' up above
64+
JOB_NAME: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})'
65+
66+
macOS:
67+
name: 'macOS (${{ matrix.python }})'
68+
timeout-minutes: 10
69+
runs-on: 'macos-latest'
70+
strategy:
71+
fail-fast: false
72+
matrix:
73+
python: ['3.7', '3.8', '3.9', '3.10']
74+
steps:
75+
- name: Checkout
76+
uses: actions/checkout@v2
77+
- name: Setup python
78+
uses: actions/setup-python@v2
79+
with:
80+
python-version: ${{ matrix.python }}
81+
cache: pip
82+
cache-dependency-path: test-requirements.txt
83+
- name: Run tests
84+
run: ./ci.sh
85+
env:
86+
# Should match 'name:' up above
87+
JOB_NAME: 'macOS (${{ matrix.python }})'

.readthedocs.yml

-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ formats:
55

66
requirements_file: ci/rtd-requirements.txt
77

8-
# Currently RTD's default image only has 3.5
9-
# This gets us 3.6 (and hopefully 3.7 in the future)
10-
# https://docs.readthedocs.io/en/latest/yaml-config.html#build-image
11-
build:
12-
image: latest
13-
148
python:
159
version: 3
1610
pip_install: True

ci.sh

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
MYPY_VERSION=0.782
6+
YAPF_VERSION=0.22.0
7+
8+
9+
pip install -U pip setuptools wheel
10+
11+
if [ "$CHECK_FORMATTING" = "1" ]; then
12+
pip install yapf==${YAPF_VERSION}
13+
if ! yapf -rpd setup.py sniffio; then
14+
cat <<EOF
15+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
17+
18+
Formatting problems were found (listed above). To fix them, run
19+
20+
pip install yapf==${YAPF_VERSION}
21+
yapf -rpi setup.py sniffio
22+
23+
in your local checkout.
24+
25+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
27+
EOF
28+
exit 1
29+
fi
30+
pip install mypy==${MYPY_VERSION}
31+
if ! mypy --pretty sniffio; then
32+
cat <<EOF
33+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
34+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
35+
36+
Type checking problems were found (listed above).
37+
38+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
39+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
40+
EOF
41+
exit 1
42+
fi
43+
exit 0
44+
fi
45+
46+
python setup.py sdist --formats=zip
47+
pip install dist/*.zip
48+
49+
# Actual tests
50+
pip install -Ur test-requirements.txt
51+
52+
mkdir empty
53+
cd empty
54+
55+
pytest -W error -ra -v --pyargs sniffio --cov=sniffio --cov-config=../.coveragerc --verbose
56+
57+
bash <(curl -s https://codecov.io/bash)

ci/travis.sh

-114
This file was deleted.

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"trio",
2222
"asyncio",
2323
],
24-
python_requires=">=3.5",
24+
python_requires=">=3.7",
2525
tests_require=['curio'],
2626
classifiers=[
2727
"License :: OSI Approved :: MIT License",

sniffio/_tests/test_sniffio.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import sys
23

34
import pytest
@@ -50,16 +51,18 @@ async def this_is_asyncio():
5051
assert current_async_library() == "asyncio"
5152
ran.append(True)
5253

53-
loop = asyncio.get_event_loop()
54-
loop.run_until_complete(this_is_asyncio())
54+
asyncio.run(this_is_asyncio())
5555
assert ran == [True]
56-
loop.close()
5756

5857
with pytest.raises(AsyncLibraryNotFoundError):
5958
current_async_library()
6059

6160

62-
@pytest.mark.skipif(sys.version_info < (3, 6), reason='Curio requires 3.6+')
61+
# https://github.com/dabeaz/curio/pull/354
62+
@pytest.mark.skipif(
63+
os.name == "nt" and sys.version_info >= (3, 9),
64+
reason="Curio breaks on Python 3.9+ on Windows. Fix was not released yet",
65+
)
6366
def test_curio():
6467
import curio
6568

0 commit comments

Comments
 (0)