From 8ee04f96934684c9b8f8278df0530ae9fad1be4a Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Mon, 26 Apr 2021 12:54:29 +0100 Subject: [PATCH] CI improvements (#243) * CI improvements * typos * fix linting, skip macos tests --- .github/workflows/ci.yml | 55 ++++++++++++++----- Makefile | 4 +- arq/jobs.py | 2 +- arq/typing.py | 6 +- requirements.txt | 5 +- setup.cfg | 2 +- tests/requirements-linting.txt | 8 +++ ...uirements.txt => requirements-testing.txt} | 7 --- 8 files changed, 57 insertions(+), 32 deletions(-) create mode 100644 tests/requirements-linting.txt rename tests/{requirements.txt => requirements-testing.txt} (61%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 055ff4d6..2a0930ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,40 @@ on: pull_request: {} jobs: + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: set up python + uses: actions/setup-python@v1 + with: + python-version: 3.9 + + - run: pip install -r tests/requirements-linting.txt + - run: pip install . + + - run: make lint + + - run: make mypy + + docs: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: set up python + uses: actions/setup-python@v1 + with: + python-version: 3.9 + + - run: pip install -r docs/requirements.txt + - run: pip install . + + - run: make docs + test: name: test py${{ matrix.python-version }} on ${{ matrix.os }} strategy: @@ -38,30 +72,21 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: install dependencies - run: | - make install - pip freeze - - - name: lint - run: make lint + - run: pip install -r tests/requirements-testing.txt + - run: pip install .[watch] - - name: mypy - run: make mypy + - run: make test - - name: test - run: | - make test - coverage xml + - run: coverage xml - - uses: samuelcolvin/codecov-action@env-vars + - uses: codecov/codecov-action@v1.4.1 with: file: ./coverage.xml env_vars: PYTHON,OS deploy: name: Deploy - needs: test + needs: [lint, docs, test] if: "success() && startsWith(github.ref, 'refs/tags/')" runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index 99fde473..35fd24c5 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ .DEFAULT_GOAL := all -isort = isort -rc arq tests +isort = isort arq tests black = black -S -l 120 --target-version py37 arq tests .PHONY: install @@ -16,7 +16,7 @@ format: .PHONY: lint lint: flake8 arq/ tests/ - $(isort) --check-only -df + $(isort) --check-only --df $(black) --check .PHONY: test diff --git a/arq/jobs.py b/arq/jobs.py index 5964c122..18d86b6b 100644 --- a/arq/jobs.py +++ b/arq/jobs.py @@ -147,7 +147,7 @@ async def abort(self, *, timeout: Optional[float] = None, poll_delay: float = 0. Abort the job. :param timeout: maximum time to wait for the job result before raising ``TimeoutError``, - will wait forever on None + will wait forever on None :param poll_delay: how often to poll redis for the job result :return: True if the job aborted properly, False otherwise """ diff --git a/arq/typing.py b/arq/typing.py index cd7d3336..bde59053 100644 --- a/arq/typing.py +++ b/arq/typing.py @@ -3,9 +3,9 @@ from typing import TYPE_CHECKING, Any, Dict, Optional, Sequence, Set, Type, Union if sys.version_info >= (3, 8): - from typing import Protocol, Literal + from typing import Literal, Protocol else: - from typing_extensions import Protocol, Literal + from typing_extensions import Literal, Protocol __all__ = ( 'OptionType', @@ -19,8 +19,8 @@ if TYPE_CHECKING: - from .worker import Function # noqa F401 from .cron import CronJob # noqa F401 + from .worker import Function # noqa F401 OptionType = Union[None, Set[int], int] WEEKDAYS = 'mon', 'tues', 'wed', 'thurs', 'fri', 'sat', 'sun' diff --git a/requirements.txt b/requirements.txt index 07dd334b..cc8238d5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -r docs/requirements.txt --r tests/requirements.txt - -pydantic==1.7 +-r tests/requirements-linting.txt +-r tests/requirements-testing.txt diff --git a/setup.cfg b/setup.cfg index 15fc6271..12a7f168 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,7 +25,7 @@ exclude_lines = [isort] line_length=120 -known_standard_library=dataclasses +known_third_party=pytest multi_line_output=3 include_trailing_comma=True force_grid_wrap=0 diff --git a/tests/requirements-linting.txt b/tests/requirements-linting.txt new file mode 100644 index 00000000..92e22d95 --- /dev/null +++ b/tests/requirements-linting.txt @@ -0,0 +1,8 @@ +black==19.10b0 +flake8==3.7.9 +flake8-quotes==3 +isort==5.8.0 +mypy==0.812 +pycodestyle==2.5.0 +pyflakes==2.1.1 +twine==3.1.1 diff --git a/tests/requirements.txt b/tests/requirements-testing.txt similarity index 61% rename from tests/requirements.txt rename to tests/requirements-testing.txt index 5887d149..420e112c 100644 --- a/tests/requirements.txt +++ b/tests/requirements-testing.txt @@ -1,12 +1,5 @@ -black==19.10b0 coverage==5.1 -flake8==3.7.9 -flake8-quotes==3 -isort==4.3.21 msgpack==0.6.1 -mypy==0.812 -pycodestyle==2.5.0 -pyflakes==2.1.1 pytest==5.3.5 pytest-aiohttp==0.3.0 pytest-cov==2.8.1