Skip to content

Commit

Permalink
Improve hatch scripts and tox commands
Browse files Browse the repository at this point in the history
  • Loading branch information
xymy committed Nov 25, 2023
1 parent a179bbf commit 537e441
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Adopted more `ruff` rules.

### Testing

- Improved tox config.
- Now store `hypothesis` and `pytest` cache in `.cache` directory.

## [6.0] - 2023-11-19

### Added
Expand Down
16 changes: 14 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,26 @@ Tracker = "https://github.com/xymy/gethash/issues"
path = "src/gethash/__init__.py"

[tool.hatch.envs.default]
type = "virtual"
path = ".venv"
system-packages = true
features = ["all", "docs", "lint", "test"]

[tool.hatch.envs.default.env-vars]
COVERAGE_FILE = "{root}{/}.coverage"
HYPOTHESIS_STORAGE_DIRECTORY = "{root}{/}.cache{/}hypothesis"

[tool.hatch.envs.default.scripts]
test = ["coverage erase", "python -m pytest {args}", "coverage report"]
docs = "python {root}{/}docs{/}release.py {args}"
lint = [
"black {root}{/}src {root}{/}tests",
"ruff {root}{/}src {root}{/}tests",
"mypy {root}{/}src {root}{/}tests",
]
test = [
"coverage erase",
"python -m pytest -o cache_dir={root}{/}.cache{/}pytest --cov-report=html:{root}{/}htmlcov {args}",
"coverage report",
]

[tool.black]
line-length = 120
Expand Down
18 changes: 15 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,27 @@ package = wheel
wheel_build_env = .pkg

[testenv:py3{9,10,11,12}]
pass_env =
PYTEST_*
set_env =
COVERAGE_FILE = {env:COVERAGE_FILE:{envdir}{/}.coverage}
COVERAGE_FILE = {envdir}{/}.coverage
HYPOTHESIS_STORAGE_DIRECTORY = {envdir}{/}.cache{/}hypothesis
extras =
test
commands =
coverage erase
python -m pytest -v --cov-report=html:{envdir}{/}htmlcov {posargs}
python -m pytest -v -o cache_dir={envdir}{/}.cache{/}pytest \
--cov-report=html:{envdir}{/}htmlcov {posargs}
coverage report

[testenv:lint]
extras =
lint
commands =
black {toxinidir}{/}src {toxinidir}{/}tests
ruff --cache-dir={envdir}{/}.cache{/}ruff {toxinidir}{/}src {toxinidir}{/}tests
mypy --cache-dir={envdir}{/}.cache{/}mypy {toxinidir}{/}src {toxinidir}{/}tests

[testenv:docs]
extras =
docs
Expand All @@ -37,7 +49,7 @@ package = editable
system_site_packages = true

[pytest]
addopts = --strict-markers --cov --cov-context=test --cov-report=html
addopts = --strict-markers --cov --cov-context=test
filterwarnings =
error
ignore::DeprecationWarning
Expand Down

0 comments on commit 537e441

Please sign in to comment.