diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index dfa8472..9fb8509 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -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() }} diff --git a/.gitignore b/.gitignore index b4b1eb0..5a35ec3 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ build venv .env junit +.tox/ +.pytest_cache/ +_version.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d06350..948a80b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/nftest/__init__.py b/nftest/__init__.py index 14bce41..a1fe93e 100644 --- a/nftest/__init__.py +++ b/nftest/__init__.py @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 35ae477..8d031cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = "ChenghaoZhu@mednet.ucla.edu" } ] +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 +""" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 1165a95..0000000 --- a/setup.cfg +++ /dev/null @@ -1,38 +0,0 @@ -[metadata] -# replace with your username: -name = nftest -version = attr: nftest.__version__ -author = 'Chenghao Zhu' -author_email = 'ChenghaoZhu@mednet.ucla.edu' -description = 'CLI testing tool for Nextflow' -long_description = file: README.md -long_description_content_type = text/markdown -url = -project_urls = - Bug Tracker = -classifiers = - Programming Language :: Python :: 3 - License :: OSI Approved :: GNU General Public License (GPL) - Operating System :: OS Independent - -[options] -package_dir = - = . -packages = find: -python_requires = >=3.8 - -install_requires = - PyYAML - python-dotenv - pytest - mock - -[options.packages.find] -where = . - -[options.package_data] -nftest = data/* - -[options.entry_points] -console_scripts = - nftest = nftest.__main__:main diff --git a/setup.py b/setup.py deleted file mode 100644 index 3460076..0000000 --- a/setup.py +++ /dev/null @@ -1,5 +0,0 @@ -"""setup""" - -from setuptools import setup - -setup()