Skip to content

Option to run all standard test in debug #420

Option to run all standard test in debug

Option to run all standard test in debug #420

---
name: Run Standard Tests
# Run minimal end-to-end tests for Khiops, Khiops Coclustering and KNITransfer
# The tests are launched on:
# - OS: Linux, Windows and macOS
# - Running mode: Serial and parallel (3 processes)
# - Only Khiops is tested in parallel
# - Build: Release and Debug
#
# Tests for Release build or when debug-test-all is enabled:
# - TestKhiops/Standard
# - TestCoclustering/Standard
# - TestKNITransfer/Standard
# - TestKNITransfer/MultiTables/SpliceJunction
#
# Test for Debug build
# - TestKhiops/Standard/IrisLight
# - TestCoclustering/Standard/Iris
# - TestKNITransfer/Standard/Iris
#
# In case of errors, test results are available as artifacts for 7 days. It's automatically
# triggered on PR when sources files, the LearningTest directory or the workflow itself are
# modified.
on:
workflow_dispatch:
inputs:
debug-test-all:
type: boolean
default: false
description: Run all Standard tests on Debug
pull_request:
paths:
- '**CMakeLists.txt'
- src/**.h
- src/**.cpp
- src/**.java
- src/**.dd
- src/**.inc
- src/**.lex
- src/**.yac
- test/LearningTest/**
- .github/workflows/run-standard-tests.yml
# Cancel a run in progress if the workflow is automatically re-triggered in the same PR
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref
}}
cancel-in-progress: true
env:
KhiopsBatchMode: true
jobs:
# Build the project on each platform for all targets to ensure that all sources and cmake files
# are correct. The useful binaries are cached for the current run_id. It will be restored only in
# the same run of the build. The cached binaries are delete in the last job (cleanup-cache).
build-full-project:
strategy:
matrix:
build-setup:
- {os: windows-latest, cmake-preset: windows-msvc}
- {os: ubuntu-latest, cmake-preset: linux-gcc}
- {os: macos-latest, cmake-preset: macos-clang}
config: [debug, release]
runs-on: ${{ matrix.build-setup.os }}
env:
PRESET_NAME: ${{ matrix.build-setup.cmake-preset }}-${{ matrix.config }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Ninja (Linux)
if: matrix.build-setup.os == 'ubuntu-latest'
run: sudo apt-get install ninja-build
- name: Install Ninja (macOS)
if: matrix.build-setup.os == 'macos-latest'
run: brew install ninja
- name: Build all binaries
uses: ./.github/actions/build-khiops
with:
preset-name: ${{ env.PRESET_NAME }}
- name: Cache binaries
id: cache-binaries-unix
uses: actions/cache@v4
with:
# We add binaries path one by one to avoid *.pdb and other msvc stuffs that generate a
# cache of 200Mo for windows
path: |
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL_Coclustering
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/KNITransfer
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL.exe
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL_Coclustering.exe
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/KNITransfer.exe
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/KhiopsNativeInterface.dll
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/lib/libKhiopsNativeInterface.*
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/lib/KhiopsNativeInterface.lib
key: ${{ github.run_id }}-${{ matrix.build-setup.os }}-${{ env.PRESET_NAME
}}
fail-on-cache-miss: false
run-standard-tests:
needs: build-full-project
strategy:
fail-fast: false
matrix:
build-setup:
- {os: windows-2022, cmake-preset: windows-msvc}
- {os: ubuntu-latest, cmake-preset: linux-gcc}
- {os: macos-latest, cmake-preset: macos-clang}
running-mode: [parallel, serial]
config: [debug, release]
runs-on: ${{ matrix.build-setup.os }}
env:
PRESET_NAME: ${{ matrix.build-setup.cmake-preset }}-${{ matrix.config }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Restore cached binaries
id: restore-binaries
uses: actions/cache/restore@v4
with:
path: |
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL_Coclustering
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/KNITransfer
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL.exe
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL_Coclustering.exe
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/KNITransfer.exe
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/KhiopsNativeInterface.dll
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/lib/libKhiopsNativeInterface.*
${{ github.workspace }}/build/${{ env.PRESET_NAME }}/lib/KhiopsNativeInterface.lib
key: ${{ github.run_id }}-${{ matrix.build-setup.os }}-${{ env.PRESET_NAME
}}
fail-on-cache-miss: true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Setup MPI
uses: mpi4py/setup-mpi@v1
- name: Set environment variables
shell: bash
run: |
# Set the paths of the test scripts
echo "TEST_PY=test/LearningTest/cmd/python/test_khiops.py" >> "$GITHUB_ENV"
echo "APPLY_PY=test/LearningTest/cmd/python/apply_command.py" >> "$GITHUB_ENV"
# Set the paths of the Khiops executables to test
if [[ "${{ matrix.build-setup.os }}" == 'windows-2022' ]]
then
BIN_DIR="${{ github.workspace }}\\build\\${{ env.PRESET_NAME }}\\bin"
echo "MODL_BIN=${BIN_DIR}\\MODL.exe" >> "$GITHUB_ENV"
echo "MODL_CC_BIN=${BIN_DIR}\\MODL_Coclustering.exe" >> "$GITHUB_ENV"
echo "KNI_TR_BIN=${BIN_DIR}\\KNITransfer.exe" >> "$GITHUB_ENV"
else
BIN_DIR="${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin"
echo "MODL_BIN=${BIN_DIR}/MODL" >> "$GITHUB_ENV"
echo "MODL_CC_BIN=${BIN_DIR}/MODL_Coclustering" >> "$GITHUB_ENV"
echo "KNI_TR_BIN=${BIN_DIR}/KNITransfer" >> "$GITHUB_ENV"
fi
# Set the MPI settings if necessary
if [[ "${{ matrix.running-mode }}" == "parallel" ]] ; then
echo "KhiopsMPIProcessNumber=3" >> "$GITHUB_ENV"
fi
- name: Run Tests (Release or Debug Full)
shell: bash
if: matrix.config == 'release' || inputs.debug-test-all
run: |
set -x
# Run standard tests as described in the top comment:
# - In parallel, run only MODL tests
# - In debug run only Standard/Iris for KNITRansfer and MODL_Coclustering, Standard/IrisLight for MODL
# - In release run all Standard tests
python $TEST_PY Khiops $MODL_BIN Standard
if [[ "${{ matrix.running-mode }}" == "serial" ]]
then
python $TEST_PY Coclustering $MODL_CC_BIN Standard
python $TEST_PY KNI $KNI_TR_BIN Standard
python $TEST_PY KNI $KNI_TR_BIN MultiTables SpliceJunction
fi
- name: Run Tests (Debug)
shell: bash
if: matrix.config == 'debug' && ! inputs.debug-test-all
run: |
set -x
# See the top comment to see which tests are launched
python $TEST_PY Khiops $MODL_BIN Standard IrisLight
if [[ "${{ matrix.running-mode }}" == "serial" ]]
then
python $TEST_PY Coclustering $MODL_CC_BIN Standard Iris
python $TEST_PY KNI $KNI_TR_BIN Standard Iris
fi
- name: Collect Test Results (Release or Debug Full)
shell: bash
if: (success() || failure()) && (matrix.config == 'release' || inputs.debug-test-all)
run: |
python $APPLY_PY errors test/LearningTest/TestKhiops/Standard \
| tee test/LearningTest/TestKhiops/Standard/errors.txt
if [[ "${{ matrix.running-mode }}" == "serial" ]]
then
python $APPLY_PY errors test/LearningTest/TestCoclustering/Standard \
| tee test/LearningTest/TestCoclustering/Standard/errors.txt
python $APPLY_PY errors test/LearningTest/TestKNITransfer/Standard \
| tee test/LearningTest/TestKNITransfer/Standard/errors.txt
python $APPLY_PY errors test/LearningTest/TestKNITransfer/MultiTables SpliceJunction \
| tee test/LearningTest/TestKNITransfer/MultiTables/errors.txt
fi
- name: Collect Test Results (Debug)
shell: bash
if: (success() || failure()) && (matrix.config == 'debug' && ! inputs.debug-test-all)
run: |
python $APPLY_PY errors test/LearningTest/TestKhiops/Standard IrisLight \
| tee test/LearningTest/TestKhiops/Standard/errors.txt
if [[ "${{ matrix.running-mode }}" == "serial" ]]
then
python $APPLY_PY errors test/LearningTest/TestCoclustering/Standard Iris \
| tee test/LearningTest/TestCoclustering/Standard/errors.txt
python $APPLY_PY errors test/LearningTest/TestKNITransfer/Standard Iris \
| tee test/LearningTest/TestKNITransfer/Standard/errors.txt
fi
- name: Check results
shell: bash
run: |
if grep -qr "error" --include="errors.txt" test/LearningTest/
then
echo "::error::Errors in test"
false
fi
if grep -qr "not been launched" --include="errors.txt" test/LearningTest/
then
echo "::error::Test not launched"
false
fi
- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: test-results-${{ env.PRESET_NAME }}-${{ matrix.running-mode}}
retention-days: 7
path: |-
test/LearningTest/**/comparisonResults.log
test/LearningTest/**/errors.txt
test/LearningTest/**/results
test/LearningTest/**/results.ref*
cleanup-cache:
# Clean up all caches belonging to the current run
if: always()
needs: run-standard-tests
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Cleanup cache
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |-
gh extension install actions/gh-actions-cache
echo "Fetching list of cache key for the current workflow"
cache_keys_for_delete=$(gh actions-cache list --key ${{ github.run_id }} | cut -f 1 )
set +e
echo "Deleting caches..."
for cache_key in $cache_keys_for_delete
do
gh actions-cache delete $cache_key --confirm
done
echo "Done"