mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
* ci: surface per-class timings from the compatibility test legs The slowest compatibility leg (sdk-test-java, ~10 minutes) is a black box: the container entrypoint runs the build tool quietly, so the job log shows pass/fail but no per-class times, and the junit XMLs the suites already export to test-results/ are discarded after the summary step. - Report the slowest 25 classes (and the suite total) in the job log and step summary, parsed from the exported junit XMLs. - Upload test-results/ as a per-leg artifact so timings are machine-readable across runs. - Extend the leg's sparse checkout to include .github/ci for the parser. No test behavior changes; the report step never fails the job. * ci: retrigger compatibility legs when the timing parser changes * ci: make the timing reporter total and the report step non-fatal The reporter promised it never fails the job, but only ET.ParseError was caught: a locale-formatted time attribute (ValueError) or an unreadable path (OSError) would exit non-zero and fail an otherwise-green leg. Catch both with a stderr warning naming the file, and add continue-on-error to the report step so the property holds regardless of parser changes.
45 lines
1.7 KiB
Python
Executable File
45 lines
1.7 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Print per-class timings from junit XMLs, slowest first.
|
|
|
|
Usage: compat-timing-report.py <results-dir>
|
|
Also appends the table to GITHUB_STEP_SUMMARY when set. Never fails the job:
|
|
bad or absent XMLs produce an empty report, not an error.
|
|
"""
|
|
import glob
|
|
import os
|
|
import sys
|
|
import xml.etree.ElementTree as ET
|
|
|
|
def main():
|
|
d = sys.argv[1] if len(sys.argv) > 1 else 'test-results'
|
|
rows = []
|
|
for f in glob.glob(os.path.join(d, '*.xml')):
|
|
try:
|
|
root = ET.parse(f).getroot()
|
|
except (ET.ParseError, OSError) as exc:
|
|
print(f'warning: skipping unreadable JUnit XML {f}: {exc}', file=sys.stderr)
|
|
continue
|
|
suites = root.iter('testsuite') if root.tag != 'testsuite' else [root]
|
|
for ts in suites:
|
|
try:
|
|
rows.append((float(ts.get('time') or 0), int(ts.get('tests') or 0),
|
|
ts.get('name') or os.path.basename(f)))
|
|
except ValueError as exc:
|
|
print(f'warning: skipping suite with non-numeric attributes in {f}: {exc}',
|
|
file=sys.stderr)
|
|
rows.sort(reverse=True)
|
|
total_t = sum(r[0] for r in rows)
|
|
total_n = sum(r[1] for r in rows)
|
|
lines = [f'== {len(rows)} suites, {total_n} tests, {total_t / 60:.1f} min total test time',
|
|
'== slowest 25 classes:']
|
|
lines += [f'{t:8.1f}s {n:5d} tests {name}' for t, n, name in rows[:25]]
|
|
report = '\n'.join(lines)
|
|
print(report)
|
|
summary = os.environ.get('GITHUB_STEP_SUMMARY')
|
|
if summary:
|
|
with open(summary, 'a') as fh:
|
|
fh.write('```\n' + report + '\n```\n')
|
|
|
|
if __name__ == '__main__':
|
|
main()
|