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 Jun 17, 2024
1 parent 6deb93d commit 04e6216
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 19 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
45 changes: 41 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ Homepage = 'https://github.com/teemtee/fmf'
Documentation = 'https://fmf.readthedocs.io'

[project.optional-dependencies]
tests-cov = [
'fmf[tests]',
'pytest-cov',
]
# Needed for tests inside rpm build. Not being pacakged in rpm
tests = [
'pytest',
Expand All @@ -56,6 +52,47 @@ docs = [
[project.scripts]
fmf = 'fmf.cli:cli_entry'

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

[tool.hatch.envs.dev]
description = "Development environment"
dependencies = [
"pytest-cov"
]
features = ["tests"]

[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"

cov = [
"coverage run --source=fmf -m pytest -vvv -ra --showlocals tests",
"coverage report",
"coverage annotate",
]

[tool.hatch.envs.dev-not-editable]
template = "dev"
description = "Same as 'dev', but not using editable install"
dev-mode = false

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

[[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 04e6216

Please sign in to comment.