From 142bd4a6082988cc4a61ed7ea4f849fcfb0ee405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jim=20Br=C3=A4nnlund?= Date: Sun, 2 Apr 2023 21:18:21 +0200 Subject: [PATCH] chore: Migrate from Poetry to Hatch (#617) --- .github/workflows/actions.yml | 105 ----------------------------- .github/workflows/nightly.yml | 10 --- .github/workflows/publish.yml | 42 ++++++++++++ .github/workflows/tests.yml | 55 ++++++++++++++- .gitignore | 2 + Gruntfile.js | 9 --- pyproject.toml | 122 ++++++++++++++++++++-------------- setup.cfg | 2 - setup.py | 39 ----------- 9 files changed, 169 insertions(+), 217 deletions(-) delete mode 100644 .github/workflows/actions.yml delete mode 100644 .github/workflows/nightly.yml create mode 100644 .github/workflows/publish.yml delete mode 100644 Gruntfile.js delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml deleted file mode 100644 index dc832bc..0000000 --- a/.github/workflows/actions.yml +++ /dev/null @@ -1,105 +0,0 @@ -name: Main - -on: - create: # is used for publishing to PyPI and TestPyPI - tags: # any tag regardless of its name, no branches - push: # only publishes pushes to the main branch to TestPyPI - branches: # any maintenance branch but not tag - # avoid generic ** as it duplicates builds from temporary branches - - "master" - - "stable/**" - tags-ignore: - - >- - ** - pull_request: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build_docs: - name: Build Docs - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: Install tox - run: python -m pip install --upgrade tox - - name: Build docs with tox - run: tox -e docs - - tests: - uses: ./.github/workflows/tests.yml - - publish: - if: github.repository_owner == 'pytest-dev' - name: Publish to PyPI registry - needs: - - tests - runs-on: ubuntu-latest - env: - PY_COLORS: 1 - steps: - - name: Set up python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - - name: Check out src from Git - uses: actions/checkout@v3 - with: - # Get shallow Git history (default) for tag creation events - # but have a complete clone for any other workflows. - # Both options fetch tags but since we're going to remove - # one from HEAD in non-create-tag workflows, we need full - # history for them. - fetch-depth: >- - ${{ - ( - github.event_name == 'create' && - github.event.ref_type == 'tag' - ) && - 1 || 0 - }} - - - name: Drop Git tags from HEAD for non-tag-create events - if: >- - github.event_name != 'create' || - github.event.ref_type != 'tag' - run: git tag --points-at HEAD | xargs git tag --delete - - - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v1 - - - name: Download Package - uses: actions/download-artifact@v3 - with: - name: Packages - path: dist - - - name: Publish to test.pypi.org - if: >- - ( - github.event_name == 'push' && - github.ref == format('refs/heads/{0}', github.event.repository.default_branch) - ) || - ( - github.event_name == 'create' && - github.event.ref_type == 'tag' - ) - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.testpypi_password }} - repository_url: https://test.pypi.org/legacy/ - - - name: Publish to pypi.org - if: >- # "create" workflows run separately from "push" & "pull_request" - github.event_name == 'create' && - github.event.ref_type == 'tag' - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.pypi_password }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml deleted file mode 100644 index 252aa36..0000000 --- a/.github/workflows/nightly.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: Nightly tests - -on: - schedule: - - cron: '1 0 * * *' # Run daily at 0:01 UTC - -jobs: - tests: - if: github.repository_owner == 'pytest-dev' - uses: ./.github/workflows/tests.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..03c35a0 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,42 @@ +name: Publish + +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" + - "[0-9]+.[0-9]+.[0-9]+rc[0-9]+" + +jobs: + publish: + if: github.repository == 'pytest-dev/pytest-html' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '16.x' + + - name: Install dependencies + run: npm ci + + - name: Build app.js + run: npm run build:ci + + - name: Build and Check Package + uses: hynek/build-and-inspect-python-package@v1 + + - name: Download Package + uses: actions/download-artifact@v3 + with: + name: Packages + path: dist + + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.pypi_password }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d4b4b3c..0f65508 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,11 +1,62 @@ name: Tests on: - workflow_call: + push: + branches: + - master + + schedule: + - cron: '1 0 * * *' # Run daily at 0:01 UTC + + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: + build_docs: + name: Build Docs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install tox + run: python -m pip install --upgrade tox + + - name: Build docs with tox + run: tox -e docs + + build_package: + name: Build Package + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '16.x' + + - name: Install dependencies + run: npm ci + + - name: Build app.js + run: npm run build:ci + + - name: Build and Check Package + uses: hynek/build-and-inspect-python-package@v1 + test_javascript: - name: javascript + name: Run javascript unit tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.gitignore b/.gitignore index d95b913..223cb04 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,5 @@ docs/_build/ assets/ .nyc_output + +.venv/ diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index 19e5cf8..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = function(grunt) { - grunt.initConfig({ - qunit: { - src: 'testing/js_test_report.html' - } - }); - grunt.loadNpmTasks('grunt-contrib-qunit'); - grunt.registerTask('test', 'qunit:src'); -}; diff --git a/pyproject.toml b/pyproject.toml index 2579286..ed4a068 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,65 +1,87 @@ [build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" +build-backend = "hatchling.build" +requires = [ + "hatch-vcs>=0.3", + "hatchling>=1.13", +] -[tool.poetry] +[project] name = "pytest-html" description = "pytest plugin for generating HTML reports" -version = "4.0.0-rc0" -license = "MPL-2.0" -authors = [ - "Dave Hunt ", - "Jim Brannlund " -] readme = "README.rst" -homepage = "https://github.com/pytest-dev/pytest-html" -repository = "https://github.com/pytest-dev/pytest-html" +license = "MPL-2.0" +requires-python = ">=3.7" keywords = [ - "pytest", - "html", - "report", + "pytest", + "html", + "report", +] +authors = [ + { name = "Dave Hunt", email = "dhunt@mozilla.com" }, + { name = "Jim Brannlund", email = "jimbrannlund@fastmail.com" }, ] classifiers = [ - "Development Status :: 5 - Production/Stable", - "Framework :: Pytest", - "Intended Audience :: Developers", - "Operating System :: POSIX", - "Operating System :: Microsoft :: Windows", - "Operating System :: MacOS :: MacOS X", - "Topic :: Software Development :: Quality Assurance", - "Topic :: Software Development :: Testing", - "Topic :: Utilities", + "Development Status :: 5 - Production/Stable", + "Framework :: Pytest", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Operating System :: POSIX", + "Operating System :: Microsoft :: Windows", + "Operating System :: MacOS :: MacOS X", + "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 :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Software Development :: Quality Assurance", + "Topic :: Software Development :: Testing", + "Topic :: Utilities", ] -packages = [ - { include = "pytest_html", from = "src" }, +dependencies = [ + "pytest>=7.0.0", + "pytest-metadata>=2.0.2", + "Jinja2>=3.0.0", ] -include = [ - { path = "testing", format = "sdist" }, - { path = "docs", format = "sdist" }, - "src/pytest_html/resources", - "src/pytest_html/resources/app.js", +dynamic = [ + "version", ] -[tool.poetry.dependencies] -python = ">=3.7" -pytest = ">=7.0.0" -pytest-metadata = ">=2.0.2" -Jinja2 = ">=3.0.0" +[project.optional-dependencies] +test = [ + "assertpy>=1.1", + "beautifulsoup4>=4.11.1", + "black>=22.1.0", + "flake8>=4.0.1", + "pre-commit>=2.17.0", + "pytest-xdist>=2.4.0", + "pytest-mock>=3.7.0", + "selenium>=4.3.0", + "tox>=3.24.5", +] -[tool.poetry.dev-dependencies] -assertpy = ">=1.1" -beautifulsoup4 = ">=4.11.1" -black = ">=22.1.0" -flake8 = ">=4.0.1" -pre-commit = ">=2.17.0" -pytest-xdist = ">=2.4.0" -pytest-mock = ">=3.7.0" -selenium = ">=4.3.0" -tox = ">=3.24.5" +[project.urls] +Homepage = "https://github.com/pytest-dev/pytest-html" +Tracker = "https://github.com/pytest-dev/pytest-html/issues" +Source = "https://github.com/pytest-dev/pytest-html" -[tool.poetry.plugins.pytest11] -html = "pytest_html.plugin" +[project.entry-points.pytest11] +env = "pytest_html.plugin" -[tool.setuptools_scm] -local_scheme = "no-local-version" -write_to = "src/pytest_html/__version.py" +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.targets.wheel] +exclude = [ + "src/pytest_html/scripts/*", +] + +[tool.hatch.build.targets.sdist] +exclude = [ + "/.github", +] + +[tool.hatch.build.hooks.vcs] +version-file = "src/pytest_html/__version.py" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 526aeb2..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[bdist_wheel] -universal = 0 diff --git a/setup.py b/setup.py deleted file mode 100644 index dd2d6e5..0000000 --- a/setup.py +++ /dev/null @@ -1,39 +0,0 @@ -from setuptools import setup - -setup( - name="pytest-html", - use_scm_version={"local_scheme": "no-local-version"}, - description="pytest plugin for generating HTML reports", - long_description=open("README.rst").read(), - author="Dave Hunt", - author_email="dhunt@mozilla.com", - url="https://github.com/pytest-dev/pytest-html", - package_dir={"": "src"}, - packages=["pytest_html"], - package_data={"pytest_html": ["resources/*", "scripts/*"]}, - entry_points={"pytest11": ["html = pytest_html.plugin"]}, - setup_requires=["setuptools_scm"], - install_requires=["pytest>=5.0,!=6.0.0", "pytest-metadata", "jinja2>=3.0,<4.0"], - license="Mozilla Public License 2.0 (MPL 2.0)", - keywords="py.test pytest html report", - python_requires=">=3.6", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Framework :: Pytest", - "Intended Audience :: Developers", - "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)", - "Operating System :: POSIX", - "Operating System :: Microsoft :: Windows", - "Operating System :: MacOS :: MacOS X", - "Topic :: Software Development :: Quality Assurance", - "Topic :: Software Development :: Testing", - "Topic :: Utilities", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3 :: Only", - ], -)