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/.
10 def filter_changes(line
):
12 if line
.startswith("---") or line
.startswith("+++"):
15 # Only count lines that changed
16 return line
.startswith("-") or line
.startswith("+")
20 parser
= argparse
.ArgumentParser(
21 description
="Classify output of taskgraph for CI analsyis"
26 help="Folder containing all the TXT files from taskgraph target.",
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
] = {
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__":