Add markdown test summaries and a coverage HTML report to CI
CI / build-image (arm64, ubuntu-latest-arm64) (push) Successful in 24s
CI / build-image (amd64, ubuntu-latest-amd64) (push) Successful in 42s
CI / pre-commit (push) Successful in 33s
CI / release (arm64, ubuntu-latest-arm64) (push) Failing after 1m4s
CI / test (-DCMAKE_BUILD_TYPE=Debug, debug) (push) Successful in 2m42s
CI / test (-DCMAKE_CXX_FLAGS=-DUSE_64_BIT=1, 64-bit-versions) (push) Successful in 2m37s
CI / test (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc) (push) Successful in 2m47s
CI / test (-DUSE_SIMD_FALLBACK=ON, simd-fallback) (push) Successful in 2m36s
CI / release (amd64, ubuntu-latest-amd64) (push) Failing after 2m42s
CI / coverage (push) Has been cancelled
CI / build-image (arm64, ubuntu-latest-arm64) (push) Successful in 24s
CI / build-image (amd64, ubuntu-latest-amd64) (push) Successful in 42s
CI / pre-commit (push) Successful in 33s
CI / release (arm64, ubuntu-latest-arm64) (push) Failing after 1m4s
CI / test (-DCMAKE_BUILD_TYPE=Debug, debug) (push) Successful in 2m42s
CI / test (-DCMAKE_CXX_FLAGS=-DUSE_64_BIT=1, 64-bit-versions) (push) Successful in 2m37s
CI / test (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc) (push) Successful in 2m47s
CI / test (-DUSE_SIMD_FALLBACK=ON, simd-fallback) (push) Successful in 2m36s
CI / release (amd64, ubuntu-latest-amd64) (push) Failing after 2m42s
CI / coverage (push) Has been cancelled
ctest_summary.py renders a Test.xml as markdown for GITHUB_STEP_SUMMARY: a one-liner when everything passes, otherwise the first few failures inline with a link to the full Test.xml on MinIO. It's also usable locally with --all to list every failure from a downloaded Test.xml. The coverage job now also generates and uploads gcovr's html-details report and links it from the step summary.
This commit is contained in:
@@ -112,6 +112,13 @@ jobs:
|
|||||||
zstd build/Testing/*/Test.xml
|
zstd build/Testing/*/Test.xml
|
||||||
mc cp build/Testing/*/Test.xml.zst "minio/jenkins/conflict-set/${{ gitea.run_number }}/${{ matrix.name }}/"
|
mc cp build/Testing/*/Test.xml.zst "minio/jenkins/conflict-set/${{ gitea.run_number }}/${{ matrix.name }}/"
|
||||||
|
|
||||||
|
- name: Test summary
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
python3 ctest_summary.py build/Testing/*/Test.xml \
|
||||||
|
--link "https://minio.weaselab.dev/jenkins/conflict-set/${{ gitea.run_number }}/${{ matrix.name }}/Test.xml.zst" \
|
||||||
|
>> "$GITHUB_STEP_SUMMARY"
|
||||||
|
|
||||||
release:
|
release:
|
||||||
needs: build-image
|
needs: build-image
|
||||||
strategy:
|
strategy:
|
||||||
@@ -193,6 +200,13 @@ jobs:
|
|||||||
mc cp paper/*.pdf "$dest"
|
mc cp paper/*.pdf "$dest"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Test summary
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
python3 ctest_summary.py build/Testing/*/Test.xml \
|
||||||
|
--link "https://minio.weaselab.dev/jenkins/conflict-set/${{ gitea.run_number }}/release-${{ matrix.arch }}/Test.xml.zst" \
|
||||||
|
>> "$GITHUB_STEP_SUMMARY"
|
||||||
|
|
||||||
coverage:
|
coverage:
|
||||||
needs: build-image
|
needs: build-image
|
||||||
runs-on: ubuntu-latest-amd64
|
runs-on: ubuntu-latest-amd64
|
||||||
@@ -232,6 +246,8 @@ jobs:
|
|||||||
--gcov-executable "llvm-cov gcov" --exclude-noncode-lines)
|
--gcov-executable "llvm-cov gcov" --exclude-noncode-lines)
|
||||||
gcovr "${gcov_args[@]}" --cobertura > build/coverage.xml
|
gcovr "${gcov_args[@]}" --cobertura > build/coverage.xml
|
||||||
gcovr "${gcov_args[@]}"
|
gcovr "${gcov_args[@]}"
|
||||||
|
mkdir -p build/coverage_html
|
||||||
|
gcovr "${gcov_args[@]}" --html-details build/coverage_html/index.html
|
||||||
gcovr "${gcov_args[@]}" --fail-under-line 100 > /dev/null
|
gcovr "${gcov_args[@]}" --fail-under-line 100 > /dev/null
|
||||||
|
|
||||||
- name: Upload results to MinIO
|
- name: Upload results to MinIO
|
||||||
@@ -250,3 +266,15 @@ jobs:
|
|||||||
if [ -e build/coverage.xml ]; then
|
if [ -e build/coverage.xml ]; then
|
||||||
mc cp build/coverage.xml "$dest"
|
mc cp build/coverage.xml "$dest"
|
||||||
fi
|
fi
|
||||||
|
if [ -d build/coverage_html ]; then
|
||||||
|
mc cp -r build/coverage_html "$dest"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Test summary
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
python3 ctest_summary.py build/Testing/*/Test.xml \
|
||||||
|
--link "https://minio.weaselab.dev/jenkins/conflict-set/${{ gitea.run_number }}/coverage/Test.xml.zst" \
|
||||||
|
>> "$GITHUB_STEP_SUMMARY"
|
||||||
|
echo "" >> "$GITHUB_STEP_SUMMARY"
|
||||||
|
echo "📊 [Coverage report](https://minio.weaselab.dev/jenkins/conflict-set/${{ gitea.run_number }}/coverage/coverage_html/index.html)" >> "$GITHUB_STEP_SUMMARY"
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Summarize a CTest Test.xml as markdown.
|
||||||
|
|
||||||
|
Intended for $GITHUB_STEP_SUMMARY in CI, where only the first few failures
|
||||||
|
are shown inline (pass --link to point at the full Test.xml). Also reusable
|
||||||
|
locally to print every failure from a downloaded Test.xml with --all.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import base64
|
||||||
|
import gzip
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
|
# Failure output is truncated to this many trailing characters, which is
|
||||||
|
# usually enough to include e.g. an ASan report's summary.
|
||||||
|
OUTPUT_TAIL_CHARS = 3000
|
||||||
|
|
||||||
|
|
||||||
|
def test_output(test):
|
||||||
|
value = test.find("./Results/Measurement/Value")
|
||||||
|
if value is None or value.text is None:
|
||||||
|
return ""
|
||||||
|
text = value.text
|
||||||
|
if value.get("encoding") == "base64":
|
||||||
|
raw = base64.b64decode(text)
|
||||||
|
if value.get("compression") == "gzip":
|
||||||
|
raw = gzip.decompress(raw)
|
||||||
|
text = raw.decode(errors="replace")
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument("test_xml", help="path to a ctest Testing/*/Test.xml")
|
||||||
|
parser.add_argument(
|
||||||
|
"--inline",
|
||||||
|
type=int,
|
||||||
|
default=5,
|
||||||
|
help="how many failures to show inline (default 5)",
|
||||||
|
)
|
||||||
|
parser.add_argument("--all", action="store_true", help="show every failure inline")
|
||||||
|
parser.add_argument(
|
||||||
|
"--link", help="URL of the full Test.xml, linked when failures are elided"
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
testing = ET.parse(args.test_xml).getroot().find("Testing")
|
||||||
|
tests = testing.findall("Test")
|
||||||
|
failed = [t for t in tests if t.get("Status") == "failed"]
|
||||||
|
notrun = sum(1 for t in tests if t.get("Status") == "notrun")
|
||||||
|
|
||||||
|
if not failed:
|
||||||
|
print(f"✅ All {len(tests) - notrun} tests passed")
|
||||||
|
else:
|
||||||
|
print(f"❌ {len(failed)} of {len(tests)} tests failed\n")
|
||||||
|
shown = failed if args.all else failed[: args.inline]
|
||||||
|
for test in shown:
|
||||||
|
name = test.findtext("Name")
|
||||||
|
output = test_output(test)[-OUTPUT_TAIL_CHARS:].strip()
|
||||||
|
print(f"<details><summary><code>{name}</code></summary>\n")
|
||||||
|
print("````")
|
||||||
|
print(output)
|
||||||
|
print("````")
|
||||||
|
print("</details>\n")
|
||||||
|
remaining = len(failed) - len(shown)
|
||||||
|
if remaining > 0:
|
||||||
|
more = f"… and {remaining} more"
|
||||||
|
if args.link:
|
||||||
|
more += f" — full list in [Test.xml]({args.link})"
|
||||||
|
print(more)
|
||||||
|
if notrun:
|
||||||
|
print(f"\n⚠️ {notrun} tests not run")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user