ci: Include context from failed build logs in the CI job log

This is faster to look up than browsing or downloading artifacts, and will often
contain the root cause.

Context includes the last 25 lines of the log, and any lines contaiing 'error:'
or 'warning:'
pull/6882/head
Angus Gratton 2021-02-18 10:06:36 +11:00 zatwierdzone przez bot
rodzic 936523b904
commit 2a33dbb5a7
2 zmienionych plików z 19 dodań i 1 usunięć

Wyświetl plik

@ -7,11 +7,19 @@
import argparse
import logging
import os.path
import re
import sys
from find_build_apps import BUILD_SYSTEMS, BuildError, BuildItem, setup_logging
from find_build_apps.common import SIZE_JSON_FN, rmdir
# This RE will match GCC errors and many other fatal build errors and warnings as well
LOG_ERROR_WARNING = re.compile(r'(error|warning):', re.IGNORECASE)
# Log this many trailing lines from a failed build log, also
LOG_DEBUG_LINES = 25
def main(): # type: () -> None
parser = argparse.ArgumentParser(description='ESP-IDF app builder')
@ -120,6 +128,17 @@ def main(): # type: () -> None
build_system_class.build(build_info)
except BuildError as e:
logging.error(str(e))
if build_info.build_log_path:
log_filename = os.path.basename(build_info.build_log_path)
with open(build_info.build_log_path, 'r') as f:
lines = [line.rstrip() for line in f.readlines() if line.rstrip()] # non-empty lines
logging.debug('Error and warning lines from {}:'.format(log_filename))
for line in lines:
if LOG_ERROR_WARNING.search(line):
logging.warning('>>> {}'.format(line))
logging.debug('Last {} lines of {}:'.format(LOG_DEBUG_LINES, log_filename))
for line in lines[-LOG_DEBUG_LINES:]:
logging.debug('>>> {}'.format(line))
if args.keep_going:
failed_builds.append(build_info)
else:

Wyświetl plik

@ -153,7 +153,6 @@ examples/wifi/iperf/iperf_test.py
tools/ble/lib_ble_client.py
tools/ble/lib_gap.py
tools/ble/lib_gatt.py
tools/build_apps.py
tools/check_python_dependencies.py
tools/check_term.py
tools/ci/check_artifacts_expire_time.py