Skip to content

Commit

Permalink
Use hatch (#175)
Browse files Browse the repository at this point in the history
* Use hatch

* ci on hatch

* add badge

* add section Development

* ruff badge

* dm badge

* disable lint on ci
  • Loading branch information
aamalev authored Jun 16, 2023
1 parent e9f2bab commit c225239
Show file tree
Hide file tree
Showing 5 changed files with 338 additions and 82 deletions.
152 changes: 84 additions & 68 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,83 +4,99 @@ on:
push:
branches:
- master
tags: [ '*' ]
pull_request:
branches:
- master
- 0.9.X

jobs:
tests:
runs-on: ${{ matrix.os }}
env:
FAKE_UI: 'yes'
strategy:
max-parallel: 7
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python:
- version: '3.6'
file: python3.6
requirements: aiohttp
os:
- ubuntu-latest
python-version:
- '3.7'
- '3.9'
- '3.10'
- pypy-3.8
- pypy-3.9
include:
- os: ubuntu-latest
python:
version: '3.5'
file: python3.5
requirements: aiohttp 'aiohttp-jinja2<1.3'
- os: ubuntu-latest
python:
version: '3.6'
file: python3.6
requirements: aiohttp==3.7.2
- os: ubuntu-latest
python:
version: '3.7'
file: python3.7
requirements: aiohttp
- os: ubuntu-latest
python:
version: '3.8'
file: python3.8
requirements: aiohttp
- os: ubuntu-latest
python:
version: '3.9'
file: python3.9
requirements: aiohttp
- os: ubuntu-latest
python:
version: '3.10'
file: python3.10
requirements: aiohttp
- os: ubuntu-latest
python:
version: pypy3
file: pypy3
requirements: aiohttp
python-version: '3.8'
coverage: true
- os: macOS-latest
python-version: '3.8'
- os: windows-latest
python-version: '3.8'
- os: ubuntu-20.04
python-version: '3.5'
deps: >-
'pytest-aiohttp<1'
pytest-mock
'aiohttp-jinja2<1.3'
jsonschema
pyyaml
- os: ubuntu-20.04
python-version: '3.6'
deps: >-
'pytest-aiohttp<1'
pytest-mock
aiohttp-jinja2
jsonschema
pyyaml
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python.version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python.version }}
- name: Install dependencies
run: |
pip install --user pip setuptools
pip install --user pipenv
python -m pipenv --python ${{ matrix.python.file }}
python -m pipenv run pip install -U pip setuptools codecov
echo "__version__ = 'tests'" > aiohttp_apiset/version.py
python -m pipenv run pip install -e .[dev]
python -m pipenv run pip install ${{ matrix.python.requirements }}
- name: Test with pytest
run: |
python -m pipenv run pytest --cov=aiohttp_apiset --cov-report=xml
- name: Upload coverage to Codecov
if: ${{ matrix.python.version == '3.5' && matrix.os == 'ubuntu-latest' }}
uses: codecov/codecov-action@v3.1.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
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.1
with:
python-version: ${{ matrix.python-version }}
- name: Install hatch
if: ${{ !matrix.deps }}
run: |
pip install -U hatch
- name: Install dependencies
if: ${{ matrix.deps }}
run: |
pip install ${{ matrix.deps }}
- name: ruff
if: ${{ matrix.lint }}
run: |
hatch run lint:ruff check aiohttp_apiset tests
- name: isort
if: ${{ matrix.lint }}
run: |
hatch run lint:isort -c aiohttp_apiset tests
- name: black
if: ${{ matrix.lint }}
run: |
hatch run lint:black --check --diff aiohttp_apiset tests
- name: mypy
if: ${{ matrix.lint }}
run: |
hatch run lint:mypy aiohttp_apiset tests
- name: Tests with coverage
if: ${{ !matrix.deps }}
run: |
hatch run cov
- name: Tests
if: ${{ matrix.deps }}
run: pytest
- name: coverage.xml
if: ${{ matrix.coverage }}
run: |
hatch run coverage xml
- name: Upload coverage to Codecov
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@v3.1.4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
31 changes: 21 additions & 10 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,31 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: PyPI
url: https://pypi.org/project/aiohttp-apiset/${{ github.ref_name }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v3.5.2
- name: Set up Python
uses: actions/setup-python@v4.6.1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
pip install --upgrade pip
pip install --upgrade hatch
- name: Build
run: |
hatch version $GITHUB_REF_NAME
hatch build
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
- name: Publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }}
run: |
echo "__version__ = '$(git describe --tags)'" > aiohttp_apiset/version.py
python setup.py sdist bdist_wheel
twine upload dist/*
hatch publish
44 changes: 44 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ aiohttp-apiset

.. image:: https://codecov.io/gh/aamalev/aiohttp_apiset/branch/master/graph/badge.svg
:target: https://codecov.io/gh/aamalev/aiohttp_apiset
:alt: Coverage

.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v0.json
:target: https://github.com/charliermarsh/ruff
:alt: Code style: ruff

.. image:: https://img.shields.io/pypi/v/aiohttp_apiset.svg
:target: https://pypi.python.org/pypi/aiohttp_apiset
Expand All @@ -14,6 +19,13 @@ aiohttp-apiset
:target: http://aiohttp-apiset.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://img.shields.io/pypi/dm/aiohttp-apiset.svg
:target: https://pypi.org/project/aiohttp-apiset

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

Package to build routes and validate request using swagger specification 2.0.

Features
Expand Down Expand Up @@ -90,3 +102,35 @@ Available both branch swagger-ui. For use branch 3.x visit http://localhost:8080


Examples: `examples <https://github.com/aamalev/aiohttp_apiset/tree/master/examples>`_



Development
-----------

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
Run tests with coverage:

.. code-block:: shell
hatch run cov
11 changes: 7 additions & 4 deletions aiohttp_apiset/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from .swagger.router import SwaggerRouter
from .views import ApiSet

try:
from .version import __version__
except ImportError:
__version__ = 'dev'
__version__ = "0.0.0"


__all__ = [
"ApiSet",
"SwaggerRouter",
]
Loading

0 comments on commit c225239

Please sign in to comment.