Skip to content

Commit c26ad9c

Browse files
author
Thierry RAMORASOAVINA
committed
Refactor the github conda workflow to only test the released package
- the github workflow does not build any longer a conda package (even if the instructions and files to build locally are kept) - this github workflow fetches the released package from conda-forge - this workflow is launched manually on demand
1 parent f70cdd9 commit c26ad9c

File tree

2 files changed

+189
-5
lines changed

2 files changed

+189
-5
lines changed
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
---
2+
name: Test the released Conda Package
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
khiops-core-version:
7+
default: 11.0.0
8+
description: khiops-core version for testing
9+
khiops-samples-version:
10+
default: 11.0.0
11+
description: khiops-samples version
12+
khiops-python-version:
13+
default: 11.0.0.3
14+
description: khiops-python version for testing
15+
defaults:
16+
run:
17+
shell: bash -el {0}
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
20+
cancel-in-progress: true
21+
jobs:
22+
# Test Conda package on brand new environments
23+
test:
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
28+
env:
29+
- {os: ubuntu-22.04, json-image: '{"image": "ubuntu:20.04"}'}
30+
- {os: ubuntu-22.04, json-image: '{"image": null}'}
31+
- {os: ubuntu-24.04, json-image: '{"image": null}'}
32+
- {os: ubuntu-22.04, json-image: '{"image": "rockylinux:8"}'}
33+
- {os: ubuntu-22.04, json-image: '{"image": "rockylinux:9"}'}
34+
- {os: windows-2022, json-image: '{"image": null}'}
35+
- {os: windows-2025, json-image: '{"image": null}'}
36+
- {os: macos-14, json-image: '{"image": null}'}
37+
- {os: macos-15, json-image: '{"image": null}'}
38+
- {os: macos-15-intel, json-image: '{"image": null}'}
39+
runs-on: ${{ matrix.env.os }}
40+
container: ${{ fromJSON(matrix.env.json-image) }}
41+
steps:
42+
- name: Install Miniforge
43+
uses: conda-incubator/setup-miniconda@v3
44+
with:
45+
miniforge-version: 24.11.0-0
46+
python-version: ${{ matrix.python-version }}
47+
conda-remove-defaults: true
48+
- name: Put the khiops-core Version in the Environment
49+
run: |
50+
KHIOPS_CORE_VERSION="${{ inputs.khiops-core-version }}"
51+
echo "KHIOPS_CORE_VERSION=$KHIOPS_CORE_VERSION" >> "$GITHUB_ENV"
52+
- name: Install the Khiops Conda package
53+
run: |
54+
# Add the Conda `rc` label for alpha or RC pre-releases
55+
if [[ $(echo ${KHIOPS_CORE_VERSION} | grep -E ".*(a|rc)\.[0-9]+") ]]; then
56+
RC_LABEL="conda-forge/label/rc::"
57+
else
58+
RC_LABEL=""
59+
fi
60+
conda install "${RC_LABEL}"khiops-core==$KHIOPS_CORE_VERSION
61+
conda install khiops==${{ inputs.khiops-python-version }}
62+
- name: Install JQ test dependency (Linux / MacOS)
63+
if: runner.os != 'Windows'
64+
run: conda install jq
65+
- name: Test Conda / Python Package Version Coherence
66+
run: |
67+
PACKAGE_VERSION=$(python -c "import khiops; print(khiops.__version__)")
68+
CONDA_VERSION=$(conda list ^khiops$ --json | jq ".[].version")
69+
70+
# Fail if CONDA_VERSION is not identical to $PACKAGE_VERSION
71+
echo $CONDA_VERSION | grep -wq $PACKAGE_VERSION
72+
if [[ $? -ne 0 ]]
73+
then
74+
echo "::error::Conda package version $CONDA_VERSION does not match Python package version $PYTHON_VERSION"
75+
false
76+
fi
77+
- name: Test Khiops Installation Status
78+
run: kh-status
79+
- name: Test Khiops Installation Status (Conda-Based Environments)
80+
run: |
81+
# Set `python` to the current Conda Python executable
82+
PYTHON="$(type -P python)"
83+
84+
# Remove $CONDA_PREFIX/bin from PATH
85+
PATH=$(echo $PATH | sed "s#$CONDA_PREFIX/bin:##g")
86+
87+
# Unset *CONDA* environment variables
88+
# As a corollary, CONDA_PREFIX is unset
89+
# Note: There is no way to remove these variables from GITHUB_ENV
90+
# (see https://github.com/actions/runner/issues/1126)
91+
for CONDA_VAR in $(env | grep CONDA)
92+
do
93+
unset $(echo $CONDA_VAR | cut -d '=' -f 1)
94+
done
95+
96+
# Note: kh-status is not reachable as it is not in PATH
97+
$PYTHON -c \
98+
"import sys; import khiops.core as kh; return_code = kh.get_runner().print_status(); sys.exit(return_code)"
99+
- name: Download Sample Datasets
100+
run: |
101+
kh-download-datasets \
102+
--version ${{ inputs.khiops-samples-version }}
103+
- name: Run Samples
104+
env:
105+
# Force > 2 CPU cores to launch mpiexec
106+
KHIOPS_PROC_NUMBER: 4
107+
run: |
108+
kh-samples core -i deploy_model -e
109+
kh-samples core -i deploy_coclustering -e
110+
kh-samples core -i train_predictor_error_handling -e
111+
kh-samples sklearn -i khiops_classifier -e
112+
kh-samples sklearn -i khiops_coclustering -e
113+
- name: Run Samples (Conda-Based Environments)
114+
env:
115+
# Force > 2 CPU cores to launch mpiexec
116+
KHIOPS_PROC_NUMBER: 4
117+
run: |
118+
# Set `python` to the current Conda Python executable
119+
PYTHON="$(type -P python)"
120+
121+
# Remove $CONDA_PREFIX/bin from PATH
122+
PATH=$(echo $PATH | sed "s#$CONDA_PREFIX/bin:##g")
123+
124+
# Unset *CONDA* environment variables
125+
# As a corollary, CONDA_PREFIX is unset
126+
# Note: There is no way to remove these variables from GITHUB_ENV
127+
# (see https://github.com/actions/runner/issues/1126)
128+
for CONDA_VAR in $(env | grep CONDA)
129+
do
130+
unset $(echo $CONDA_VAR | cut -d '=' -f 1)
131+
done
132+
133+
# Run samples
134+
# Note: kh-samples is not reachable as it is not in PATH
135+
$PYTHON -m khiops.samples.samples -i deploy_model -e
136+
$PYTHON -m khiops.samples.samples -i deploy_coclustering -e
137+
$PYTHON -m khiops.samples.samples -i train_predictor_error_handling -e
138+
$PYTHON -m khiops.samples.samples_sklearn -i khiops_classifier -e
139+
$PYTHON -m khiops.samples.samples_sklearn -i khiops_coclustering -e
140+
# Checkout the sources to obtain the tests
141+
# Note: The `sparse-checkout` option of this action is bugged so we checkout all the sources
142+
# See https://github.com/actions/checkout/issues/1628
143+
- name: Checkout Sources
144+
uses: actions/checkout@v4
145+
with:
146+
fetch-depth: 1
147+
# This is needed so python does not retrieve the khiops module from PWD
148+
- name: Remove the khiops Module from the Sources
149+
run: rm -rf khiops
150+
- name: Install the Test Requirements
151+
run: conda install -y --file test-requirements.txt
152+
- name: Run the Runner Initialization Integration Test
153+
run: |
154+
python -m unittest -v \
155+
tests.test_khiops_integrations.KhiopsRunnerEnvironmentTests.test_runner_environment_initialization
156+
- name: Run the Runner Initialization Integration Test (Conda-Based Environments)
157+
run: |-
158+
# Set `python` to the current Conda Python executable
159+
PYTHON="$(type -P python)"
160+
161+
# Remove $CONDA_PREFIX/bin from PATH
162+
PATH=$(echo $PATH | sed "s#$CONDA_PREFIX/bin:##g")
163+
164+
# Unset *CONDA* environment variables
165+
# As a corolary, CONDA_PREFIX is unset
166+
# Note: There is no way to remove these variables from GITHUB_ENV
167+
# (see https://github.com/actions/runner/issues/1126)
168+
for CONDA_VAR in $(env | grep CONDA)
169+
do
170+
unset $(echo $CONDA_VAR | cut -d '=' -f 1)
171+
done
172+
173+
# Execute the runner initialization integration test
174+
$PYTHON -m unittest -v \
175+
tests.test_khiops_integrations.KhiopsRunnerEnvironmentTests.test_runner_environment_initialization

