-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
323 lines (280 loc) · 16.5 KB
/
action.yml
File metadata and controls
323 lines (280 loc) · 16.5 KB
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# Action description and parameters
name: 'SOFA Setup Action'
description: 'Setup everything needed to build a SOFA plugin'
inputs:
sofa_root:
description: 'SOFA install directory to get Regression binary, set SOFA_ROOT variable and append the PYTHONPATH env variable'
required: true
sofa_version:
description: 'Version of SOFA used. Needed to know which binary verison of Regression to use (either master or a release e.g. v24.12)'
required: true
src_dir:
description: 'Directory of the sources of the plugin to be tested (regression file will be looked for in example folder)'
required: true
build_dir:
description: 'Build directory of the plugin. Used to include bindings if some are compiled by this plugin'
required: true
output_dir:
description: 'Directory where to dump logs and results of tests. Will be created if it does not exist'
required: true
python_exe:
description: 'path to python executable'
required: true
run_unit_tests:
description: 'If true, will run the unit tests found in the build_dir/bin'
required: false
default: 'true'
run_scene_tests:
description: 'If true, will run all the scene found under src_dir/examples'
required: false
default: 'true'
run_regression_tests:
description: 'If true, will run the regression tests found in the src_dir/examples'
required: false
default: 'true'
nb_parallel_threads:
description: 'Tests will be run in parallel, this is the maximum number of thread allowed'
required: false
default: '1'
ci_dir:
description: 'Directory of the clone of the ci repository. If none is given, the plugin will be fetched by this action'
required: false
regression_dir:
description: 'Directory of the clone of the Regression repository. If none is given, the plugin will be fetched by this action'
required: false
publish_logs:
description: 'Boolean stating if the logs should be directly published by the action'
required: false
default: 'true'
outputs:
unit_test_results:
description: "Log file containing scene tests results"
value: ${{ steps.set-env-vars.outputs.scene_test_results_path }}
unit_test_results_path:
description: "Log file containing scene tests results"
value: ${{ steps.set-env-vars.outputs.scene_test_results_path }}
scene_test_results:
description: "Log file containing scene tests results"
value: ${{ steps.set-env-vars.outputs.scene_test_results_path }}
scene_test_results_path:
description: "Log file containing scene tests results"
value: ${{ steps.set-env-vars.outputs.scene_test_results_path }}
regression_test_results:
description: "Log file containing regression tests results"
value: ${{ steps.set-env-vars.outputs.regression_test_results_path }}
regression_test_results_path:
description: "Log file containing regression tests results"
value: ${{ steps.set-env-vars.outputs.regression_test_results_path }}
runs:
using: "composite"
steps:
- name: Clone missing CI plugin
uses: actions/checkout@v4
if: inputs.ci_dir == ''
with:
repository: 'sofa-framework/ci'
ref: 'master'
path: ci
- name: Clone missing Regression plugin
uses: actions/checkout@v4
if: inputs.regression_dir == ''
with:
repository: 'sofa-framework/Regression'
ref: 'master'
path: Regression
- name: Setup environement for tests
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
WORKSPACE_DIR=$(echo "${{ github.workspace }}" | tr '\\' '/' | sed 's/^\([A-Za-z]\):/\/\L\1/')
BUILD_DIR=$(echo "${{ inputs.build_dir }}" | tr '\\' '/' | sed 's/^\([A-Za-z]\):/\/\L\1/')
SRC_DIR=$(echo "${{ inputs.src_dir }}" | tr '\\' '/' | sed 's/^\([A-Za-z]\):/\/\L\1/')
SOFA_ROOT=$(echo "${{ inputs.sofa_root }}" | tr '\\' '/' | sed 's/^\([A-Za-z]\):/\/\L\1/')
OUTPUT_DIR=$(echo "${{ inputs.output_dir }}" | tr '\\' '/' | sed 's/^\([A-Za-z]\):/\/\L\1/')
OUTPUT_DIR_FOR_GTEST=$(echo "${{ inputs.output_dir }}" | tr '\\' '/')
CI_DIR=$(echo "${{ inputs.ci_dir }}" | tr '\\' '/' | sed 's/^\([A-Za-z]\):/\/\L\1/')
REGRESSION_DIR=$(echo "${{ inputs.regression_dir }}" | tr '\\' '/' | sed 's/^\([A-Za-z]\):/\/\L\1/')
else
WORKSPACE_DIR="${{ github.workspace }}"
BUILD_DIR="${{ inputs.build_dir }}"
SRC_DIR="${{ inputs.src_dir }}"
SOFA_ROOT="${{ inputs.sofa_root }}"
OUTPUT_DIR="${{ inputs.output_dir }}"
OUTPUT_DIR_FOR_GTEST=$OUTPUT_DIR
CI_DIR="${{ inputs.ci_dir }}"
REGRESSION_DIR="${{ inputs.regression_dir }}"
fi
if [[ -z "$OUTPUT_DIR" ]]; then
OUTPUT_DIR="$WORKSPACE_DIR/output"
fi
if [[ ! -d "$OUTPUT_DIR" ]]; then
mkdir -p "$OUTPUT_DIR"
fi
if [[ -z "$CI_DIR" ]]; then
CI_DIR="$WORKSPACE_DIR/ci"
fi
if [[ -z "$REGRESSION_DIR" ]]; then
REGRESSION_DIR="$WORKSPACE_DIR/Regression"
fi
echo "WORKSPACE_DIR=$WORKSPACE_DIR" >> $GITHUB_ENV
echo "CI_DIR=$CI_DIR" >> $GITHUB_ENV
echo "REGRESSION_DIR=$REGRESSION_DIR" >> $GITHUB_ENV
echo "BUILD_DIR=$BUILD_DIR" >> $GITHUB_ENV
echo "SRC_DIR=$SRC_DIR" >> $GITHUB_ENV
echo "OUTPUT_DIR=$OUTPUT_DIR" >> $GITHUB_ENV
echo "OUTPUT_DIR_FOR_GTEST=$OUTPUT_DIR_FOR_GTEST" >> $GITHUB_ENV
echo "SOFA_ROOT=$SOFA_ROOT" >> $GITHUB_ENV
##Install Regression release
#mkdir -p "${{ runner.temp }}/regression_tmp"
#curl --output "${{ runner.temp }}/regression_tmp/${RUNNER_OS}.zip" -L https://github.com/sofa-framework/regression/releases/download/release-master/Regression_test_master_for-SOFA-${{ inputs.sofa_version }}_${RUNNER_OS}.zip
#unzip -qq "${{ runner.temp }}/regression_tmp/${RUNNER_OS}.zip" -d "$WORKSPACE_DIR"
#mv "$WORKSPACE_DIR/Regression_test_master_for-SOFA-${{ inputs.sofa_version }}_${RUNNER_OS}/bin/*" "$SOFA_ROOT/bin/"
chmod +x $SOFA_ROOT/bin/Regression_*
echo "REGRESSION_BINARY_DIR=$SOFA_ROOT" >> $GITHUB_ENV
if [[ "$RUNNER_OS" == "Windows" ]]; then
echo "$BUILD_DIR/lib" >> $GITHUB_PATH
echo "$BUILD_DIR/bin" >> $GITHUB_PATH
pythonroot="$(dirname "${{ inputs.python_exe }}")"
pythonroot=$(echo "$pythonroot" | tr '\\' '/' | sed 's/^\([A-Za-z]\):/\/\L\1/')
echo "$pythonroot" >> $GITHUB_PATH
echo "$pythonroot/DLLs" >> $GITHUB_PATH
echo "$pythonroot/Lib" >> $GITHUB_PATH
echo "$SOFA_ROOT/plugins/SofaPython3/bin" >> $GITHUB_PATH
echo "SOFA_PLUGIN_PATH=$BUILD_DIR/bin" | tee -a $GITHUB_ENV
else
echo "SOFA_PLUGIN_PATH=$BUILD_DIR/lib" | tee -a $GITHUB_ENV
echo "SOFA_ROOT=$SOFA_ROOT" | tee -a $GITHUB_ENV
fi
if [[ "$RUNNER_OS" == "macOS" ]]; then
echo "DYLD_LIBRARY_PATH=$BUILD_DIR/lib:$SOFA_ROOT/lib:$SOFA_ROOT/plugins/SofaPython3/lib:$DYLD_LIBRARY_PATH" | tee -a $GITHUB_ENV
fi
# Install GNU timeout on macOS (not available by default)
if [[ "$RUNNER_OS" == "macOS" ]]; then
if ! command -v timeout &> /dev/null; then
echo "Installing GNU timeout on macOS..."
brew install coreutils
echo "/usr/local/opt/coreutils/libexec/gnubin" >> $GITHUB_PATH
fi
fi
if [[ "$RUNNER_OS" == "Linux" ]]; then
echo "LD_LIBRARY_PATH=$BUILD_DIR/lib:$SOFA_ROOT/lib:$SOFA_ROOT/plugins/SofaPython3/lib:$LD_LIBRARY_PATH" | tee -a $GITHUB_ENV
fi
# Setup PYTHONPATH for SofaPython3 module
SOFA_PYTHON_PATH="$SOFA_ROOT/plugins/SofaPython3/lib/python3/site-packages"
# Check if the path exists, if not try common alternatives
if [[ ! -d "$SOFA_PYTHON_PATH" ]]; then
# Try with specific Python versions
for pyver in "python3.12" "python3.10" "python3.9" "python3.8" "python3.7"; do
if [[ -d "$SOFA_ROOT/plugins/SofaPython3/lib/$pyver/site-packages" ]]; then
SOFA_PYTHON_PATH="$SOFA_ROOT/plugins/SofaPython3/lib/$pyver/site-packages"
break
fi
done
fi
if [[ "$RUNNER_OS" == "Windows" ]]; then
# On Windows, use semicolon as path separator instead of colon
# Only add semicolon if PYTHONPATH is not empty
if [[ -n "$PYTHONPATH" ]]; then
echo "PYTHONPATH=$SOFA_PYTHON_PATH;$PYTHONPATH" | tee -a $GITHUB_ENV
else
echo "PYTHONPATH=$SOFA_PYTHON_PATH" | tee -a $GITHUB_ENV
fi
else
echo "PYTHONPATH=$SOFA_PYTHON_PATH:$PYTHONPATH" | tee -a $GITHUB_ENV
fi
- name: Install missing pip packages
shell: bash
run: |
python3 -m pip install prettytable
- name: Launch unit tests
if: always() && inputs.run_unit_tests == 'true'
shell: bash
run: |
echo "Launching \" /bin/bash \"$CI_DIR/scripts/unit-tests.sh\" run unit \"$BUILD_DIR\" \"$SRC_DIR\" \"$OUTPUT_DIR_FOR_GTEST\" ${{ inputs.nb_parallel_threads }}\""
/bin/bash "$CI_DIR/scripts/unit-tests.sh" run unit "$BUILD_DIR" "$SRC_DIR" "$OUTPUT_DIR_FOR_GTEST" ${{ inputs.nb_parallel_threads }}
/bin/bash "$CI_DIR/scripts/unit-tests.sh" print-summary unit "$BUILD_DIR" "$SRC_DIR" "$OUTPUT_DIR_FOR_GTEST" ${{ inputs.nb_parallel_threads }}
echo "tests_suites=$(/bin/bash "$CI_DIR/scripts/unit-tests.sh" count-test-suites unit $BUILD_DIR $SRC_DIR $OUTPUT_DIR_FOR_GTEST)" > $OUTPUT_DIR/unit-tests/unit-tests_results.txt
echo "tests_total=$(/bin/bash "$CI_DIR/scripts/unit-tests.sh" count-tests unit $BUILD_DIR $SRC_DIR $OUTPUT_DIR_FOR_GTEST)" >> $OUTPUT_DIR/unit-tests/unit-tests_results.txt
echo "tests_disabled=$(/bin/bash "$CI_DIR/scripts/unit-tests.sh" count-disabled unit $BUILD_DIR $SRC_DIR $OUTPUT_DIR_FOR_GTEST)" >> $OUTPUT_DIR/unit-tests/unit-tests_results.txt
echo "tests_failures=$(/bin/bash "$CI_DIR/scripts/unit-tests.sh" count-failures unit $BUILD_DIR $SRC_DIR $OUTPUT_DIR_FOR_GTEST)" >> $OUTPUT_DIR/unit-tests/unit-tests_results.txt
echo "tests_errors=$(/bin/bash "$CI_DIR/scripts/unit-tests.sh" count-errors unit $BUILD_DIR $SRC_DIR $OUTPUT_DIR_FOR_GTEST)" >> $OUTPUT_DIR/unit-tests/unit-tests_results.txt
echo "tests_duration=$(/bin/bash "$CI_DIR/scripts/unit-tests.sh" count-durations unit $BUILD_DIR $SRC_DIR $OUTPUT_DIR_FOR_GTEST)" >> $OUTPUT_DIR/unit-tests/unit-tests_results.txt
python3 "$CI_DIR/scripts/exctractErrorFromXML.py" "$OUTPUT_DIR/unit-tests/reports" "$OUTPUT_DIR/unit-tests"
- name: Launch scene tests
if: always() && inputs.run_scene_tests == 'true'
shell: bash
run: |
echo "Launching \" /bin/bash \"$CI_DIR/scripts/scene-tests.sh\" run \"$SOFA_ROOT\" \"$SRC_DIR\" \"$OUTPUT_DIR\" ${{ inputs.nb_parallel_threads }}\""
/bin/bash "$CI_DIR/scripts/scene-tests.sh" run "$SOFA_ROOT" "$SRC_DIR" "$OUTPUT_DIR" ${{ inputs.nb_parallel_threads }}
/bin/bash "$CI_DIR/scripts/scene-tests.sh" print-summary "$SOFA_ROOT" "$SRC_DIR" "$OUTPUT_DIR" ${{ inputs.nb_parallel_threads }}
echo "scenes_total=$(/bin/bash $CI_DIR/scripts/scene-tests.sh count-tested-scenes $BUILD_DIR $SRC_DIR $OUTPUT_DIR)" > $OUTPUT_DIR/scene-tests/scene-tests_results.txt
echo "scenes_successes=$(/bin/bash "$CI_DIR/scripts/scene-tests.sh" count-successes $BUILD_DIR $SRC_DIR $OUTPUT_DIR)" >> $OUTPUT_DIR/scene-tests/scene-tests_results.txt
echo "scenes_errors=$(/bin/bash "$CI_DIR/scripts/scene-tests.sh" count-errors $BUILD_DIR $SRC_DIR $OUTPUT_DIR)" >> $OUTPUT_DIR/scene-tests/scene-tests_results.txt
echo "scenes_crashes=$(/bin/bash "$CI_DIR/scripts/scene-tests.sh" count-crashes $BUILD_DIR $SRC_DIR $OUTPUT_DIR)" >> $OUTPUT_DIR/scene-tests/scene-tests_results.txt
echo "scenes_duration=$(/bin/bash "$CI_DIR/scripts/scene-tests.sh" count-durations $BUILD_DIR $SRC_DIR $OUTPUT_DIR)" >> $OUTPUT_DIR/scene-tests/scene-tests_results.txt
if [[ -f "$OUTPUT_DIR/scene-tests/reports/crashes.txt" && "$(cat "$OUTPUT_DIR/scene-tests/reports/crashes.txt")" != "" ]]; then
cp $OUTPUT_DIR/scene-tests/reports/crashes.txt $OUTPUT_DIR/scene-tests_crashes
fi
if [[ -f "$OUTPUT_DIR/scene-tests/reports/errors.txt" && "$(cat "$OUTPUT_DIR/scene-tests/reports/errors.txt")" != "" ]]; then
cp $OUTPUT_DIR/scene-tests/reports/errors.txt $OUTPUT_DIR/scene-tests_errors
fi
- name: Launch regression tests
if: always() && inputs.run_regression_tests == 'true'
shell: bash
run: |
echo "Launching \" /bin/bash \"$CI_DIR/scripts/unit-tests.sh\" run regression \"$REGRESSION_BINARY_DIR\" \"$SRC_DIR\" \"$OUTPUT_DIR_FOR_GTEST\" ${{ inputs.nb_parallel_threads }}\""
/bin/bash "$CI_DIR/scripts/unit-tests.sh" run regression "$REGRESSION_BINARY_DIR" "$SRC_DIR" "$OUTPUT_DIR_FOR_GTEST" ${{ inputs.nb_parallel_threads }}
/bin/bash "$CI_DIR/scripts/unit-tests.sh" print-summary regression "$REGRESSION_BINARY_DIR" "$SRC_DIR" "$OUTPUT_DIR_FOR_GTEST" ${{ inputs.nb_parallel_threads }}
echo "regressions_suites=$(/bin/bash "$CI_DIR/scripts/unit-tests.sh" count-test-suites regression $REGRESSION_BINARY_DIR $SRC_DIR $OUTPUT_DIR_FOR_GTEST )" > $OUTPUT_DIR/regression-tests/regression-tests_results.txt
echo "regressions_total=$(/bin/bash "$CI_DIR/scripts/unit-tests.sh" count-tests regression $REGRESSION_BINARY_DIR $SRC_DIR $OUTPUT_DIR_FOR_GTEST )" >> $OUTPUT_DIR/regression-tests/regression-tests_results.txt
echo "regressions_disabled=$(/bin/bash "$CI_DIR/scripts/unit-tests.sh" count-disabled regression $REGRESSION_BINARY_DIR $SRC_DIR $OUTPUT_DIR_FOR_GTEST )" >> $OUTPUT_DIR/regression-tests/regression-tests_results.txt
echo "regressions_failures=$(/bin/bash "$CI_DIR/scripts/unit-tests.sh" count-failures regression $REGRESSION_BINARY_DIR $SRC_DIR $OUTPUT_DIR_FOR_GTEST )" >> $OUTPUT_DIR/regression-tests/regression-tests_results.txt
echo "regressions_errors=$(/bin/bash "$CI_DIR/scripts/unit-tests.sh" count-errors regression $REGRESSION_BINARY_DIR $SRC_DIR $OUTPUT_DIR_FOR_GTEST )" >> $OUTPUT_DIR/regression-tests/regression-tests_results.txt
echo "regressions_duration=$(/bin/bash "$CI_DIR/scripts/unit-tests.sh" count-durations regression $REGRESSION_BINARY_DIR $SRC_DIR $OUTPUT_DIR_FOR_GTEST )" >> $OUTPUT_DIR/regression-tests/regression-tests_results.txt
python3 "$CI_DIR/scripts/exctractErrorFromXML.py" "$OUTPUT_DIR/regression-tests/reports" "$OUTPUT_DIR/regression-tests"
- name: Publish tests logs
id: publish-tests-logs
if: always()
uses: actions/upload-artifact@v4
with:
name: tests-logs-${{ runner.os }}
path: |
${{ inputs.output_dir }}
- name: Summarize tests results
shell: bash
run: |
if [[ "$(cd "$OUTPUT_DIR" && find . -maxdepth 1 -type f)" != "" ]]; then
echo "❌ Tests have resulted in : "
echo ""
python3 $CI_DIR/scripts/generate-tests-table.py "$OUTPUT_DIR"
echo ""
echo "#----------------------------------------#"
echo "#---------------Quick Logs---------------#"
echo "#----------------------------------------#"
for testType in 'unit' 'scene' 'regression';
do
for errorType in 'errors' 'crashes' 'failures';
do
if [ -f "$OUTPUT_DIR/${testType}-tests_${errorType}" ]; then
capitalized="$(echo "${testType:0:1}" | tr '[:lower:]' '[:upper:]')${testType:1}"
echo ""
echo -e "${bold}${capitalized} ${errorType}:${normal}"
echo ""
cat "$OUTPUT_DIR/${testType}-tests_${errorType}"
echo ""
echo "#----------------------------------------#"
fi
done
done
echo -e "${bold}You can download all logs here : ${{ steps.publish-tests-logs.outputs.artifact-url }}${normal}"
exit 1
elif [[ "${{ steps.unit-tests-step.outcome }}" == "failure" || "${{ steps.scene-tests-step.outcome }}" == "failure" || "${{ steps.regression-tests-step.outcome }}" == "failure" ]]; then
echo "❌ Something whent wrong during one of the tests steps"
echo -e "${bold}Please check this action logs, and download tests logs here: ${{ steps.publish-tests-logs.outputs.artifact-url }}${normal}"
exit 1
else
echo "✅ Tests where successful : "
echo ""
python3 $CI_DIR/scripts/generate-tests-table.py "$OUTPUT_DIR/"
echo ""
fi