From 3ac7693d7dae2d91e6fb03dbea9f5ad9070c4970 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 19 Mar 2024 02:16:13 +0000 Subject: [PATCH 1/2] add better error handling for patches that fail to apply Signed-off-by: Justin Stitt --- caching/update.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/caching/update.py b/caching/update.py index e296c8c8..c6ae67bb 100644 --- a/caching/update.py +++ b/caching/update.py @@ -18,6 +18,8 @@ import json import os import sys +import re +import urllib.request from pathlib import Path from utils import get_patches_hash, get_workflow_name_to_var_name, update_repository_variable @@ -79,6 +81,31 @@ def main(): except KeyError: builds_that_are_missing_metadata.append(entry) + # some builds may be missing metadata due to patches failing to apply + for build_id in builds_that_are_missing_metadata: + build = builds[build_id] + + if "Unable to apply kernel patch" not in build["status_message"]: + continue + req = urllib.request.Request(build["download_url"] + "build.log") + build_log_raw = "" + with urllib.request.urlopen(req) as response: + build_log_raw = response.read().decode() + + failed_pattern = ( + r"(?<=Apply patch set FAILED\s)[0-9A-Za-z._:/\-\s]*?(?=\serror: )" + ) + failed_matches = re.findall(failed_pattern, build_log_raw) + if len(failed_matches) == 0: + print( + f"No patches failed to apply yet the build status stated there were: {build['status_message']}" + ) + sys.exit(0) # Not sure how we got here but continue the action anyways + + patches_that_failed_to_apply = failed_matches[0].split('\n') + print(f"Error: Some patches failed to apply.\n{patches_that_failed_to_apply}\n") + sys.exit(1) + if len(builds_that_are_missing_metadata) == len(builds): raise RuntimeError( f"Could not find a suitable git sha or compiler version in any build\n" From 720a22fc60ab3510351647873a0c884bec5e379c Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 19 Mar 2024 02:31:02 +0000 Subject: [PATCH 2/2] yapf Signed-off-by: Justin Stitt --- caching/update.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/caching/update.py b/caching/update.py index c6ae67bb..37c8f36a 100644 --- a/caching/update.py +++ b/caching/update.py @@ -93,17 +93,19 @@ def main(): build_log_raw = response.read().decode() failed_pattern = ( - r"(?<=Apply patch set FAILED\s)[0-9A-Za-z._:/\-\s]*?(?=\serror: )" - ) + r"(?<=Apply patch set FAILED\s)[0-9A-Za-z._:/\-\s]*?(?=\serror: )") failed_matches = re.findall(failed_pattern, build_log_raw) if len(failed_matches) == 0: print( f"No patches failed to apply yet the build status stated there were: {build['status_message']}" ) - sys.exit(0) # Not sure how we got here but continue the action anyways + sys.exit( + 0) # Not sure how we got here but continue the action anyways patches_that_failed_to_apply = failed_matches[0].split('\n') - print(f"Error: Some patches failed to apply.\n{patches_that_failed_to_apply}\n") + print( + f"Error: Some patches failed to apply.\n{patches_that_failed_to_apply}\n" + ) sys.exit(1) if len(builds_that_are_missing_metadata) == len(builds):