From 835512ee27e7708937708ca29a8679d139af78e4 Mon Sep 17 00:00:00 2001 From: Rogdham Date: Sun, 11 Oct 2026 10:46:30 +0200 Subject: [PATCH] chore: refactor build pipeline --- .github/workflows/build.yml | 113 ++++++++++++++++++++++++++++-------- .gitignore | 1 - .vscode/settings.json | 3 +- CHANGELOG.md | 1 + README.md | 2 +- dev-requirements.txt | 15 ----- pyproject.toml | 11 ++-- requirements-dev.txt | 5 ++ requirements-lint.txt | 1 + requirements-test.txt | 2 + requirements-type.txt | 1 + tox.ini | 52 ----------------- 12 files changed, 107 insertions(+), 100 deletions(-) delete mode 100644 dev-requirements.txt create mode 100644 requirements-dev.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 6649699..085ef31 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,45 @@ 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 + - name: Test integration files generation + run: + pytest -vv -m generate_integration_files --generate-integration-files --no-cov + tests-py: + name: Test | ${{ matrix.python }} runs-on: ubuntu-latest + needs: + - build strategy: matrix: python: @@ -31,52 +69,79 @@ 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 - strategy: - matrix: - env: - - build - - generate-integration-files - - 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' }} - name: Save ${{ matrix.env }} artifacts - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + 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: ${{ matrix.env }} + 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/xz/_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 publish: + name: Publish to PyPI if: startsWith(github.ref, 'refs/tags') needs: + - build + - lint - tests-py - - tests-misc + - type runs-on: ubuntu-latest environment: publish permissions: @@ -87,6 +152,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 a7e8a4e..cc8d808 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,5 @@ __pycache__ /.coverage /coverage /.pytest_cache -/.tox /src/xz/_version.py diff --git a/.vscode/settings.json b/.vscode/settings.json index da33dbd..3234353 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 96188ee..4f0daf9 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 - Update dev dependencies - Necessary code changes following dev dependency update: mypy, ruff +- Refactor CI pipeline ## [0.6.0] - 2025-10-18 diff --git a/README.md b/README.md index f9e2146..830dc72 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ _Leveraging the lzma module for fast (de)compression_ [![GitHub build status](https://img.shields.io/github/actions/workflow/status/rogdham/python-xz/build.yml?branch=master)](https://github.com/rogdham/python-xz/actions?query=branch:master) [![Release on PyPI](https://img.shields.io/pypi/v/python-xz)](https://pypi.org/project/python-xz/) -[![Code coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/rogdham/python-xz/search?q=fail+under&type=Code) +[![Code coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/search?q=repo%3ARogdham%2Fpython-xz+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/python-xz)](https://github.com/Rogdham/python-xz/blob/master/LICENSE.txt) diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index 70fda70..0000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,15 +0,0 @@ -# install + dependencies --e . - -# build -build==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 81f201b..55a69f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,11 +55,7 @@ source = "vcs" directory = "coverage" [tool.coverage.paths] -source = [ - "src/xz/", - ".tox/py*/lib/python*/site-packages/xz/", - ".tox/py*/site-packages/xz/", -] +source = ["src/xz/"] [tool.coverage.report] exclude_lines = [ @@ -70,6 +66,7 @@ exclude_lines = [ "@overload", "if TYPE_CHECKING:", ] +fail_under = 100 show_missing = true [tool.coverage.run] @@ -125,6 +122,8 @@ warn_unused_configs = true [tool.pytest.ini_options] addopts = """ --cov + --cov-report=html + --cov-report=term-missing --strict-markers """ filterwarnings = ["error"] @@ -137,7 +136,7 @@ testpaths = ["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..d7bfac7 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,5 @@ +-e . + +-r requirements-lint.txt +-r requirements-test.txt +-r requirements-type.txt 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/tox.ini b/tox.ini deleted file mode 100644 index afd4007..0000000 --- a/tox.ini +++ /dev/null @@ -1,52 +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, generate-integration-files, 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:generate-integration-files] -deps = - pytest==9.1.1 - pytest-cov==7.1.0 -passenv = PY_COLORS -setenv = - PYTEST_ADDOPTS = --no-cov - PYTHONDEVMODE = 1 -commands = pytest -vv -m generate_integration_files --generate-integration-files - -[testenv:lint] -deps = - ruff==0.16.10 -commands = - ruff check src tests - ruff format --check src tests - -[testenv:type] -deps = - mypy==2.4.0 - pytest==9.1.1 # for typing -commands = - mypy - mypy --namespace-packages --explicit-package-bases tests