Skip to content

Commit

Permalink
build: switch to hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
15r10nk committed Feb 22, 2024
1 parent 428678a commit e078fb5
Show file tree
Hide file tree
Showing 16 changed files with 152 additions and 151 deletions.
19 changes: 19 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Changes here will be overwritten by Copier
_commit: v0.0.5
_src_path: https://github.com/15r10nk/project-template
full_coverage: true
github_user: 15r10nk
insider_only: false
module_name: inline_snapshot
project_description: golden master/snapshot/approval testing library which puts the values right into your source code
project_main: false
project_name: inline-snapshot
python_versions:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
show_project_logo: true
use_mkdocs: true
24 changes: 16 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
with:
python-version: ${{matrix.python-version}}
architecture: x64
- run: pip install nox==2023.4.22
- run: pip install poetry nox-poetry
- run: nox --session mypy-${{matrix.python-version}}
- run: |
pip install hatch
hatch run +python=${{matrix.python-version}} all:test-mypy
test:
runs-on: ${{matrix.os}}
Expand All @@ -33,16 +33,22 @@ jobs:
with:
python-version: ${{matrix.python-version}}
architecture: x64
- run: pip install nox==2023.4.22
- run: pip install poetry nox-poetry
- run: nox --sessions test-${{matrix.python-version}}

- name: run tests for ${{matrix.python-version}}
env:
TOP: ${{github.workspace}}
COVERAGE_PROCESS_START: ${{github.workspace}}/pyproject.toml
run: |
pip install hatch
hatch run +python=${{matrix.python-version}} all:test-cov
- name: Combine data
env:
TOP: ${{github.workspace}}
COVERAGE_PROCESS_START: ${{github.workspace}}/pyproject.toml
run: |
poetry install
poetry run coverage combine
pip install coverage
coverage combine
mv .coverage .coverage.${{ matrix.python-version }}.${{matrix.os}}
- name: Upload coverage data
Expand Down Expand Up @@ -71,7 +77,9 @@ jobs:
- name: Combine data
env:
TOP: ${{github.workspace}}
COVERAGE_PROCESS_START: ${{github.workspace}}/pyproject.toml
run: |
# i have problems to combine windows coverage files with linux coverage files
rm .coverage.*.windows-latest
rm .coverage.*.macos-latest
pip install coverage
Expand Down
3 changes: 0 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ repos:
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2']
- id: pretty-format-toml
exclude: ^poetry.lock$
args: [--autofix]

- hooks:
- id: commitizen
Expand Down
8 changes: 5 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ Contributions are welcome.
Please create an issue before writing a pull request so we can discuss what needs to be changed.

