From 2e2d00032cdb57846ce85c32aad6048726855629 Mon Sep 17 00:00:00 2001 From: mdwcrft Date: Sun, 19 Jul 2026 13:49:22 +0100 Subject: [PATCH] ci: run test matrix on the actual matrix interpreter, split lint from tests The pull-request workflow installed Poetry via pipx, which built the project virtualenv from pipx's own interpreter rather than the one selected by actions/setup-python - every matrix job was actually testing against the runner's default Python (spotted in #740's discussion: the "3.8" job ran 3.12). - Bind Poetry to the matrix interpreter with `poetry env use` and assert sys.version_info inside the venv so the matrix cannot silently drift again - Trim the matrix to the versions pyproject.toml currently supports (^3.11); the untruthful 3.8-3.10 jobs are removed until the floor is genuinely lowered (#740) - Split `make tests` into `lint` + `unit-tests`; lint runs once on 3.13, matrix jobs run only the test suite. `make tests` still runs both, so local workflow is unchanged - publish-to-pypi: bump the pinned interpreter 3.10 -> 3.13 (it was below the package's own ^3.11 floor and only worked via the same pipx accident) and bind Poetry the same way Constraint: matrix must reflect pyproject's python range at every commit Rejected: extending matrix to 3.9/3.10 here | fails until #740 lowers the floor Confidence: high Scope-risk: narrow Not-tested: publish workflow path (only runs on tag push) Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/publish-to-pypi.yml | 8 +++-- .github/workflows/pull-request.yml | 43 +++++++++++++++++++++++---- Makefile | 10 +++++-- 3 files changed, 52 insertions(+), 9 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 1d4afa925..4738af6f9 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -10,10 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - - name: Set up Python 3.10 + - name: Set up Python 3.13 uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: '3.13' - name: Gets the tag version id: context @@ -23,6 +23,10 @@ jobs: - name: Setup the Python Environment by installing Poetry uses: ./.github/actions/setup-python-build-env + - name: Bind Poetry to the selected interpreter + shell: bash + run: poetry env use "$(which python)" + - name: Code Quality Check shell: bash run: make install && make tests diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 4445b661e..64124875f 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -6,14 +6,35 @@ on: - master jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Setup the Python Environment by installing Poetry + uses: ./.github/actions/setup-python-build-env + + - name: Bind Poetry to the selected interpreter + shell: bash + run: poetry env use "$(which python)" + + - name: Install dependencies + shell: bash + run: make install + + - name: Lint + shell: bash + run: make lint + tests: runs-on: ubuntu-latest strategy: matrix: version: - - "3.8" - - "3.9" - - "3.10" - "3.11" - "3.12" - "3.13" @@ -27,7 +48,19 @@ jobs: - name: Setup the Python Environment by installing Poetry uses: ./.github/actions/setup-python-build-env - - name: Code Quality Check + - name: Bind Poetry to Python ${{ matrix.version }} + shell: bash + run: poetry env use "$(which python)" + + - name: Install dependencies + shell: bash + run: make install + + - name: Verify tests run on Python ${{ matrix.version }} shell: bash run: | - make install && make tests + poetry run python -c 'import sys; expected = tuple(int(p) for p in "${{ matrix.version }}".split(".")); assert sys.version_info[:2] == expected, f"expected Python {expected}, got {sys.version}"; print(sys.version)' + + - name: Run tests + shell: bash + run: make unit-tests diff --git a/Makefile b/Makefile index 01bc03c44..4b94da5a0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: help .check-pypi-envs .install-poetry update install docs tests build deploy +.PHONY: help .check-pypi-envs .install-poetry update install docs lint unit-tests tests build deploy .DEFAULT_GOAL := help @@ -18,6 +18,8 @@ help: @echo " release version= bumps the project version to , using poetry;" @echo " Updates also docs/source/conf.py version;" @echo " If no version is provided, poetry outputs the current project version" + @echo " lint run the linting checks (black, isort, flake8)" + @echo " unit-tests run the test suite" @echo " tests run all the tests and linting" @echo " update updates the dependencies in poetry.lock" @echo "" @@ -39,12 +41,16 @@ docs: .install-poetry format: .install-poetry poetry run isort ocpp tests && poetry run black ocpp tests -tests: .install-poetry +lint: .install-poetry poetry run black --check --diff ocpp tests poetry run isort --check-only ocpp tests poetry run flake8 ocpp tests + +unit-tests: .install-poetry poetry run py.test -vvv --cov=ocpp --cov-report=term-missing tests/ +tests: lint unit-tests + build: .install-poetry poetry build