-
Notifications
You must be signed in to change notification settings - Fork 5
216 lines (216 loc) · 9.43 KB
/
run-standard-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
---
name: Run Standard Tests
# Run minimal end-to-end tests for Khiops, Khiops Coclustering and KNITransfer
# Tests are lauched on Linux, Windows and macOS ; in serial and in parallel (4 procs)
# On release, it runs Standard test for binary.
# On debug, it runs only Standard/Iris for Coclustering and KNITransfer and Standard/IrisLight for Khiops
# In case of errors, test results are available as artifacts for 7 days
# It is automatically triggered on PR when sources files are modified (files in src directory)
on:
workflow_dispatch:
inputs:
warning_as_error:
type: boolean
description: Treat warnings as errors
required: false
default: false
pull_request:
paths:
- '**CMakeLists.txt'
- src/**.h
- src/**.cpp
- src/**.java
- src/**.dd
- src/**.inc
- src/**.lex
- src/**.yac
- test/LearningTest/**
# Cancel any ongoing run of this workflow on the same PR or ref
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-2022, 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@v3
- name: Build all binaries
uses: ./.github/actions/build-khiops
with:
preset-name: ${{ env.PRESET_NAME }}
override-flags: -DTESTING=OFF
targets: all
- name: Cache binaries
id: cache-binaries-unix
uses: actions/cache@v3
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@v3
- name: Restore cached binaries
id: restore-binaries
uses: actions/cache/restore@v3
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@v4
with:
python-version: '3.10'
- name: Set environment variables
shell: bash
run: |
echo "TEST_PY=test/LearningTestTool/py/kht_test.py" >> "$GITHUB_ENV"
echo "APPLY_PY=test/LearningTestTool/py/kht_apply.py" >> "$GITHUB_ENV"
echo "COLLECT_PY=test/LearningTestTool/py/kht_collect_results.py" >> "$GITHUB_ENV"
echo "BIN_PATH=${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin" >> "$GITHUB_ENV"
- name: Setup MPI
uses: mpi4py/setup-mpi@v1
- name: Run Tests
# Run test on linux and macOS as describe 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
shell: bash
run: |
if [[ "${{ matrix.running-mode }}" == "parallel" ]] ; then
export KhiopsMPIProcessNumber=4
fi
if [[ "${{ matrix.config }}" == "release" ]] ; then
python $TEST_PY test/LearningTest/TestKhiops/Standard ${BIN_PATH}
if [[ "${{ matrix.running-mode }}" != "parallel" ]] ; then
python $TEST_PY test/LearningTest/TestCoclustering/Standard ${BIN_PATH}
python $TEST_PY test/LearningTest/TestKNI/Standard ${BIN_PATH}
fi
else
python $TEST_PY test/LearningTest/TestKhiops/Standard/IrisLight ${BIN_PATH}
if [[ "${{ matrix.running-mode }}" != "parallel" ]] ; then
python $TEST_PY test/LearningTest/TestCoclustering/Standard/Iris ${BIN_PATH}
python $TEST_PY test/LearningTest/TestKNI/Standard/Iris ${BIN_PATH}
fi
fi
- name: Collect results
shell: bash
if: success() || failure()
run: |
mkdir results
if [[ "${{ matrix.config }}" == "release" ]] ; then
python $APPLY_PY test/LearningTest/TestKhiops/Standard errors | tee -a results/errors.txt
if [[ "${{ matrix.running-mode }}" != "parallel" ]] ; then
python $APPLY_PY test/LearningTest/TestCoclustering/Standard errors | tee -a results/errors.txt
python $APPLY_PY test/LearningTest/TestKNI/Standard errors | tee -a results/errors.txt
fi
else
python $APPLY_PY test/LearningTest/TestKhiops/Standard/IrisLight errors | tee -a results/errors.txt
if [[ "${{ matrix.running-mode }}" != "parallel" ]] ; then
python $APPLY_PY test/LearningTest/TestCoclustering/Standard/Iris errors | tee -a results/errors.txt
python $APPLY_PY test/LearningTest/TestKNI/Standard/Iris errors | tee -a results/errors.txt
fi
fi
python $COLLECT_PY test/LearningTest/ results --collect-type warnings -f basic
- name: Check results
# We escape eol in the results file to print multilines in the github UI https://github.com/orgs/community/discussions/26288
shell: bash
run: |
MSG=$(<results/errors.txt)
MSG="${MSG//'%'/'%25'}"
MSG="${MSG//$'\n'/'%0A'}"
MSG="${MSG//$'\r'/'%0D'}"
if grep -q -e "error" -e "The test has not been launched" results/errors.txt ; then
echo "::error::$MSG"
false
fi
if [ "${{ github.event.inputs.warning_as_error }}" == "true" ] && grep -q "warning" results/errors.txt ; then
echo "::error::$MSG"
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: |-
results/
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: Checkout sources
uses: actions/checkout@v3
with:
sparse-checkout: .git
- 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"