Skip to content

Commit

Permalink
Use plugin template (#40)
Browse files Browse the repository at this point in the history
* Use plugin template

* add types-PyYAML

* additional cov env detached

* ci 3.7
  • Loading branch information
aamalev authored May 23, 2023
1 parent 4df4095 commit 15bbba9
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 83 deletions.
82 changes: 45 additions & 37 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,55 +17,63 @@ jobs:
os:
- ubuntu-latest
python-version:
- '3.8'
- '3.7'
- '3.9'
- '3.10'
- '3.11'
- pypy-3.7
- pypy-3.8
- pypy-3.9
include:
- os: ubuntu-latest
python-version: '3.7'
python-version: '3.8'
coverage: true
lint: true
- os: macOS-latest
python-version: '3.7'
python-version: '3.8'
- os: windows-latest
python-version: '3.7'
python-version: '3.8'

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3.5.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4.6.0
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install -U hatch
- name: ruff
if: ${{ matrix.lint }}
run: |
hatch run style:ruff check pytest_aioworkers tests
- name: mypy
if: ${{ matrix.lint }}
run: |
hatch run style:mypy pytest_aioworkers tests
- name: Test with pytest & coverage
run: |
hatch run cov
- name: Additional coverage
if: ${{ matrix.coverage }}
run: |
hatch run cov:cov
hatch run coverage report
hatch run coverage xml
- name: Upload coverage to Codecov
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@v3.1.4
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
- uses: actions/checkout@v3.5.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4.6.0
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -U hatch
- name: ruff
if: ${{ matrix.lint }}
run: |
hatch run lint:ruff check pytest_aioworkers tests
- name: isort
if: ${{ matrix.lint }}
run: |
hatch run lint:isort -c pytest_aioworkers tests
- name: black
if: ${{ matrix.lint }}
run: |
hatch run lint:black --check --diff pytest_aioworkers tests
- name: mypy
if: ${{ matrix.lint }}
run: |
hatch run lint:mypy pytest_aioworkers tests
- name: Tests with coverage
run: |
hatch run cov
- name: Additional coverage
if: ${{ matrix.coverage }}
run: |
hatch run cov:cov
hatch run coverage report
hatch run coverage xml
- name: Upload coverage to Codecov
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@v3.1.3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
9 changes: 9 additions & 0 deletions .scaraplate.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[cookiecutter_context]
_template = cookiecutter-aioworkers-plugin
author_name = Alexander Malev
description = A plugin to test aioworkers project with pytest
email = malev@somedev.ru
git_branch = master
project_name = pytest-aioworkers
project_package = pytest_aioworkers
project_slug = pytest-aioworkers
46 changes: 38 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,34 @@
pytest-aioworkers
=================

.. image:: https://img.shields.io/pypi/v/pytest-aioworkers.svg
:target: https://pypi.org/project/pytest-aioworkers

.. image:: https://github.com/aioworkers/pytest-aioworkers/workflows/Tests/badge.svg
:target: https://github.com/aioworkers/pytest-aioworkers/actions?query=workflow%3ATests

.. image:: https://codecov.io/gh/aioworkers/pytest-aioworkers/branch/master/graph/badge.svg
:target: https://codecov.io/gh/aioworkers/pytest-aioworkers

.. image:: https://img.shields.io/pypi/v/pytest-aioworkers.svg
:target: https://pypi.org/project/pytest-aioworkers
:alt: PyPI version
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v0.json
:target: https://github.com/charliermarsh/ruff

.. image:: https://img.shields.io/badge/types-Mypy-blue.svg
:target: https://github.com/python/mypy

.. image:: https://readthedocs.org/projects/pytest-aioworkers/badge/?version=latest
:target: https://pytest-aioworkers.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://img.shields.io/pypi/pyversions/pytest-aioworkers.svg
:target: https://pypi.org/project/pytest-aioworkers
:alt: Python versions

.. image:: https://img.shields.io/pypi/dm/pytest-aioworkers.svg
:target: https://pypi.org/project/pytest-aioworkers

.. image:: https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg
:alt: Hatch project
:target: https://github.com/pypa/hatch
:alt: Hatch project
:target: https://github.com/pypa/hatch

A plugin to test aioworkers projects with pytest

Expand Down Expand Up @@ -50,11 +61,30 @@ Contributing
Contributions are very welcome. Tests can be run with `hatch`_, please ensure
the coverage at least stays the same before you submit a pull request.

To run tests::
Check code:

.. code-block:: shell
hatch run lint:all
Format code:

.. code-block:: shell
hatch run lint:fmt
Run tests:

.. code-block:: shell
hatch run pytest
or::
Run tests with coverage:

.. code-block:: shell
hatch run cov
Expand Down
128 changes: 90 additions & 38 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,54 @@ requires-python = ">=3.7"
authors = [
{ name = "Alexander Malev", email = "malev@somedev.ru" },
]
keywords = [
"aioworkers",
"pytest",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Framework :: AsyncIO",
"Framework :: Pytest",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Testing",
"Typing :: Typed",
]
dependencies = [
"aioworkers",
"pytest >= 6.1.0",
]

[project.optional-dependencies]
asyncio = [
"pytest-asyncio",
]
aiohttp = [
"pytest-aiohttp",
]
asyncio = [
"pytest-asyncio",
dev-test = [
"aioworkers==0.21.1",
"coverage[toml]==7.2.5",
"pytest==7.3.1",
"pytest-asyncio==0.21.0",
"pytest-timeout==2.1.0",
"pytest-mock==3.10.0",
"pyyaml==6.0",
]
dev-lint = [
"ruff==0.0.269",
"isort==5.12.0",
"black==23.3.0",
"mypy==1.3.0",
"types-PyYAML==6.0.12.10",
]

[project.entry-points.pytest11]
Expand All @@ -45,8 +68,9 @@ aioworkers = "pytest_aioworkers.plugin"
[project.urls]
GitHub = "https://github.com/aioworkers/pytest-aioworkers"
Homepage = "https://github.com/aioworkers/pytest-aioworkers"
Documentation = "https://github.com/aioworkers/pytest-aioworkers/blob/master/README.rst"
Documentation = "https://github.com/aioworkers/pytest-aioworkers#readme"
Issues = "https://github.com/aioworkers/pytest-aioworkers/issues"
Source = "https://github.com/aioworkers/pytest-aioworkers"

[tool.hatch.version]
path = "pytest_aioworkers/__init__.py"
Expand All @@ -57,35 +81,45 @@ include = [
]

[tool.hatch.envs.default]
dependencies = [
"coverage[toml]",
"pytest",
"pytest-asyncio",
"pytest-timeout",
"pytest-mock",
"pyyaml",
features = [
"dev-test",
]
[tool.hatch.envs.default.scripts]
cov = "coverage run -m pytest"
no-cov = "cov --no-cov"
cov = "coverage run -m pytest && coverage report"

[tool.hatch.envs.cov]
detached = true
dependencies = [
"coverage[toml]",
]
[tool.hatch.envs.cov.scripts]
cov = "coverage run --append -m pytest_aioworkers.utils"

[[tool.hatch.envs.all.matrix]]
python = [
"3.7",
"3.8",
"3.9",
"3.10",
"3.11",
]

[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = ["tests", "pytest_aioworkers"]
addopts = ["-s", "--doctest-modules"]
testpaths = [
"pytest_aioworkers",
"tests",
]
addopts = [
"--doctest-modules",
]

[tool.coverage.run]
branch = false
branch = true
parallel = false
omit = [
"pytest_aioworkers/__init__.py",
source = [
"pytest_aioworkers",
"tests",
]

[tool.coverage.report]
Expand All @@ -96,7 +130,13 @@ exclude_lines = [

[tool.black]
line-length = 120
target-version = ["py37", "py38", "py39", "py310", "py311"]
target-version = [
"py37",
"py38",
"py39",
"py310",
"py311",
]

[tool.isort]
profile = "black"
Expand All @@ -108,30 +148,42 @@ follow_imports = "silent"
strict_optional = true
warn_redundant_casts = true
ignore_missing_imports = true
check_untyped_defs = true

[tool.ruff]
line-length = 120

[tool.hatch.envs.style]
[tool.hatch.envs.lint]
features = [
"dev-lint",
]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive {args:pytest_aioworkers tests}"
style = [
"ruff {args:pytest_aioworkers tests}",
"isort --check-only --diff {args:pytest_aioworkers tests}",
"black --check --diff {args:pytest_aioworkers tests}",
]
fmt = [
"ruff --fix {args:pytest_aioworkers tests}",
"isort {args:pytest_aioworkers tests}",
"black {args:pytest_aioworkers tests}",
"style",
]
all = [
"style",
"typing",
]

[tool.hatch.envs.template]
detached = true
dependencies = [
"ruff",
"black",
"isort",
"mypy",
"types-PyYAML",
"types-setuptools",
]
[tool.hatch.envs.style.scripts]
check = [
"ruff check pytest_aioworkers tests",
"isort --check-only --diff pytest_aioworkers tests",
"black --check --diff pytest_aioworkers tests",
"mypy pytest_aioworkers tests",
"scaraplate",
]
fmt = [
"isort pytest_aioworkers tests",
"black pytest_aioworkers tests",
"ruff check --fix pytest_aioworkers tests",
"check",
[tool.hatch.envs.template.scripts]
update = [
"scaraplate rollup --no-input {args:../cookiecutter-aioworkers-plugin} ."
]
clone = [
"git clone https://github.com/aioworkers/cookiecutter-aioworkers-plugin {args:../cookiecutter-aioworkers-plugin}"
]

0 comments on commit 15bbba9

Please sign in to comment.