Skip to content

Commit

Permalink
Merge pull request #75 from uclahs-cds/nwiltsie-pyproject.toml
Browse files Browse the repository at this point in the history
Migrate package configuration to pyproject.toml, establish dynamic versioning
  • Loading branch information
nwiltsie authored Nov 19, 2024
2 parents df79561 + 10ccf45 commit cb7e4c4
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 66 deletions.
38 changes: 21 additions & 17 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
---
name: pytest
name: Run PyTest

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
pytest:
runs-on: ubuntu-latest

timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python-version:
- "3.8"
- "3.12"

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
- name: Test with pytest
python-version: ${{ matrix.python-version }}

- name: Run tests
run: |
pytest test \
--doctest-modules \
--junitxml=junit/test-results.xml
pip install tox
tox -e py${{matrix.python-version}}
- name: Upload pytest test results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: test-results.xml
name: "pytest-${{ matrix.python-version }}.xml"
path: junit/test-results.xml
if-no-files-found: error
# Use always() to always run this step to publish test results when
# there are test failures
if: ${{ always() }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ build
venv
.env
junit
.tox/
.pytest_cache/
_version.py
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Added
- Add `--report` flag to write out a summary JSON file

### Changed
- Migrate package definition to pyproject.toml

### Fixed
- Properly catch failing test cases

Expand Down
11 changes: 9 additions & 2 deletions nftest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""nftest module"""
"""NFTest module."""

__version__ = "1.1.0"
try:
from nftest._version import version as __version__ # noqa: F401
except ModuleNotFoundError as err:
# The user is probably trying to run this without having installed
# the package, so complain.
raise RuntimeError(
"NFTest is not correctly installed. Please install it with pip."
) from err
51 changes: 47 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,51 @@
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

requires = [
"setuptools>=42",
"wheel"
[project]
name = "nftest"
dynamic = ["version"]
description = "CLI testing tool for Nextflow"
readme = "README.md"
authors = [
{ name = "Chenghao Zhu", email = "[email protected]" }
]
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Operating System :: OS Independent"
]
requires-python = ">=3.8"
dependencies = [
"PyYAML",
"python-dotenv",
"pytest",
"mock"
]

[project.optional-dependencies]
dev = ["pytest", "mock"]

[project.scripts]
nftest = "nftest.__main__:main"

[tool.hatch.metadata]
package-data = { "nftest" = ["data/*"] }

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "nftest/_version.py"

[tool.tox]
legacy_tox_ini = """
[tox]
env_list =
py3.8
py3.12
build-backend = "setuptools.build_meta"
[testenv]
deps = pytest
commands = pytest test --doctest-modules --junitxml=junit/test-results.xml
"""
38 changes: 0 additions & 38 deletions setup.cfg

This file was deleted.

5 changes: 0 additions & 5 deletions setup.py

This file was deleted.

0 comments on commit cb7e4c4

Please sign in to comment.