Skip to content

Commit 96f3c89

Browse files
author
Thierry RAMORASOAVINA
committed
Refactor the github conda workflow to test released packages
- the workflow does not build any longer locally a package - it fetches the released one from conda-forge - the workflow is launched manually on demand
1 parent f70cdd9 commit 96f3c89

1 file changed

Lines changed: 176 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)