Skip to content

Commit 2b93d1f

Browse files
ci: handle no error message (#728)
In some rare cases, the flow does not finish and there's no error message. In such cases, print last 10 lines of the log. Signed-off-by: Vitor Bandeira <[email protected]>
1 parent bfe8d93 commit 2b93d1f

File tree

1 file changed

+61
-11
lines changed

1 file changed

+61
-11
lines changed

flow/util/genReport.py

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
SINGLE_REPORT_FILENAME = f"{REPORTS_FOLDER}/report.log"
1515
SUMMARY_FILENAME = f"{REPORTS_FOLDER}/report-summary.log"
1616
DRC_FILENAME = '5_route_drc.rpt'
17-
LAST_EXPECTED_LOG = '6_report.log'
17+
LAST_EXPECTED_LOG = ['6_report.log', 'generate_abstract.log']
1818
METRICS_LOG_FMT = 'gen-metrics-{}-check.log'
1919
METRICS_CHECK_FMT = '{}/metadata-{}-check.log'
2020
REGEX_ERROR = re.compile(r"^\[error ?(\w+-\d+)?\]", re.IGNORECASE)
@@ -112,16 +112,56 @@ def gen_report(name, data):
112112
else:
113113
output = ""
114114

115-
output = append_text(data['log_errors'], output, 'errors in the logs', REGEX_ERROR, args.verbose)
116-
output = append_text(data['metrics_logs_errors'], output, 'errors in the metrics logs', REGEX_ERROR, args.verbose)
117-
output = append_text(data['metrics_errors'], output, 'metrics failures', REGEX_ERROR, args.verbose)
118-
output = append_text(data['calibre_errors'], output, 'calibre failures', REGEX_ERROR, args.verbose)
115+
output = append_text(
116+
data['log_errors'],
117+
output,
118+
'errors in the logs',
119+
REGEX_ERROR,
120+
args.verbose)
121+
output = append_text(
122+
data['metrics_logs_errors'],
123+
output,
124+
'errors in the metrics logs',
125+
REGEX_ERROR,
126+
args.verbose)
127+
output = append_text(
128+
data['metrics_errors'],
129+
output,
130+
'metrics failures',
131+
REGEX_ERROR,
132+
args.verbose)
133+
output = append_text(
134+
data['calibre_errors'],
135+
output,
136+
'calibre failures',
137+
REGEX_ERROR,
138+
args.verbose)
119139

120140
if args.verbose >= 2:
121-
output = append_text(data['log_warnings'], output, 'warnings in the logs', REGEX_WARNING, args.verbose-2)
122-
output = append_text(data['metrics_logs_warnings'], output, 'warnings in the metrics logs', REGEX_WARNING, args.verbose-2)
123-
output = append_text(data['metrics_warnings'], output, 'metrics warnings', REGEX_WARNING, args.verbose-2)
124-
output = append_text(data['calibre_warnings'], output, 'calibre warnings', REGEX_WARNING, args.verbose-2)
141+
output = append_text(
142+
data['log_warnings'],
143+
output,
144+
'warnings in the logs',
145+
REGEX_WARNING,
146+
args.verbose - 2)
147+
output = append_text(
148+
data['metrics_logs_warnings'],
149+
output,
150+
'warnings in the metrics logs',
151+
REGEX_WARNING,
152+
args.verbose - 2)
153+
output = append_text(
154+
data['metrics_warnings'],
155+
output,
156+
'metrics warnings',
157+
REGEX_WARNING,
158+
args.verbose - 2)
159+
output = append_text(
160+
data['calibre_warnings'],
161+
output,
162+
'calibre warnings',
163+
REGEX_WARNING,
164+
args.verbose - 2)
125165

126166
if d['drcs']:
127167
if data['status'] == STATUS_GREEN:
@@ -214,7 +254,7 @@ def write_summary():
214254
d['log_warnings'] += temp_w
215255
if name_.endswith('.log'):
216256
d['last_log'] = name_
217-
d['finished'] = (d['last_log'] == LAST_EXPECTED_LOG)
257+
d['finished'] = (d['last_log'] in LAST_EXPECTED_LOG)
218258

219259
# check if metrics generation had issues
220260
d['metrics_logs_errors'], d['metrics_logs_warnings'] = parse_messages(
@@ -250,7 +290,17 @@ def write_summary():
250290
if d['log_errors'] or d['metrics_errors'] or d['calibre_errors']:
251291
d['status'] = STATUS_RED
252292
else:
253-
d['status'] = STATUS_GREEN
293+
if not d['finished']:
294+
d['status'] = STATUS_RED
295+
last_lines = 'Could not find last lines of the log file.'
296+
with open(os.path.join(log_dir, d['last_log']), 'r') as last_file:
297+
last_lines = last_file.readlines()[-10:]
298+
last_lines = ' '.join(last_lines)
299+
message = '[ERROR CI-0000] No error message found. '
300+
message += 'Here are the last 10 lines of the log.\n'
301+
d['log_errors'] = [message + last_lines]
302+
else:
303+
d['status'] = STATUS_GREEN
254304

255305
design_list[f"{platform} {design} ({variant})"] = d
256306

0 commit comments

Comments
 (0)