Skip to content

Commit

Permalink
python: run black, easier on the eye
Browse files Browse the repository at this point in the history
Signed-off-by: Øyvind Harboe <[email protected]>
  • Loading branch information
oharboe committed Nov 19, 2024
1 parent 8a3b8c6 commit a1807ad
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions jenkins/genReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import sys
import argparse


def write_summary(output_file, summary_data):
"""
Writes summary to output file and creates any directories in the output_file's path
Expand All @@ -39,6 +40,7 @@ def write_summary(output_file, summary_data):
out_fh.write("\n".join(summary_data["info"]))
out_fh.write("\n")


def read_log(input_file):
"""
Reads the build log and extracts any interesting errors or info to include
Expand All @@ -48,25 +50,34 @@ def read_log(input_file):
file output to include in the summary
"""

summary_data = { "errors": [], "info": [] }
summary_data = {"errors": [], "info": []}
orfs_regex_error = re.compile(r"^\[error ?(\w+-\d+)?\]", re.IGNORECASE)
bazel_regex_error = re.compile(r"^error:", re.IGNORECASE)
regex_hitrate = re.compile(r"^INFO\:\s+\d+\s+processes\:\s+\d+\s+remote\s+cache\s+hit")
regex_hitrate = re.compile(
r"^INFO\:\s+\d+\s+processes\:\s+\d+\s+remote\s+cache\s+hit"
)

with open(input_file, "r") as in_fh:
for line in in_fh:
if orfs_regex_error.match(line):
summary_data["errors"].append(line.strip())
elif re.search(bazel_regex_error, line):
summary_data["errors"].append(line.strip())
elif line.startswith("INFO: Elapsed time") or re.search(regex_hitrate, line) or line.startswith("INFO: Build completed successfully"):
elif (
line.startswith("INFO: Elapsed time")
or re.search(regex_hitrate, line)
or line.startswith("INFO: Build completed successfully")
):
summary_data["info"].append(line.strip())
return summary_data


# Define args and defaults
parser = argparse.ArgumentParser(prog="genReport.py")
parser.add_argument("-i", "--input_file", help="Bazel build log", default="build.log")
parser.add_argument("-o", "--output_file", help="Summary log", default="flow/reports/report-summary.log")
parser.add_argument(
"-o", "--output_file", help="Summary log", default="flow/reports/report-summary.log"
)

args = parser.parse_args()

Expand Down

0 comments on commit a1807ad

Please sign in to comment.