packaging/conda/README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Khiops Conda Packaging Scripts
22

3+
## Purpose
4+
The current folder helps you build locally a conda package from the sources.
5+
36
## How to Build
4-
You'll need `conda-build` installed in your system. The environment variable `KHIOPS_REVISION` must
5-
be set to a Git tag of the `khiops` repository.
7+
You'll need the package `conda-build` installed in your conda environment.
8+
Optionally if installed, the package `conda-verify` will find obvious packaging bugs.
69

710
```bash
8-
# At the root of the repo
9-
# These commands will leave a ready to use conda channel in `./khiops-conda-build`
10-
KHIOPS_REVISION=10.2.0
11+
# At the root of the project repository
1112

1213
# Windows
1314
conda build --output-folder ./khiops-conda-build packaging/conda
@@ -16,3 +17,11 @@ conda build --output-folder ./khiops-conda-build packaging/conda
1617
# Note: We use the conda-forge channel so the khiops-core package obtains the pinned MPICH versions
1718
conda build --channel conda-forge --output-folder ./khiops-conda-build packaging/conda
1819
```
20+
21+
## How to Install
22+
23+
The freshly built package can be installed in your conda environment
24+
25+
```bash
26+
conda install --channel ./khiops-conda-build khiops
27+
```

0 commit comments

Comments
 (0)