From 93849fadada67b7cdf4fc4f844ab7fbcc711c52f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4ufl?= Date: Tue, 20 Oct 2020 01:16:07 +0200 Subject: [PATCH] Add GitHub Actions --- .github/workflows/tests.yml | 47 +++++++++++++++++++++++++++++++++++++ daphne/testing.py | 4 ++-- setup.cfg | 21 +++++++---------- tox.ini | 23 ++++++++++++++++++ 4 files changed, 80 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/tests.yml create mode 100644 tox.ini diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..0756665 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,47 @@ +name: Tests + +on: + push: + branches: + - master + pull_request: + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: + - 3.6 + - 3.7 + - 3.8 + - 3.9 + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel setuptools tox + - name: Run tox targets for ${{ matrix.python-version }} + run: | + ENV_PREFIX=$(tr -C -d "0-9" <<< "${{ matrix.python-version }}") + TOXENV=$(tox --listenvs | grep "^py$ENV_PREFIX" | tr '\n' ',') python -m tox + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install dependencies + run: | + python -m pip install --upgrade pip tox + - name: Run lint + run: tox -e qa diff --git a/daphne/testing.py b/daphne/testing.py index 7cc1182..c302045 100644 --- a/daphne/testing.py +++ b/daphne/testing.py @@ -127,8 +127,8 @@ class DaphneProcess(multiprocessing.Process): from twisted.internet import reactor - from .server import Server from .endpoints import build_endpoint_description_strings + from .server import Server try: # Create the server class @@ -266,8 +266,8 @@ class TestApplication: def _reinstall_reactor(): - import sys import asyncio + import sys from twisted.internet import asyncioreactor diff --git a/setup.cfg b/setup.cfg index e50af68..0c1709f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,16 +1,11 @@ -[bdist_wheel] -universal=1 - -[tool:pytest] -addopts = tests/ - -[isort] -include_trailing_comma = True -multi_line_output = 3 -known_first_party = channels,daphne,asgiref,channels_redis -line_length = 88 - [flake8] exclude = venv/*,tox/*,docs/*,testproject/*,js_client/*,.eggs/* -ignore = E123,E128,E266,E402,W503,E731,W601 +extend-ignore = E123, E128, E266, E402, W503, E731, W601 max-line-length = 120 + +[isort] +profile = black +known_first_party = channels,daphne,asgiref,channels_redis,http_base,http_strategies + +[tool:pytest] +testpaths = tests diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..a4010d7 --- /dev/null +++ b/tox.ini @@ -0,0 +1,23 @@ +[tox] +envlist = + py{36,37,38,39}-twisted{187,latest} + qa + +[testenv] +usedevelop = true +extras = tests +commands = + pytest -v {posargs} +deps = + twisted187: twisted==18.7.0 + twistedlatest: twisted>=20.3.0 + +[testenv:qa] +deps = + black + flake8 + isort +commands = + flake8 daphne tests + black --check daphne tests + isort --check-only --diff daphne tests