diff --git a/.coverage b/.coverage new file mode 100644 index 0000000..be1aa30 Binary files /dev/null and b/.coverage differ diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 4477245..ad73886 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -30,26 +30,68 @@ jobs: os: macos-latest steps: - - uses: actions/checkout@v4.1.7 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5.2.0 with: python-version: ${{ matrix.python-version }} allow-prereleases: true - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install --upgrade -r requirements-dev.txt - pip install . - - name: Test with pytest - run: | - pytest --cov --junitxml=junit.xml - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 + - name: install uv + uses: astral-sh/setup-uv@v3 with: - token: ${{ secrets.CODECOV_TOKEN }} - - name: Upload test results to Codecov - if: ${{ !cancelled() }} - uses: codecov/test-results-action@v1 + enable-cache: true + cache-dependency-glob: requirements-dev.txt + + - name: Install dependencies + run: uv pip install --system tox tox-uv + + - name: Run tox targets for ${{ matrix.python-version }} + run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d .) + + - name: Upload coverage data + uses: actions/upload-artifact@v4 with: - token: ${{ secrets.CODECOV_TOKEN }} + name: coverage-data-${{ matrix.python-version }} + path: '${{ github.workspace }}/.coverage.*' + include-hidden-files: true + if-no-files-found: error + + + coverage: + name: Coverage + runs-on: ubuntu-24.04 + needs: build + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install uv + uses: astral-sh/setup-uv@v3 + + - name: Install dependencies + run: uv pip install --system coverage[toml] + + - name: Download data + uses: actions/download-artifact@v4 + with: + path: ${{ github.workspace }} + pattern: coverage-data-* + merge-multiple: true + + - name: Combine coverage and fail if it's <100% + run: | + python -m coverage combine + python -m coverage html --skip-covered --skip-empty + python -m coverage report --fail-under=90 + echo "## Coverage summary" >> $GITHUB_STEP_SUMMARY + python -m coverage report --format=markdown >> $GITHUB_STEP_SUMMARY + + - name: Upload HTML report + if: ${{ failure() }} + uses: actions/upload-artifact@v4 + with: + name: html-report + path: htmlcov diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..bd7afd0 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,64 @@ +ci: + autofix_commit_msg: | + ci: auto fixes from pre-commit hooks + + for more information, see https://pre-commit.ci + autofix_prs: true + autoupdate_commit_msg: 'ci: pre-commit autoupdate' + autoupdate_schedule: monthly + +default_language_version: + python: python3.12 + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-json + - id: check-merge-conflict + - id: check-symlinks + - id: check-toml + - id: end-of-file-fixer + - id: trailing-whitespace +- repo: https://github.com/tox-dev/pyproject-fmt + rev: v2.5.0 + hooks: + - id: pyproject-fmt +- repo: https://github.com/tox-dev/tox-ini-fmt + rev: 1.4.1 + hooks: + - id: tox-ini-fmt +- repo: https://github.com/rstcheck/rstcheck + rev: v6.2.4 + hooks: + - id: rstcheck + additional_dependencies: + - tomli==2.0.1 +- repo: https://github.com/asottile/pyupgrade + rev: v3.19.0 + hooks: + - id: pyupgrade + args: [--py38-plus] +- repo: https://github.com/psf/black-pre-commit-mirror + rev: 24.10.0 + hooks: + - id: black +- repo: https://github.com/adamchainz/blacken-docs + rev: 1.19.1 + hooks: + - id: blacken-docs + additional_dependencies: + - black==23.1.0 +- repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort + name: isort (python) +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.13.0 + hooks: + - id: mypy + additional_dependencies: + - django-stubs==5.0.4 diff --git a/pyproject.toml b/pyproject.toml index 9434ded..4f4dc6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,56 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "json2xml" +version = "5.0.5" # Replace with the dynamic version if needed +description = "Simple Python Library to convert JSON to XML" +readme = "README.rst" +requires-python = ">=3.10" +license = { text = "Apache Software License 2.0" } +keywords = ["json2xml"] +authors = [ + { name = "Vinit Kumar", email = "mail@vinitkumar.me" } +] +classifiers = [ + "Development Status :: 6 - Mature", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Natural Language :: English", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Software Development :: Libraries :: Python Modules" +] +dependencies = [ + "defusedxml", + "urllib3", + "xmltodict>=0.12.0", + "pytest", + "pytest-cov", + "coverage", + "py", + "setuptools", +] + +[project.urls] +Homepage = "https://github.com/vinitkumar/json2xml" + +[tool.setuptools.packages.find] +include = ["json2xml"] + +[project.optional-dependencies] +test = [ + "pytest==7.0.1", + "py==1.11.0" +] + +[tool.pytest.ini_options] +testpaths = ["tests"] [tool.ruff] exclude = [ ".env", diff --git a/setup.py b/setup.py index e986ed2..56db080 100644 --- a/setup.py +++ b/setup.py @@ -2,52 +2,6 @@ """The setup script.""" -from setuptools import setup, find_packages -from json2xml import __version__ +from setuptools import setup +setup() -with open("README.rst", encoding="utf-8") as readme_file: - readme = readme_file.read() - -with open("HISTORY.rst", encoding="utf-8") as history_file: - history = history_file.read() - -with open("requirements.in", encoding="utf-8") as requirements_in: - requirements = [requirements_in.read()] - -setup_requirements = [] - -test_requirements = ["pytest==7.0.1", "py==1.11.0"] - -setup( - author="Vinit Kumar", - author_email="mail@vinitkumar.me", - classifiers=[ - "Development Status :: 6 - Mature", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Natural Language :: English", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - "Topic :: Software Development :: Libraries :: Python Modules", - ], - description="Simple Python Library to convert JSON to XML", - install_requires=requirements, - license="Apache Software License 2.0", - long_description=readme + "\n\n" + history, - long_description_content_type="text/x-rst", - include_package_data=True, - keywords="json2xml", - name="json2xml", - packages=find_packages(include=["json2xml"]), - setup_requires=setup_requirements, - test_suite="tests", - tests_require=test_requirements, - url="https://github.com/vinitkumar/json2xml", - version=__version__, - zip_safe=False, - python_requires=">=3.10", -) diff --git a/tox.ini b/tox.ini index 0d5027e..e726689 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,5 @@ [tox] -envlist = py38, py39, py310, py311, py312, pypy38, pypy39 - - -[testenv:flake8] -basepython = python -deps = flake8 -commands = flake8 json2xml +envlist = py310, py311, py312, py313, py314, pypy310 [testenv] setenv = @@ -13,8 +7,12 @@ setenv = allowlist_externals = pytest -commands = - pip install -r requirements-dev.txt - pytest - +; pytest +commands = + python \ + -W error::ResourceWarning \ + -W error::DeprecationWarning \ + -W error::PendingDeprecationWarning \ + -m coverage run \ + -m pytest {posargs:tests}