From 006feaaae715172ebde4beac65b961d0352686ee Mon Sep 17 00:00:00 2001 From: Rogdham Date: Sun, 11 Oct 2026 11:17:28 +0200 Subject: [PATCH] chore: refactor build pipeline --- .github/workflows/build.yml | 130 +++++++++++++++++++++++++------ .gitignore | 1 - .vscode/settings.json | 3 +- CHANGELOG.md | 1 + README.md | 2 +- dev-requirements.txt | 18 ----- pyproject.toml | 13 ++-- requirements-dev.txt | 6 ++ requirements-docs.txt | 1 + requirements-lint.txt | 1 + requirements-test.txt | 2 + requirements-type.txt | 1 + stubs/defusedxml/ElementTree.pyi | 5 +- tox.ini | 49 ------------ 14 files changed, 130 insertions(+), 103 deletions(-) delete mode 100644 dev-requirements.txt create mode 100644 requirements-dev.txt create mode 100644 requirements-docs.txt create mode 100644 requirements-lint.txt create mode 100644 requirements-test.txt create mode 100644 requirements-type.txt delete mode 100644 tox.ini diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb2f849..9ca0480 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,7 @@ on: tags: - "**" pull_request: + workflow_dispatch: permissions: {} @@ -15,8 +16,42 @@ env: PY_COLORS: 1 jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + # fetch all commits for version computation + fetch-depth: 0 + persist-credentials: false + - name: Setup Python + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: "3.15" + - name: Install dependencies + run: python -m pip install -U build + - name: Build + run: python -m build + - name: List distributions + run: ls -lR dist + - name: Save build artifacts + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: build + path: dist + - name: Install sdist + run: python -m pip install dist/*.tar.gz + - name: Install dependencies + run: python -m pip install -r requirements-test.txt + - name: Test + run: pytest -vv + tests-py: + name: Test | ${{ matrix.python }} runs-on: ubuntu-latest + needs: + - build strategy: matrix: python: @@ -31,52 +66,101 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - submodules: true + - name: Restore build artifacts + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: build + path: dist - name: Setup Python ${{ matrix.python }} uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: ${{ matrix.python }} + - name: Install wheel + run: python -m pip install dist/*.whl - name: Install dependencies - run: pip install tox - - name: Run tests - run: tox run -e py + run: python -m pip install -r requirements-test.txt + - name: Test + run: pytest -vv - tests-misc: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Setup Python + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: "3.15" + - name: Install dependencies + run: python -m pip install -r requirements-lint.txt + - name: ruff check + run: ruff check + - name: ruff format + run: ruff format --check + + type: + name: Type + runs-on: ubuntu-latest + needs: + - build + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Restore build artifacts + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: build + path: dist + - name: Setup Python + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: "3.15" + - name: Install dependencies + run: python -m pip install -r requirements-type.txt + - name: Create _version.py + run: echo '__version__ = ""' > src/bigxml/_version.py + - name: mypy + run: mypy + - name: Install wheel + run: python -m pip install dist/*.whl + - name: Install dependencies + run: python -m pip install -r requirements-test.txt + - name: mypy tests + run: mypy --namespace-packages --explicit-package-bases tests + + docs: + name: Docs runs-on: ubuntu-latest - strategy: - matrix: - env: - - build - - docs - - lint - - type steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - # build env: fetch all commits for version computation - fetch-depth: ${{ matrix.env == 'build' && '0' || '1' }} persist-credentials: false - submodules: true - name: Setup Python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: "3.15" - name: Install dependencies - run: pip install tox - - name: Run ${{ matrix.env }} - run: tox run -e ${{ matrix.env }} - - if: ${{ matrix.env == 'build' || matrix.env == 'docs' }} - name: Save ${{ matrix.env }} artifacts + run: python -m pip install -r requirements-docs.txt + - name: mkdocs + run: mkdocs build -f docs/mkdocs.yml + - name: Save docs artifacts uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: - name: ${{ matrix.env }} + name: docs path: dist publish: + name: Publish to PyPI if: startsWith(github.ref, 'refs/tags') needs: + - build + - docs + - lint - tests-py - - tests-misc + - type runs-on: ubuntu-latest environment: publish permissions: @@ -87,6 +171,8 @@ jobs: with: name: build path: dist + - name: List distributions + run: ls -lR dist - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 with: diff --git a/.gitignore b/.gitignore index e3896bf..5fe00f6 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,3 @@ __pycache__ /.coverage /coverage /.pytest_cache -/.tox diff --git a/.vscode/settings.json b/.vscode/settings.json index e5afaaa..7dd6878 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,8 +7,7 @@ ".coverage": true, ".mypy_cache": true, ".pytest_cache": true, - ".ruff_cache": true, - ".tox": true + ".ruff_cache": true }, "editor.detectIndentation": false, "editor.formatOnSave": true, diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c96d91..e1ca7bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ For the purpose of determining breaking changes: - Add tests for CPython 3.15 and PyPy 3.12 - Use CPython 3.15 for misc. tests - Update dev dependencies +- Refactor CI pipeline ## [1.2.0] - 2025-11-06 diff --git a/README.md b/README.md index 6c4bc1b..c707f0b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Parse big xml files and streams with ease [![GitHub build status](https://img.shields.io/github/actions/workflow/status/rogdham/bigxml/build.yml?branch=master)](https://github.com/rogdham/bigxml/actions?query=branch:master) [![Release on PyPI](https://img.shields.io/pypi/v/bigxml)](https://pypi.org/project/bigxml/) -[![Code coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/rogdham/bigxml/search?q=fail+under&type=Code) +[![Code coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/search?q=repo%3ARogdham%2Fbigxml+fail_under&type=code) [![Mypy type checker](https://img.shields.io/badge/type_checker-mypy-informational)](https://mypy.readthedocs.io/) [![MIT License](https://img.shields.io/pypi/l/bigxml)](https://github.com/Rogdham/bigxml/blob/master/LICENSE.txt) diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index f930e21..0000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,18 +0,0 @@ -# install + dependencies --e . - -# build -build==1.6.1 - -# docs -mkdocs==1.6.1 - -# lint -ruff==0.16.10 - -# tests -pytest==9.1.1 -pytest-cov==7.1.0 - -# type -mypy==2.4.0 diff --git a/pyproject.toml b/pyproject.toml index 8e0e646..1699ed1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,11 +52,7 @@ source = "vcs" directory = "coverage" [tool.coverage.paths] -source = [ - "src/bigxml/", - ".tox/py*/lib/python*/site-packages/bigxml/", - ".tox/py*/site-packages/bigxml/", -] +source = ["src/bigxml/"] [tool.coverage.report] exclude_lines = [ @@ -67,6 +63,7 @@ exclude_lines = [ "@overload", "if TYPE_CHECKING:", ] +fail_under = 100 show_missing = true [tool.coverage.run] @@ -122,7 +119,9 @@ warn_unused_configs = true [tool.pytest.ini_options] addopts = """ - --cov + --cov + --cov-report=html + --cov-report=term-missing --doctest-glob='*.md' --doctest-modules --strict-markers """ @@ -137,7 +136,7 @@ testpaths = ["docs", "tests"] # [tool.ruff] -src = ["src"] +src = ["src", "tests"] target-version = "py311" [tool.ruff.lint] diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..3a46f66 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,6 @@ +-e . + +-r requirements-docs.txt +-r requirements-lint.txt +-r requirements-tests.txt +-r requirements-type.txt diff --git a/requirements-docs.txt b/requirements-docs.txt new file mode 100644 index 0000000..f2caded --- /dev/null +++ b/requirements-docs.txt @@ -0,0 +1 @@ +mkdocs==1.6.1 diff --git a/requirements-lint.txt b/requirements-lint.txt new file mode 100644 index 0000000..4e55a01 --- /dev/null +++ b/requirements-lint.txt @@ -0,0 +1 @@ +ruff==0.16.10 diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 0000000..cb34cb8 --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,2 @@ +pytest==9.1.1 +pytest-cov==7.1.0 diff --git a/requirements-type.txt b/requirements-type.txt new file mode 100644 index 0000000..f5d9ba5 --- /dev/null +++ b/requirements-type.txt @@ -0,0 +1 @@ +mypy==2.4.0 diff --git a/stubs/defusedxml/ElementTree.pyi b/stubs/defusedxml/ElementTree.pyi index d6b250e..6895572 100644 --- a/stubs/defusedxml/ElementTree.pyi +++ b/stubs/defusedxml/ElementTree.pyi @@ -1,14 +1,13 @@ -# ruff: noqa: FBT001 # note: only used items are defined here, with used typing from collections.abc import Iterator, Sequence -from typing import Optional, Protocol, TypeVar +from typing import Protocol, TypeVar from xml.etree.ElementTree import Element, ParseError _T_co = TypeVar("_T_co", covariant=True) class _SupportsRead(Protocol[_T_co]): - def read(self, size: Optional[int] = None) -> _T_co: ... + def read(self, size: int | None = None) -> _T_co: ... def iterparse( source: _SupportsRead[bytes], diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 7780b99..0000000 --- a/tox.ini +++ /dev/null @@ -1,49 +0,0 @@ -# for moving this file into pyproject.toml, see https://github.com/tox-dev/tox/issues/999 - -[tox] -envlist = - py, py311, py312, py313, py314, py315, pypy3 - build, docs, lint, type - -[testenv] -package = wheel -wheel_build_env = .pkg # reuse same wheel across envs -deps = - pytest==9.1.1 - pytest-cov==7.1.0 -passenv = PY_COLORS -setenv = - COVERAGE_FILE = {toxworkdir}/{envname}/.coverage - PYTHONDEVMODE = 1 -commands = - pytest {posargs:-vv --cov-fail-under=100} - py: -coverage html - -[testenv:build] -skip_install = true -deps = - build==1.6.1 -commands = - python -m build - -[testenv:docs] -skip_install = true -deps = - mkdocs==1.6.1 -commands = - mkdocs {posargs:build} -f docs/mkdocs.yml - -[testenv:lint] -deps = - ruff==0.16.10 -commands = - ruff check src docs tests - ruff format --check src docs tests - -[testenv:type] -deps = - mypy==2.4.0 - pytest==9.1.1 # for typing -commands = - mypy - mypy --explicit-package-bases docs tests