Skip to content

Commit

Permalink
Use tox
Browse files Browse the repository at this point in the history
  • Loading branch information
tarioch committed Sep 10, 2021
1 parent 1d3f6eb commit fcbc9cc
Show file tree
Hide file tree
Showing 8 changed files with 201 additions and 25 deletions.
28 changes: 28 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# .coveragerc to control coverage.py
[run]
branch = True
source = tariochbctools
# omit = bad_file.py

[paths]
source =
src/
*/site-packages/

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover

# Don't complain about missing debug-only code:
def __repr__
if self\.debug

# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError

# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:
33 changes: 9 additions & 24 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,34 @@ jobs:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@main
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v1
- uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install flake8
python-version: 3.x
- name: Install tox
run: >-
pip install
flake8
pip install tox
- name: Lint
run: >-
flake8
tox -e lint
- name: Test
run: >-
python setup.py test
- name: Install pep517
run: >-
python -m
pip install
pep517
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
pep517.build
--source
--binary
--out-dir dist/
.
tox
- name: Publish distribution 📦 to Test PyPI
if: contains(github.ref, 'refs/heads/master')
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.test_pypi_password }}
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
run: >-
pip install twine && twine upload dist/*
tox -e publish
- name: Publish distribution 📦 to PyPI
if: contains(github.ref, 'refs/tags/v')
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_password }}
TWINE_REPOSITORY_URL: https://upload.pypi.org/legacy/
run: >-
pip install twine && twine upload dist/*
tox -e publish --repository pypi
3 changes: 3 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[settings]
profile = black
known_first_party = tariochbctools
54 changes: 54 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
exclude: '^docs/conf.py'

repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: check-added-large-files
- id: check-ast
- id: check-json
- id: check-merge-conflict
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: mixed-line-ending
args: ['--fix=auto'] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows

## If you want to avoid flake8 errors due to unused vars or imports:
# - repo: https://github.com/myint/autoflake.git
# rev: v1.4
# hooks:
# - id: autoflake
# args: [
# --in-place,
# --remove-all-unused-imports,
# --remove-unused-variables,
# ]

- repo: https://github.com/pycqa/isort
rev: 5.9.3
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 21.8b0
hooks:
- id: black
language_version: python3

## If like to embrace black styles even in the docs:
# - repo: https://github.com/asottile/blacken-docs
# rev: v1.9.1
# hooks:
# - id: blacken-docs
# additional_dependencies: [black]

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
## You can add flake8 plugins via `additional_dependencies`:
# additional_dependencies: [flake8-bugbear]
22 changes: 22 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF
formats:
- pdf

python:
version: 3.8
install:
- requirements: docs/requirements.txt
2 changes: 1 addition & 1 deletion src/tariochbctools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

try:
# Change here if project is renamed and does not equal the package name
dist_name = "tariochbctools"
dist_name = __name__
__version__ = version(dist_name)
except PackageNotFoundError: # pragma: no cover
__version__ = "unknown"
Expand Down
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
Dummy conftest.py for tariochbctools.
If you don't know what this is for, just leave it empty.
Read more about conftest.py under:
- https://docs.pytest.org/en/stable/fixture.html
- https://docs.pytest.org/en/stable/writing_plugins.html
"""

# import pytest
74 changes: 74 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Tox configuration file
# Read more under https://tox.readthedocs.org/

[tox]
minversion = 3.15
envlist = default


[testenv]
description = invoke pytest to run automated tests
isolated_build = True
setenv =
TOXINIDIR = {toxinidir}
passenv =
HOME
extras =
testing
commands =
pytest {posargs}

[testenv:lint]
description = static code checks
skip_install = True
deps =
flake8
commands =
flake8

[testenv:{clean,build}]
description =
Build (or clean) the package in isolation according to instructions in:
https://setuptools.readthedocs.io/en/latest/build_meta.html#how-to-use-it
https://github.com/pypa/pep517/issues/91
https://github.com/pypa/build
# NOTE: build is still experimental, please refer to the links for updates/issues
skip_install = True
changedir = {toxinidir}
deps =
build: build[virtualenv]
commands =
clean: python -c 'from shutil import rmtree; rmtree("build", True); rmtree("dist", True)'
build: python -m build .
# By default `build` produces wheels, you can also explicitly use the flags `--sdist` and `--wheel`


[testenv:{docs,doctests}]
description = invoke sphinx-build to build the docs/run doctests
setenv =
DOCSDIR = {toxinidir}/docs
BUILDDIR = {toxinidir}/docs/_build
docs: BUILD = html
doctests: BUILD = doctest
deps =
-r {toxinidir}/docs/requirements.txt
# ^ requirements.txt shared with Read The Docs
commands =
sphinx-build -b {env:BUILD} -d "{env:BUILDDIR}/doctrees" "{env:DOCSDIR}" "{env:BUILDDIR}/{env:BUILD}" {posargs}


[testenv:publish]
description =
Publish the package you have been developing to a package index server.
By default, it uses testpypi. If you really want to publish your package
to be publicly accessible in PyPI, use the `-- --repository pypi` option.
skip_install = True
changedir = {toxinidir}
passenv =
TWINE_USERNAME
TWINE_PASSWORD
TWINE_REPOSITORY
deps = twine
commands =
python -m twine check dist/*
python -m twine upload {posargs:--repository testpypi} dist/*

0 comments on commit fcbc9cc

Please sign in to comment.