Skip to content

Commit

Permalink
Switch to hatch environments and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
icgood committed Apr 23, 2023
1 parent 876eed8 commit 7776f69
Show file tree
Hide file tree
Showing 20 changed files with 116 additions and 293 deletions.
1 change: 0 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ extend-select = B901, B902, B903, B904
extend-ignore = ANN101, ANN102
per-file-ignores =
test/*: ANN
tasks/*: ANN, B028
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build
name: check

on:
push:
Expand All @@ -7,9 +7,9 @@ on:
branches: [ main ]

jobs:
build:

run-checks:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
Expand All @@ -23,33 +23,13 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install build tools
run: |
python -m pip install --upgrade pip invoke coveralls
- name: Install package and dependencies
run: |
invoke install
python -m pip install hatch coveralls
- name: Run test suites, type checks, and linters
run: |
invoke validate
hatch run check
- name: Report test coverage to Coveralls
if: success()
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
coveralls --service=github
docs:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install build tools
run: |
python -m pip install --upgrade pip invoke
- name: Build the Sphinx documentation
run: |
invoke install doc.install doc.build
32 changes: 32 additions & 0 deletions .github/workflows/python-doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: doc

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ published ]

jobs:
build-doc:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install build tools
run: |
python -m pip install hatch
- name: Build the Sphinx documentation
run: |
hatch run doc:build
- name: Deploy to GitHub Pages
if: github.event_name == 'release'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ github.token }}
publish_dir: ./doc/build/html
40 changes: 9 additions & 31 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ on:
types: [ published ]

jobs:
deploy:

publish-dist:
runs-on: ubuntu-latest

steps:
Expand All @@ -17,34 +16,13 @@ jobs:
python-version: '3.11'
- name: Install build tools
run: |
python -m pip install --upgrade pip build twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m build
twine upload dist/*
docs:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install build tools
python -m pip install hatch
- name: Build distributions
run: |
python -m pip install --upgrade pip invoke
- name: Build the Sphinx documentation
hatch build
- name: Publish distributions
env:
HATCH_INDEX_USER: ${{ secrets.PYPI_USERNAME }}
HATCH_INDEX_AUTH: ${{ secrets.PYPI_PASSWORD }}
run: |
invoke install doc.install doc.build
- name: Deploy to GitHub Pages
if: success()
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ github.token }}
publish_dir: ./doc/build/html
hatch publish
2 changes: 0 additions & 2 deletions doc/requirements.txt

This file was deleted.

2 changes: 2 additions & 0 deletions pymap/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#: The package version string.
__version__ = '0.30.1'
13 changes: 0 additions & 13 deletions pymap/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +0,0 @@
"""Contains the package version string.
See Also:
`PEP 396 <https://www.python.org/dev/peps/pep-0396/>`_
"""

from importlib.metadata import distribution

__all__ = ['__version__']

#: The package version string.
__version__: str = distribution(__package__).version
3 changes: 2 additions & 1 deletion pymap/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
from grpclib.health.service import Health, OVERALL
from pymap.context import cluster_metadata
from pymap.interfaces.backend import ServiceInterface
from pymapadmin import is_compatible, __version__ as server_version
from pymapadmin import is_compatible
from pymapadmin.__about__ import __version__ as server_version
from pymapadmin.local import socket_file, token_file

from .errors import get_incompatible_version_error
Expand Down
4 changes: 2 additions & 2 deletions pymap/admin/handlers/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from typing import TypeAlias

from grpclib.server import Stream
from pymap import __version__ as pymap_version
from pymapadmin import __version__ as pymap_admin_version
from pymap.__about__ import __version__ as pymap_version
from pymapadmin.__about__ import __version__ as pymap_admin_version
from pymapadmin.grpc.admin_grpc import SystemBase
from pymapadmin.grpc.admin_pb2 import LoginRequest, LoginResponse, \
PingRequest, PingResponse
Expand Down
2 changes: 1 addition & 1 deletion pymap/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from string import Template
from typing import Any

from . import __version__
from .__about__ import __version__
from .backend import backends
from .interfaces.backend import BackendInterface, ServiceInterface
from .service import services
Expand Down
2 changes: 1 addition & 1 deletion pymap/sieve/manage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from proxyprotocol.reader import ProxyProtocolReader
from proxyprotocol.result import ProxyResult
from proxyprotocol.sock import SocketInfo
from pymap import __version__
from pymap.__about__ import __version__
from pymap.bytes import BytesFormat
from pymap.config import IMAPConfig
from pymap.context import socket_info, language_code, connection_exit
Expand Down
65 changes: 60 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ build-backend = 'hatchling.build'

[project]
name = 'pymap'
version = '0.30.0'
dynamic = ['version']
authors = [
{ name = 'Ian Good', email = 'ian@icgood.net' },
]
Expand All @@ -49,7 +49,7 @@ dependencies = [
]

[project.optional-dependencies]
admin = ['pymap-admin ~= 0.9.0', 'protobuf', 'googleapis-common-protos']
admin = ['pymap-admin ~= 0.9.2', 'protobuf', 'googleapis-common-protos']
macaroon = ['pymacaroons']
redis = ['redis ~= 4.2', 'msgpack ~= 1.0']
sieve = ['sievelib']
Expand All @@ -58,7 +58,8 @@ systemd = ['systemd-python']
optional = ['hiredis', 'passlib', 'pid']

[project.urls]
homepage = 'https://github.com/icgood/pymap/'
'Homepage' = 'https://github.com/icgood/pymap/'
'API Documentation' = 'https://icgood.github.io/pymap/'

[project.scripts]
pymap = 'pymap.main:main'
Expand All @@ -85,8 +86,16 @@ server = 'pymap.admin.handlers.system:SystemHandlers'
mailbox = 'pymap.admin.handlers.mailbox:MailboxHandlers'
user = 'pymap.admin.handlers.user:UserHandlers'

[tool.hatch.version]
path = 'pymap/__about__.py'

[tool.hatch.build]
exclude = ['/tasks', '/doc', '/.github']
exclude = [
'/.dockerignore',
'/doc',
'/docker',
'/.github',
]

[tool.hatch.build.targets.wheel]
packages = ['pymap']
Expand Down Expand Up @@ -141,10 +150,56 @@ norecursedirs = 'doc'

[tool.coverage.report]
fail_under = 90
omit = ['*/maildir/*', '*/redis/*', '*/main.py']
omit = ['*/__about__.py', '*/maildir/*', '*/redis/*', '*/main.py']
exclude_lines = [
'pragma: no cover',
'NotImplemented',
'^\s*...\s*$',
'def __repr__',
]