# Testing
The code can be tested with [nox](https://nox.thea.codes/en/stable/)
The code can be tested with [hatch](https://hatch.pypa.io/latest/)

* `hatch run cov:test` can be used to test all supported python versions and to check for coverage.
* `hatch run +py=3.10 all:test -- --sw` runs pytest for python 3.10 with the `--sw` argument.

* `nox` can be used to test all supported python versions and to check for coverage.
* `nox -e test-3.10 -- --sw` runs pytest for python 3.10 with the `--sw` argument.

# Coverage
This project has a hard coverage requirement of 100%.
Expand All @@ -28,5 +29,6 @@ else:
```
This serves also as an additional check during runtime.


# Commits
Please use [pre-commit](https://pre-commit.com/) for your commits.
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ watch:
- CONTRIBUTING.md
- CHANGELOG.md
- README.md
- inline_snapshot
- src

nav:
- Introduction: index.md
Expand Down
70 changes: 0 additions & 70 deletions noxfile.py

This file was deleted.

177 changes: 111 additions & 66 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,66 @@
[build-system]
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core>=1.0.0"]
build-backend = "hatchling.build"
requires = ["hatchling"]

[project]
authors = [
{name = "Frank Hoffmann", email = "15r10nk@polarbit.de"}
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"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 :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy"
]

dependencies = [
"asttokens >=2.0.5",
"black >=23.3.0",
"click >=8.1.4",
"executing >=2.0.0",
"toml >=0.10.2",
"types-toml >=0.10.8.7"
]
description = "golden master/snapshot/approval testing library which puts the values right into your source code"
keywords = []
license = "MIT"
name = "inline-snapshot"
readme = "README.md"
requires-python = ">=3.7"
version="0.6.1"

[project.entry-points.pytest11]
inline_snapshot = "inline_snapshot.pytest_plugin"


[project.urls]
Documentation = "https://github.com/15r10nk/inline-snapshot#readme"
Source = "https://github.com/15r10nk/inline-snapshot"
Changelog = "https://15r10nk.github.io/inline-snapshot/changelog/"
Discussions = "https://15r10nk.github.io/inline-snapshot/discussions"
Funding = "https://github.com/sponsors/15r10nk"
Homepage = "https://15r10nk.github.io/inline-snapshot"
Issues = "https://github.com/15r10nk/inline-snapshots/issues"
Repository = "https://github.com/15r10nk/inline-snapshot/"

[tool.black]
target-version = ["py38"]

[tool.commitizen]
changelog_incremental = true
major_version_zero = true
tag_format = "v$major.$minor.$patch$prerelease"
update_changelog_on_bump = true
version_files = [
"inline_snapshot/__init__.py:version"
]
version_provider = "poetry"

[tool.coverage.paths]
source = [
"./",
".nox/test-*/lib/python*/site-packages/"
"src/inline_snapshot/__init__.py:version"
]
version_provider = "pep621"

[tool.coverage.report]
exclude_lines = ["pragma: no cover", "assert False", "raise NotImplemented", "\\.\\.\\."]
Expand All @@ -25,63 +69,64 @@ exclude_lines = ["pragma: no cover", "assert False", "raise NotImplemented", "\\
branch = true
data_file = "$TOP/.coverage"
parallel = true
source = [
"tests",
"inline_snapshot",
".nox/test-*/lib/python*/site-packages"
source_pkgs=[
"inline_snapshot",
"tests"
]

[tool.poetry]
authors = ["Frank Hoffmann <15r10nk@polarbit.de>"]
classifiers = [
"Development Status :: 4 - Beta",
"Framework :: Pytest",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Testing",
"Framework :: Pytest"
[tool.hatch.envs.default]
scripts.test = "pytest {args:tests}"
dependencies = [
"black ==23.3.0",
"pytest == 7.4.3",
"pytest-subtests",
"hypothesis"
]
description = "golden master/snapshot/approval testing library which puts the values right into your source code"
keywords = ["pytest", "testing", "snapshot", "approval", "golden-master"]
license = "MIT"
name = "inline-snapshot"
readme = "README.md"
repository = "https://github.com/15r10nk/inline-snapshots"
version = "0.6.1"

[tool.poetry.dependencies]
asttokens = ">=2.0.5"
black = ">=23.3.0"
click = ">=8.1.4"
executing = ">=2.0.0"
python = ">=3.7"
toml = ">=0.10.2"
types-toml = ">=0.10.8.7"

[tool.poetry.group.dev.dependencies]
coverage = ">=7.2.3"
coverage-enable-subprocess = ">=1.0"
hypothesis = ">=6.75.5"
mypy = ">=1.2.0"
pytest = ">=7.1"
pytest-subtests = ">=0.11.0"
pytest-xdist = {extras = ["psutil"], version = ">=3.2.1"}

[tool.poetry.group.doc.dependencies]
mkdocs = ">=1.4.2"
mkdocs-material = {extras = ["imaging"], version = ">=8.5.10"}
mkdocstrings = {extras = ["python-legacy"], version = ">=0.19.0"}

[tool.poetry.plugins.pytest11]
inline_snapshot = "inline_snapshot.pytest_plugin"

[tool.poetry.urls]
Changelog = "https://15r10nk.github.io/inline-snapshot/changelog/"
Discussions = "https://15r10nk.github.io/inline-snapshot/discussions"
Documentation = "https://15r10nk.github.io/inline-snapshot"
Funding = "https://github.com/sponsors/15r10nk"
Homepage = "https://15r10nk.github.io/inline-snapshot"
Issues = "https://github.com/15r10nk/inline-snapshots/issues"
Repository = "https://github.com/15r10nk/inline-snapshot/"
[tool.hatch.envs.all]
dependencies = [
"coverage[toml]>=6.5",
"coverage-enable-subprocess",
"black ==23.3.0",
"pytest == 7.4.3",
"pytest-subtests",
"hypothesis",
"mypy"
]
env-vars.TOP = "{root}"
env-vars.COVERAGE_PROCESS_START = "{root}/pyproject.toml"
scripts.test-cov = "coverage run -m pytest --doctest-modules src/inline_snapshot {args:tests}"
scripts.test-mypy = "mypy src tests"


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

[tool.hatch.envs.cov]
dependencies = ["coverage[toml]>=6.5"]
detached = true
env-vars.TOP = "{root}"
scripts.test = [
"- coverage erase",
"hatch run all:test-cov -- {args}",
"coverage combine",
"coverage html",
"coverage report --fail-under 100 "
]

scripts.one = [
"- coverage erase",
"hatch run +py=3.12 all:test-cov -- {args}",
"coverage combine",
"coverage html",
"coverage report --fail-under 100 "
]


[tool.hatch.envs.docs]
dependencies = [
"mkdocs>=1.4.2",
"mkdocs-material[imaging]>=8.5.10",
"mkdocstrings[python-legacy]>=0.19.0"
]
scripts.serve = ["mkdocs serve {args}"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e078fb5

Please sign in to comment.