Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/upgrade tox and ci setup #223

Merged
merged 13 commits into from
Dec 17, 2024
Binary file added .coverage
Binary file not shown.
74 changes: 58 additions & 16 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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

- 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
64 changes: 64 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]" }
]
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",
Expand Down
50 changes: 2 additions & 48 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]",
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",
)
19 changes: 8 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
[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 =
PYTHONPATH = {toxinidir}

allowlist_externals = pytest

commands =
pip install -r requirements-dev.txt
pytest


commands =
python \
-W error::ResourceWarning \
-W error::DeprecationWarning \
-W error::PendingDeprecationWarning \
-m coverage run \
-m pytest {posargs:tests}
Loading