Bug 1890689 accumulate input in LargerReceiverBlockSizeThanDesiredBuffering GTest...
[gecko.git] / taskcluster / scripts / misc / summarize-tgdiff.py
blob68db9bbdc7e11048626773a15f8bf301ea5295d5
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 import argparse
6 import json
7 import pathlib
10 def filter_changes(line):
11 # Skip diff headers
12 if line.startswith("---") or line.startswith("+++"):
13 return False
15 # Only count lines that changed
16 return line.startswith("-") or line.startswith("+")
19 def run():
20 parser = argparse.ArgumentParser(
21 description="Classify output of taskgraph for CI analsyis"
23 parser.add_argument(
24 "path",
25 type=pathlib.Path,
26 help="Folder containing all the TXT files from taskgraph target.",
28 parser.add_argument(
29 "threshold",
30 type=int,
31 help="Minimum number of lines to trigger a warning on taskgraph output.",
33 args = parser.parse_args()
35 out = {"files": {}, "status": "OK", "threshold": args.threshold}
36 for path in args.path.glob("*.txt"):
37 with path.open() as f:
38 nb = len(list(filter(filter_changes, f.readlines())))
40 out["files"][path.stem] = {
41 "nb": nb,
42 "status": "WARNING" if nb >= args.threshold else "OK",
45 if nb >= args.threshold:
46 out["status"] = "WARNING"
48 (args.path / "summary.json").write_text(json.dumps(out, sort_keys=True, indent=4))
51 if __name__ == "__main__":
52 run()