From 6589be72a48c039d3cf9182a5b5de62f2def1538 Mon Sep 17 00:00:00 2001 From: Elouen Ginat Date: Mon, 2 Mar 2026 11:39:52 +0100 Subject: [PATCH 1/5] chore: update CI workflows for improved packaging and testing --- .github/workflows/ci.yml | 53 ++++++++++++++++++++++++++++++++++ .github/workflows/pack-pip.yml | 36 +++++++++++++++-------- 2 files changed, 77 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..bde109f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,53 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + paths: + - .github/workflows/ci.yml + - pyproject.toml + - src/** + - tests/** + +defaults: + run: + shell: bash + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: astral-sh/setup-uv@v6 + with: + enable-cache: true + + - name: Install dev dependencies + run: uv sync --group dev + + - name: Run pre-commit hooks + run: uv run pre-commit run --all-files + + test: + name: Test (Python ${{ matrix.python-version }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] + steps: + - uses: actions/checkout@v4 + + - uses: astral-sh/setup-uv@v6 + with: + enable-cache: true + python-version: ${{ matrix.python-version }} + + - name: Install dev dependencies + run: uv sync --group dev --extra all + + - name: Run tests + run: uv run pytest diff --git a/.github/workflows/pack-pip.yml b/.github/workflows/pack-pip.yml index 0902080..5fbc383 100644 --- a/.github/workflows/pack-pip.yml +++ b/.github/workflows/pack-pip.yml @@ -1,5 +1,6 @@ name: pip packaging -on: + +on: workflow_dispatch: inputs: python_repository: @@ -14,7 +15,12 @@ on: - .github/workflows/pack-pip.yml - pyproject.toml - CMakeLists.txt - + - src/** + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + defaults: run: shell: bash @@ -39,15 +45,21 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@v3.3.1 - - name: install Python + - name: Set up Python uses: actions/setup-python@v5 - + + - name: Set up UV + uses: astral-sh/setup-uv@v6 + with: + enable-cache: true + - name: Test built wheel run: | - pip install --find-links=wheelhouse khisto - pip install pytest>=8.3 pytest-cov>=6 pytest-xdist>=3.6 pytest-sugar>=1.0 - pytest tests/ - + uv venv .test-env + uv pip install --python .test-env --find-links=wheelhouse "khisto[all]" + VIRTUAL_ENV=.test-env uv sync --group dev --no-install-project + VIRTUAL_ENV=.test-env uv run pytest tests/ --no-cov + - uses: actions/upload-artifact@v6 with: name: pkg-wheel-${{ matrix.os }} @@ -65,7 +77,7 @@ jobs: environment: name: testpypi steps: - - uses: actions/download-artifact@v5 + - uses: actions/download-artifact@v6 with: pattern: pkg-* path: dist @@ -74,9 +86,9 @@ jobs: with: verbose: true repository-url: https://test.pypi.org/legacy/ - + release-pypi: - # Publish only on tag pushes in the KhiopsML repository + # Publish only on tag pushes in the KhiopsML repository name: Publish to PyPI.org if: github.ref_type == 'tag' && github.repository_owner == 'KhiopsML' && inputs.python_repository == 'pypi' needs: [build-wheel] @@ -86,7 +98,7 @@ jobs: environment: name: pypi steps: - - uses: actions/download-artifact@v5 + - uses: actions/download-artifact@v6 with: pattern: pkg-* path: dist From f0c9a6a909417b244e6012b49ac17ca1d8ae0b3e Mon Sep 17 00:00:00 2001 From: Elouen Ginat Date: Mon, 2 Mar 2026 11:56:16 +0100 Subject: [PATCH 2/5] chore: add conftest.py to set non-interactive matplotlib backend for tests --- tests/conftest.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..c3f506e --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,9 @@ +# Copyright (c) 2025-2026 Orange. All rights reserved. +# This software is distributed under the BSD 3-Clause-clear License, the text of which is available +# at https://spdx.org/licenses/BSD-3-Clause-Clear.html or see the "LICENSE" file for more details. + +"""Root conftest: force a non-interactive matplotlib backend for all tests.""" + +import os + +os.environ.setdefault("MPLBACKEND", "Agg") From 4867ca52b6db5c8306d9b3b9e57846ffc97ecb81 Mon Sep 17 00:00:00 2001 From: Elouen Ginat Date: Mon, 9 Mar 2026 12:22:16 +0100 Subject: [PATCH 3/5] chore: rename CI workflow to 'Lint and Test' and add Python version discovery step --- .github/workflows/ci.yml | 27 +++++++++++++++++++++++++-- .github/workflows/pack-pip.yml | 1 - 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bde109f..4631817 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: CI +name: Lint and Test on: push: @@ -31,13 +31,36 @@ jobs: - name: Run pre-commit hooks run: uv run pre-commit run --all-files + get-python-versions: + name: Get Python versions + runs-on: ubuntu-latest + outputs: + python-versions: ${{ steps.versions.outputs.python-versions }} + steps: + - uses: actions/checkout@v4 + + - uses: astral-sh/setup-uv@v6 + + - name: Discover available Python versions + id: versions + run: | + min_ver=$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['requires-python'])") + versions=$( + uv python list --all-versions "$min_ver" \ + | grep -oP 'cpython-\K\d+\.\d+' \ + | sort -uV \ + | python3 -c "import sys, json; print(json.dumps(sys.stdin.read().split()))" + ) + echo "python-versions=$versions" >> $GITHUB_OUTPUT + test: name: Test (Python ${{ matrix.python-version }}) + needs: get-python-versions runs-on: ubuntu-latest strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] + python-version: ${{ fromJson(needs.get-python-versions.outputs.python-versions) }} steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/pack-pip.yml b/.github/workflows/pack-pip.yml index 5fbc383..45234b4 100644 --- a/.github/workflows/pack-pip.yml +++ b/.github/workflows/pack-pip.yml @@ -15,7 +15,6 @@ on: - .github/workflows/pack-pip.yml - pyproject.toml - CMakeLists.txt - - src/** concurrency: group: ${{ github.workflow }}-${{ github.ref }} From 70652acd4c54de2b726197ecca0de1652a7b3a99 Mon Sep 17 00:00:00 2001 From: Elouen Ginat Date: Mon, 9 Mar 2026 12:27:51 +0100 Subject: [PATCH 4/5] fix: update regex to correctly extract Python version from output --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4631817..4fef0d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: min_ver=$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['requires-python'])") versions=$( uv python list --all-versions "$min_ver" \ - | grep -oP 'cpython-\K\d+\.\d+' \ + | grep -oP 'cpython-\K\d+\.\d+(?=\.\d+-)' \ | sort -uV \ | python3 -c "import sys, json; print(json.dumps(sys.stdin.read().split()))" ) From 8d15d7b795d439d9e629ed45fe31cd5d5f0464ae Mon Sep 17 00:00:00 2001 From: Elouen Ginat Date: Mon, 9 Mar 2026 13:50:08 +0100 Subject: [PATCH 5/5] chore: remove push trigger from CI workflow --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4fef0d7..ac1f319 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,6 @@ name: Lint and Test on: - push: - branches: [main] pull_request: paths: - .github/workflows/ci.yml