Repository navigation
548 lines (518 loc) · 23.6 KB
/
Copy patheeglab-reference.yml
File metadata and controls
548 lines (518 loc) · 23.6 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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
name: EEGLAB reference
on:
workflow_dispatch:
env:
# MATLAB batch licensing token (MathWorks pilot, license 1144083, expires
# 2027-01-15). It licenses matlab-batch only, not the Engine API for Python,
# so the reference tests reach MATLAB through tests/matlab/eegprep_batch_engine_serve.m
# running inside matlab-batch (client: tests/matlab_batch_engine.py).
MLM_LICENSE_TOKEN: ${{ secrets.MATLAB_BATCH_TOKEN }}
concurrency:
# v8 is not the group held by an earlier lost-runner job on this ref.
group: eeglab-reference-v8-${{ github.ref }}
cancel-in-progress: false
jobs:
reference:
name: Reference (${{ matrix.shard }})
runs-on: ubuntu-22.04
# pytest-timeout names a stuck test first. This bound fails the job when the
# runner is lost, instead of holding the concurrency group until the 180 minute default.
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
# std_precomp, std_preclust, and the full-recording runica call stay in
# their own shard. ds003061 stage comparisons stay in the parity shard.
# The other shards split the rest of the suite by file.
shard: [heavy, hybrid, stats, study, misc, core, parity]
steps:
- uses: actions/checkout@v4
with:
# Fetch the vendored EEGLAB reference itself, but not EEGLAB's nested
# plugin submodules; upstream EEGLAB can temporarily point at plugin
# commits that are unavailable for shallow GitHub Actions checkout.
submodules: true
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install Python 3.12
run: |
uv python install 3.12
- name: Install Linux GUI and BioSig libraries
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libbiosig-dev \
libegl1 \
libgl1 \
libxkbcommon-x11-0 \
libxcb-cursor0 \
libxcb-icccm4 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-randr0 \
libxcb-render-util0 \
libxcb-shape0 \
libxcb-xinerama0
echo "QT_QPA_PLATFORM=offscreen" >> "$GITHUB_ENV"
- name: Install dependencies
run: |
uv sync --python 3.12 --all-extras --group dev
- name: Read pinned EEGLAB test commits
id: pins
run: |
uv run --no-sync python - <<'PY'
import os
from tests.eeglab_tests import (
EEGLAB_TESTS_COMMIT,
EEGLAB_TESTS_EEGLAB_COMMIT,
EEGLAB_TESTS_REPOSITORY,
)
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as handle:
handle.write(f"suite-commit={EEGLAB_TESTS_COMMIT}\n")
handle.write(f"eeglab-commit={EEGLAB_TESTS_EEGLAB_COMMIT}\n")
handle.write(f"suite-repository={EEGLAB_TESTS_REPOSITORY}\n")
PY
- name: Restore eeglab_tests cache
id: eeglab-tests-cache
uses: actions/cache/restore@v4
with:
path: eeglab_tests
key: eeglab-tests-${{ steps.pins.outputs.suite-commit }}-${{ steps.pins.outputs.eeglab-commit }}
- name: Checkout eeglab_tests
if: steps.eeglab-tests-cache.outputs.cache-hit != 'true'
env:
SUITE_COMMIT: ${{ steps.pins.outputs.suite-commit }}
EEGLAB_COMMIT: ${{ steps.pins.outputs.eeglab-commit }}
SUITE_REPOSITORY: ${{ steps.pins.outputs.suite-repository }}
run: |
rm -rf eeglab_tests
git init eeglab_tests
git -C eeglab_tests remote add origin "$SUITE_REPOSITORY"
git -C eeglab_tests fetch --depth 1 origin "$SUITE_COMMIT"
git -C eeglab_tests checkout --detach FETCH_HEAD
if [[ "$(git -C eeglab_tests rev-parse HEAD)" != "$SUITE_COMMIT" ]]; then
echo "::error title=eeglab_tests pin mismatch::HEAD is not $SUITE_COMMIT"
exit 1
fi
# eeglab_tests records its EEGLAB submodule as [email protected], and the
# runner has no SSH key. submodule update does not apply insteadOf to
# that URL, so point this checkout at the public HTTPS remote.
git -C eeglab_tests submodule set-url eeglab https://github.com/sccn/eeglab.git
git -C eeglab_tests submodule sync -- eeglab
git -C eeglab_tests submodule update --init --depth 1 -- eeglab
if [[ "$(git -C eeglab_tests/eeglab rev-parse HEAD)" != "$EEGLAB_COMMIT" ]]; then
echo "::error title=EEGLAB pin mismatch::suite submodule is not $EEGLAB_COMMIT"
exit 1
fi
- name: Save eeglab_tests cache
if: steps.eeglab-tests-cache.outputs.cache-hit != 'true' && matrix.shard == 'heavy'
uses: actions/cache/save@v4
with:
path: eeglab_tests
key: eeglab-tests-${{ steps.pins.outputs.suite-commit }}-${{ steps.pins.outputs.eeglab-commit }}
# ds003061 is in the eeglab_tests checkout. ds003194 is not, and the
# OpenNeuro import comparison reads snapshot 1.0.3 from openneuro/ds003194.
- name: Restore ds003194 cache
id: ds003194-cache
uses: actions/cache/restore@v4
with:
path: openneuro/ds003194
key: openneuro-ds003194-1.0.3-nepo01
- name: Fetch ds003194
if: steps.ds003194-cache.outputs.cache-hit != 'true'
shell: bash
run: |
set -euo pipefail
root="openneuro/ds003194"
base="https://s3.amazonaws.com/openneuro.org/ds003194"
rm -rf "$root"
while read -r name expect; do
mkdir -p "$root/$(dirname "$name")"
curl -fsSL --retry 3 --retry-delay 2 -o "$root/$name" "$base/$name"
actual=$(md5sum "$root/$name" | awk '{print $1}')
if [[ "$actual" != "$expect" ]]; then
echo "::error title=ds003194 checksum::$name is $actual, expected $expect"
exit 1
fi
done <<'EOF'
dataset_description.json d6c9c445496b24e7076212a411576642
participants.tsv 16a17f7dfb39a7ae04d252625d507999
sub-NEPO01/ses-Nepopre/eeg/sub-NEPO01_ses-Nepopre_task-taskprenepo_eeg.edf bc0195c10cb4cd4e0060da2aa038a540
sub-NEPO01/ses-Nepopre/eeg/sub-NEPO01_ses-Nepopre_task-taskprenepo_eeg.json c98296e820b362c11aefc675f7f4655d
sub-NEPO01/ses-Nepopre/eeg/sub-NEPO01_ses-Nepopre_task-taskprenepo_channels.tsv f42d3d659f616806327448396e9f126d
sub-NEPO01/ses-Nepopre/eeg/sub-NEPO01_ses-Nepopre_task-taskprenepo_events.tsv 615c998fd0a5379290590210248aab43
EOF
- name: Save ds003194 cache
if: steps.ds003194-cache.outputs.cache-hit != 'true' && matrix.shard == 'heavy'
uses: actions/cache/save@v4
with:
path: openneuro/ds003194
key: openneuro-ds003194-1.0.3-nepo01
- name: Require MATLAB batch token
run: |
if [[ -z "$MLM_LICENSE_TOKEN" ]]; then
echo "::error title=MATLAB batch token missing::MATLAB_BATCH_TOKEN is not available to this workflow"
exit 1
fi
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
with:
release: R2024b
# EEGLAB's reference functions need resample/firls/pwelch, statistics
# functions (tcdf, ttest, kmeans, ...), and Optimization Toolbox
# fminunc for DIPFIT/FieldTrip coregistration and dipole fitting parity.
products: >-
MATLAB
Signal_Processing_Toolbox
Statistics_and_Machine_Learning_Toolbox
Optimization_Toolbox
- name: Locate MATLAB root
shell: bash
run: |
MATLAB_ROOT=$(python3 - <<'PY'
import os
from pathlib import Path
tool_cache = Path(os.environ.get("RUNNER_TOOL_CACHE", "")) / "MATLAB"
candidates = sorted(tool_cache.glob("*/x64"))
if not candidates:
raise SystemExit(f"No MATLAB installation found under {tool_cache}")
print(candidates[-1])
PY
)
echo "MATLAB_ROOT=$MATLAB_ROOT" >> $GITHUB_ENV
echo "$MATLAB_ROOT/bin" >> $GITHUB_PATH
- name: Fetch EEGLAB plugin submodules
shell: bash
working-directory: src/eegprep/eeglab
run: |
# One plugin at a time: a missing upstream commit costs one plugin, not the lane.
for path in $(git config -f .gitmodules --get-regexp path | awk '{print $2}'); do
if ! git submodule update --init --recursive --depth 1 -- "$path"; then
echo "::warning title=EEGLAB plugin unavailable::Could not fetch $path; parity tests needing it will fail"
fi
done
- name: Install optional EEGLAB plugins
shell: bash
working-directory: src/eegprep/eeglab
run: |
# Fileio, Biosig, and Fieldtrip-lite are extension zips, not git submodules.
# JSONio ships inside the EEG-BIDS submodule (plugins/EEG-BIDS/JSONio).
plugin_dir="plugins"
mkdir -p "$plugin_dir"
download() {
name="$1"
url="$2"
zip="$RUNNER_TEMP/${name}.zip"
if curl -fsSL --retry 3 --retry-delay 2 -o "$zip" "$url"; then
unzip -q -o "$zip" -d "$plugin_dir"
else
echo "::warning title=EEGLAB plugin unavailable::Could not download ${name}; tests that need it will skip"
fi
}
download Fieldtrip-lite "http://sccn.ucsd.edu/eeglab/plugins/fieldtrip-lite-20250523.zip"
download Fileio "http://sccn.ucsd.edu/eeglab/plugins/fileio260210.zip"
download Biosig "http://sccn.ucsd.edu/eeglab/plugins/Biosig3.8.5.zip"
# mind-inria/picard 617ce6a starts from the identity. EEGLAB PICARD 2.0
# draws a seeded random unmixing matrix and does not match eeg_picard.
picard_commit="617ce6ae669cfbd1dfedba6a5fce39a602b99ac3"
picard_src="$RUNNER_TEMP/picard-src"
picard_dest="$plugin_dir/PICARD"
rm -rf "$picard_src" "$picard_dest"
if git init "$picard_src" \
&& git -C "$picard_src" remote add origin https://github.com/mind-inria/picard.git \
&& git -C "$picard_src" fetch --depth 1 origin "$picard_commit" \
&& git -C "$picard_src" checkout --detach FETCH_HEAD; then
mkdir -p "$picard_dest"
cp -a "$picard_src/matlab_octave/." "$picard_dest/"
printf '%s\n' \
'function vers = eegplugin_picard(~, ~, ~)' \
"vers = '617ce6a';" \
"addpath(fileparts(mfilename('fullpath')));" \
> "$picard_dest/eegplugin_picard.m"
else
echo "::warning title=EEGLAB plugin unavailable::Could not fetch mind-inria/picard; Picard parity tests will skip"
rm -rf "$picard_dest"
fi
# bva-io is a git repo, not one of the extension zips. pop_loadbv.m is at the root.
bva="$plugin_dir/bva-io"
if git init "$bva" \
&& git -C "$bva" remote add origin https://github.com/sccn/bva-io.git \
&& git -C "$bva" fetch --depth 1 origin d5fe22f69aadc40139e916067ca63cb52f79978a \
&& git -C "$bva" checkout --detach FETCH_HEAD; then
:
else
echo "::warning title=EEGLAB plugin unavailable::Could not fetch bva-io; pop_loadbv tests will skip"
rm -rf "$bva"
fi
# Fileio 20260210 calls ft_deleteopt, which FieldTrip-lite 20250523 does not ship yet.
ft_util=$(echo plugins/fieldtrip-*/utilities)
if [[ -d "$ft_util" ]]; then
curl -fsSL --retry 3 -o "$ft_util/ft_deleteopt.m" \
"https://raw.githubusercontent.com/fieldtrip/fieldtrip/267ca56c1045d8ae0da72d05566da52db8b1cd09/utilities/ft_deleteopt.m" \
|| echo "::warning title=EEGLAB plugin unavailable::Could not fetch ft_deleteopt; Fileio tests will skip"
fi
- name: Start MATLAB through matlab-batch
id: matlab-batch
shell: bash
run: |
BATCH_DIR="$RUNNER_TEMP/eegprep-matlab-batch"
mkdir -p "$BATCH_DIR"
# Stop eeglab nogui from blocking on the plugin-version server.
cp "$GITHUB_WORKSPACE/src/eegprep/eeglab/functions/adminfunc/eeg_options.m" "$HOME/eeg_options.m"
printf '\noption_checkversion = 0;\n' >> "$HOME/eeg_options.m"
EEGLAB_ROOT="$GITHUB_WORKSPACE/src/eegprep/eeglab"
TESTS_MATLAB="$GITHUB_WORKSPACE/tests/matlab"
# setsid makes the pid the group leader so a wedged eval can be killed.
setsid matlab-batch "addpath('$TESTS_MATLAB'); eegprep_batch_engine_serve('$BATCH_DIR')" \
> "$BATCH_DIR/server.log" 2>&1 &
echo $! > "$BATCH_DIR/server.pid"
cat > "$BATCH_DIR/restart.sh" <<EOF
#!/bin/bash
set -u
if [[ -f "$BATCH_DIR/quit" ]]; then
exit 0
fi
if [[ -f "$BATCH_DIR/server.pid" ]]; then
pid=\$(cat "$BATCH_DIR/server.pid")
kill -TERM -- "-\$pid" 2>/dev/null || kill -TERM "\$pid" 2>/dev/null || true
for _ in \$(seq 1 20); do
kill -0 "\$pid" 2>/dev/null || break
sleep 0.5
done
kill -KILL -- "-\$pid" 2>/dev/null || kill -KILL "\$pid" 2>/dev/null || true
fi
rm -f "$BATCH_DIR"/req_*.mat "$BATCH_DIR"/req_*.part "$BATCH_DIR"/res_*.mat "$BATCH_DIR"/res_*.part "$BATCH_DIR/ready"
setsid matlab-batch "addpath('$TESTS_MATLAB'); eegprep_batch_engine_startup('$EEGLAB_ROOT'); eegprep_batch_engine_serve('$BATCH_DIR')" >> "$BATCH_DIR/server.log" 2>&1 &
echo \$! > "$BATCH_DIR/server.pid"
EOF
# The heredoc above is indented; strip the leading spaces the workflow added.
sed -i 's/^ //' "$BATCH_DIR/restart.sh"
for i in $(seq 1 180); do
[[ -f "$BATCH_DIR/ready" ]] && break
if ! kill -0 "$(cat "$BATCH_DIR/server.pid")" 2>/dev/null; then break; fi
sleep 2
done
if [[ ! -f "$BATCH_DIR/ready" ]]; then
echo "::error title=MATLAB did not start::see server.log below"
cat "$BATCH_DIR/server.log"
exit 1
fi
echo "EEGPREP_MATLAB_BATCH_DIR=$BATCH_DIR" >> "$GITHUB_ENV"
echo "EEGPREP_SKIP_MATLAB=0" >> "$GITHUB_ENV"
- name: Run EEGLAB reference tests
shell: bash
run: |
set -euo pipefail
mkdir -p reference-results
heavy_k="test_reference_std_precomp or test_reference_std_preclust or test_reference_runica_original_recording_and_defaults"
not_heavy_k="not test_reference_std_precomp and not test_reference_std_preclust and not test_reference_runica_original_recording_and_defaults"
heavy_files=(
tests/test_study_workflows_eeglab_tests.py
tests/test_popfunc_dataset_eeglab_tests.py
)
hybrid_files=(tests/test_eeglab_hybrid.py)
stats_files=(
tests/test_statcond_eeglab_tests.py
tests/test_mmo_eeglab_tests.py
tests/test_statcondfieldtrip_eeglab_tests.py
tests/test_statistics_package.py
)
study_files=(
"${heavy_files[@]}"
tests/test_study_grouped_measure_plots_eeglab_tests.py
tests/test_study_dipplot_eeglab_tests.py
tests/test_study_params_eeglab_tests.py
tests/test_tutorial_eeglab_tests.py
tests/test_limo_eeglab_tests.py
tests/test_sample_data_pop_functions.py
tests/test_popfunc_visual_eeglab_tests.py
tests/test_phase2_file_channel_location.py
tests/test_core_event_eeglab_tests.py
tests/test_clean_rawdata_eeglab_tests.py
tests/test_sigprocfunc_numerical_eeglab_tests.py
tests/test_sigprocfunc_plotting_eeglab_tests.py
tests/test_sigprocfunc_ica_legacy_eeglab_tests.py
)
# MATLAB-heavy files that previously made the remainder shard the long pole.
misc_files=(
tests/test_miscfunc_numerical_eeglab_tests.py
tests/test_misc_visual_movie_eeglab_tests.py
tests/test_phase7_long_tail_helpers.py
tests/test_binary_eeglab_tests.py
tests/test_miscfunc_decomposition_eeglab_tests.py
tests/test_pop_editeventfield_current.py
tests/test_legacy_signal_io_eeglab_tests.py
tests/test_rejection_workflows.py
tests/test_pop_topoplot.py
tests/test_phase1b_file_edit_pop_functions.py
tests/test_misc_data_event_eeglab_tests.py
tests/test_eegh.py
tests/test_getkeyval.py
tests/test_runica.py
tests/test_eegplot.py
tests/test_erpimage.py
tests/test_phase4_plot_wrappers.py
tests/test_phase4_timefreq_statistics.py
tests/test_eeg_store.py
tests/test_bdf_records_eeglab_tests.py
tests/test_eeg_lat2point.py
tests/test_eeg_point2lat.py
tests/test_eeglab_execmenu.py
)
parity_files=(
tests/test_ds003061_stage_parity.py
)
case "${{ matrix.shard }}" in
heavy)
args=("${heavy_files[@]}" -k "$heavy_k")
;;
hybrid)
args=("${hybrid_files[@]}")
;;
stats)
args=("${stats_files[@]}")
;;
study)
args=("${study_files[@]}" -k "$not_heavy_k")
;;
misc)
args=("${misc_files[@]}")
;;
parity)
args=("${parity_files[@]}")
;;
core)
args=(tests)
for path in "${hybrid_files[@]}" "${stats_files[@]}" "${study_files[@]}" "${misc_files[@]}" "${parity_files[@]}"; do
args+=(--ignore="$path")
done
;;
*)
echo "::error title=Unknown shard::${{ matrix.shard }}"
exit 1
;;
esac
echo "pytest ${args[*]}"
set +e
SECONDS=0
export PYTHONUNBUFFERED=1
# The runner is SIGTERM'd on cgroup memory pressure before artifact
# upload, so stream the MATLAB log and a memory sample into this step.
if [[ -n "${EEGPREP_MATLAB_BATCH_DIR:-}" && -f "$EEGPREP_MATLAB_BATCH_DIR/server.log" ]]; then
tail -n 0 -f "$EEGPREP_MATLAB_BATCH_DIR/server.log" | grep -F -v --line-buffered "$MLM_LICENSE_TOKEN" &
fi
(
while true; do
printf '%s mem ' "$(date -u +%H:%M:%S)"
free -m | awk 'NR==2 {print "total="$2, "used="$3, "free="$4, "available="$7}'
sleep 30
done
) &
uv run --no-sync pytest \
-vv \
--eeglab-backend=matlab \
--eeglab-root="$GITHUB_WORKSPACE/src/eegprep/eeglab" \
--eeglab-suite-root="$GITHUB_WORKSPACE/eeglab_tests" \
--timeout=1200 \
--timeout-method=signal \
--durations=0 \
--junitxml="$GITHUB_WORKSPACE/reference-results/junit.xml" \
"${args[@]}" \
| tee reference-results/pytest.log
status=${PIPESTATUS[0]}
echo "$SECONDS" > reference-results/wall-seconds.txt
awk '/durations/{flag=1} flag' reference-results/pytest.log > reference-results/durations.txt
exit "$status"
- name: Upload junit and durations
if: always()
uses: actions/upload-artifact@v4
with:
name: eeglab-reference-${{ matrix.shard }}
path: reference-results/
if-no-files-found: warn
- name: Stop MATLAB
if: always() && steps.matlab-batch.outcome == 'success'
shell: bash
run: |
touch "$EEGPREP_MATLAB_BATCH_DIR/quit"
for i in $(seq 1 30); do
kill -0 "$(cat "$EEGPREP_MATLAB_BATCH_DIR/server.pid")" 2>/dev/null || break
sleep 1
done
echo "--- matlab-batch server log (tail)"
tail -n 60 "$EEGPREP_MATLAB_BATCH_DIR/server.log" | grep -v "$MLM_LICENSE_TOKEN" || true
summary:
name: Reference summary
needs: reference
if: always()
runs-on: ubuntu-22.04
timeout-minutes: 20
steps:
- name: Download shard results
if: always()
continue-on-error: true
uses: actions/download-artifact@v4
with:
pattern: eeglab-reference-*
path: artifacts
- name: Print wall time and slowest tests
if: always()
run: |
python3 - <<'PY'
import xml.etree.ElementTree as ET
from pathlib import Path
root = Path("artifacts")
if not root.is_dir():
print("No shard artifacts were uploaded.")
raise SystemExit(0)
rows = []
cases = []
for shard_dir in sorted(path for path in root.iterdir() if path.is_dir()):
shard = shard_dir.name.removeprefix("eeglab-reference-")
wall_path = next(shard_dir.rglob("wall-seconds.txt"), None)
wall = int(wall_path.read_text().strip() or "0") if wall_path is not None else 0
pytest_time = passed = failed = skipped = 0
shard_cases = []
for junit in shard_dir.rglob("junit*.xml"):
tree = ET.parse(junit)
for suite in tree.iter("testsuite"):
tests = int(suite.get("tests") or 0)
failures = int(suite.get("failures") or 0)
errors = int(suite.get("errors") or 0)
suite_skipped = int(suite.get("skipped") or 0)
pytest_time += float(suite.get("time") or 0)
failed += failures + errors
skipped += suite_skipped
passed += tests - failures - errors - suite_skipped
for case in tree.iter("testcase"):
file = case.get("file") or case.get("classname") or ""
name = case.get("name") or ""
duration = float(case.get("time") or 0)
shard_cases.append((duration, f"{file}::{name}"))
cases.append((duration, f"{file}::{name}", shard))
rows.append((shard, wall, pytest_time, passed, failed, skipped, shard_cases))
def clock(seconds: float) -> str:
whole = int(round(seconds))
minutes, secs = divmod(whole, 60)
hours, minutes = divmod(minutes, 60)
return f"{hours}:{minutes:02d}:{secs:02d}"
print("shard wall pytest passed failed skipped")
for shard, wall, pytest_time, passed, failed, skipped, _cases in rows:
print(f"{shard:<10} {clock(wall):<10} {clock(pytest_time):<10} {passed:<7} {failed:<7} {skipped:<7}")
print("10 slowest tests per shard:")
for shard, _wall, _pytest_time, _passed, _failed, _skipped, shard_cases in rows:
print(f" {shard}")
if not shard_cases:
print(" (no junit results)")
continue
for duration, nodeid in sorted(shard_cases, reverse=True)[:10]:
print(f" {duration:8.2f}s {nodeid}")
print("Slowest 30 tests:")
if not cases:
print(" (no junit results were uploaded)")
for duration, nodeid, shard in sorted(cases, reverse=True)[:30]:
print(f" {duration:8.2f}s {nodeid} [{shard}]")
PY