Skip to content

Commit

Permalink
Use hatch scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Cristian Le <[email protected]>
  • Loading branch information
LecrisUT committed May 21, 2024
1 parent 069ca28 commit c9cccb3
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ jobs:
ref: ${{ github.event.inputs.ref }}
if: ${{ github.event_name == 'workflow_dispatch' }}
- name: Build package
run: pipx run build
run: pipx hatch build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
11 changes: 7 additions & 4 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ synced_files:
upstream_package_name: fmf
downstream_package_name: fmf

# Epel9 fails to build with dynamic version. Need to create archive with PKG-INFO
# F37 works with setuptools_scm 7.0
actions:
create-archive:
- make tarball
- "hatch build -t sdist"
- "sh -c 'echo dist/fmf-*.tar.gz'"
get-current-version:
- make version
- "hatch version"

srpm_build_deps:
- make
- python3-docutils
- hatch
- python3-hatch-vcs

jobs:
- job: copr_build
Expand Down
18 changes: 8 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@ tmp:

# Run the test suite, optionally with coverage
test: tmp
pytest tests/unit
hatch run test:unit
smoke: tmp
pytest tests/unit/test_smoke.py
hatch run test:smoke
coverage: tmp
coverage run --source=fmf -m py.test tests
coverage report
coverage annotate
hatch run cov:cov


# Build documentation, prepare man page
docs: man
cd docs && make html
hatch run docs:html
man:
cp docs/header.txt $(TMP)/man.rst
tail -n+7 README.rst >> $(TMP)/man.rst
Expand All @@ -37,7 +35,7 @@ man:

# RPM packaging
tarball: man
python3 -m build --sdist
hatch build -t sdist
rpm: tarball
rpmbuild --define '_topdir $(TMP)' -bb fmf.spec
srpm: tarball
Expand All @@ -47,9 +45,9 @@ packages: rpm srpm

# Python packaging
wheel:
python3 -m build
upload: wheel tarball
twine upload dist/*
hatch build
upload:
hatch publish


# Vim tags and cleanup
Expand Down
40 changes: 40 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,46 @@ fmf = 'fmf.cli:cli_entry'
[tool.hatch.build.targets.wheel]
packages = ['fmf']

[tool.hatch.envs.default]
platforms = ["linux"]

[tool.hatch.envs.cov]
description = "Test coverage environment"
features = ["tests-cov"]

[tool.hatch.envs.cov.scripts]
xml = ["pytest --cov --cov-report=xml"]
cov = [
"coverage run -m pytest -vvv -ra --showlocals tests",
"coverage report",
"coverage annotate",
]

[tool.hatch.envs.dev]
description = "Development environment"
features = ["dev"]

[tool.hatch.envs.dev.scripts]
type = ["mypy {args:tmt}"]
check = ["lint", "type"]

unit = "pytest -vvv -ra --showlocals tests/unit"
smoke = "pytest -vvv -ra --showlocals tests/unit/test_cli.py"

[tool.hatch.envs.test]
template = "dev"
description = "Run scripts with multiple Python versions"
features = ["tests"]

[[tool.hatch.envs.test.matrix]]
python = ["3.9", "3.11", "3.12"]

[tool.hatch.envs.docs]
features = ["docs"]

[tool.hatch.envs.docs.scripts]
html = "sphinx-build -b html {root}/docs {root}/docs/_build {args}"

[tool.pytest.ini_options]
markers = [
"web: tests which need to access the web",
Expand Down

0 comments on commit c9cccb3

Please sign in to comment.