[tool.hatch.envs.default]
dependencies = [
'mypy',
'pytest',
'pytest-asyncio',
'pytest-cov',
'flake8',
'flake8-annotations',
'flake8-bugbear',
'bandit[toml]',
'types-certifi',
'types-protobuf',
'types-redis',
'types-toml',
'types-passlib',
]
features = [
'admin',
'redis',
'macaroon',
'optional',
'sieve',
'swim',
]

[tool.hatch.envs.default.scripts]
run-pytest = 'py.test --cov-report=term-missing --cov=pymap'
run-mypy = 'mypy pymap test'
run-flake8 = 'flake8 pymap test'
run-bandit = 'bandit -c pyproject.toml -qr pymap'
check = ['run-pytest', 'run-mypy', 'run-flake8', 'run-bandit']

[[tool.hatch.envs.all.matrix]]
python = ['3.11']

[tool.hatch.envs.doc]
dependencies = [
'sphinx',
'sphinx-autodoc-typehints',
'cloud_sptheme',
]

[tool.hatch.envs.doc.scripts]
build = 'make -C doc html'
browse = ['build', 'open doc/build/html/index.html']
21 changes: 0 additions & 21 deletions requirements-dev.txt

This file was deleted.

66 changes: 0 additions & 66 deletions tasks/__init__.py

This file was deleted.

Loading

0 comments on commit 7776f69

Please sign in to comment.