summaryrefslogtreecommitdiffstats
path: root/.github/scripts/tests
diff options
context:
space:
mode:
authorErmoshkin Artem <[email protected]>2026-06-11 13:24:02 +0300
committerGitHub <[email protected]>2026-06-11 13:24:02 +0300
commit537adb4fd4e93608194e2c2342af8cd6aa446c79 (patch)
tree96089bf30c8c93787e565ec0b165ea54a9f52e82 /.github/scripts/tests
parentbb795cd44a80706e39e5267813b51934a85ee6e6 (diff)
add cpp sdk code coverage action to the ci (#43128)
Co-authored-by: Artem Ermoshkin <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Diffstat (limited to '.github/scripts/tests')
-rwxr-xr-x.github/scripts/tests/compare_cpp_sdk_coverage.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/.github/scripts/tests/compare_cpp_sdk_coverage.py b/.github/scripts/tests/compare_cpp_sdk_coverage.py
new file mode 100755
index 00000000000..13b6f6c8561
--- /dev/null
+++ b/.github/scripts/tests/compare_cpp_sdk_coverage.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+import json
+import re
+import sys
+from pathlib import Path
+
+
+def line_pct(report_dir: str) -> float:
+ html = (Path(report_dir) / "index.html").read_text(encoding="utf-8", errors="replace")
+ match = re.search(r"Lines:</td>\s*<td[^>]*>([\d.]+)\s*%", html, re.I)
+ if not match:
+ raise SystemExit(f"line coverage not found in {report_dir}/index.html")
+ return float(match.group(1))
+
+
+if __name__ == "__main__":
+ if len(sys.argv) < 2:
+ raise SystemExit("usage: compare_cpp_sdk_coverage.py {extract|check} ...")
+
+ cmd = sys.argv[1]
+ if cmd == "extract":
+ if len(sys.argv) != 4:
+ raise SystemExit("usage: compare_cpp_sdk_coverage.py extract <report_dir> <out_json>")
+ with open(sys.argv[3], "w", encoding="utf-8") as f:
+ json.dump({"line_pct": line_pct(sys.argv[2])}, f)
+ elif cmd == "check":
+ if len(sys.argv) != 4:
+ raise SystemExit("usage: compare_cpp_sdk_coverage.py check <current_json> <baseline_json>")
+ with open(sys.argv[2], encoding="utf-8") as f:
+ current = json.load(f)["line_pct"]
+ with open(sys.argv[3], encoding="utf-8") as f:
+ baseline = json.load(f)["line_pct"]
+ print(f"CPP SDK line coverage: {current}% (baseline: {baseline}%)", file=sys.stderr)
+ sys.exit(1 if current < baseline else 0)
+ else:
+ raise SystemExit(f"unknown command: {cmd}")