From 7cf6db9c60743603b9d295da1bb8cff8ebb54d72 Mon Sep 17 00:00:00 2001 From: Jared Sanson Date: Thu, 4 Aug 2022 15:33:28 +1200 Subject: [PATCH 1/4] Improve log messages for DependencyCheck & UncrustifyCheck --- .../Plugin/DependencyCheck/DependencyCheck.py | 5 +++-- .../Plugin/UncrustifyCheck/UncrustifyCheck.py | 22 +++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.pytool/Plugin/DependencyCheck/DependencyCheck.py b/.pytool/Plugin/DependencyCheck/DependencyCheck.py index fa4ffe148f..0c88ffe519 100644 --- a/.pytool/Plugin/DependencyCheck/DependencyCheck.py +++ b/.pytool/Plugin/DependencyCheck/DependencyCheck.py @@ -108,8 +108,9 @@ def RunBuildPlugin(self, packagename, Edk2pathObj, pkgconfig, environment, PLM, if mod_specific_key in pkgconfig and p in pkgconfig[mod_specific_key]: continue - logging.error("Dependency Check: Invalid Dependency INF: {0} depends on pkg {1}".format(file, p)) - tc.LogStdError("Dependency Check: Invalid Dependency INF: {0} depends on pkg {1}".format(file, p)) + msg = "Dependency Check: {0} depends on pkg {1} but pkg is not listed in AcceptableDependencies".format(file, p) + logging.error(msg) + tc.LogStdError(msg) overall_status += 1 # If XML object exists, add results diff --git a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py index c01e11308b..dc66bc8c77 100644 --- a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py +++ b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py @@ -385,7 +385,7 @@ def _get_template_file_contents(self) -> None: file_template_path = pathlib.Path(os.path.join(self._plugin_path, file_template_name)) self._file_template_contents = file_template_path.read_text() except KeyError: - logging.warn("A file header template is not specified in the config file.") + logging.info("A file header template is not specified in the config file.") except FileNotFoundError: logging.warn("The specified file header template file was not found.") try: @@ -397,7 +397,7 @@ def _get_template_file_contents(self) -> None: func_template_path = pathlib.Path(os.path.join(self._plugin_path, func_template_name)) self._func_template_contents = func_template_path.read_text() except KeyError: - logging.warn("A function header template is not specified in the config file.") + logging.info("A function header template is not specified in the config file.") except FileNotFoundError: logging.warn("The specified function header template file was not found.") @@ -575,26 +575,28 @@ def _process_uncrustify_results(self) -> None: self._formatted_file_error_count = len(formatted_files) if self._formatted_file_error_count > 0: - logging.error( + logging.warning('Uncrustify found {0} files with formatting errors'.format(self._formatted_file_error_count)) + self._tc.LogStdError("Uncrustify found {0} files with formatting errors:\n".format(self._formatted_file_error_count)) + logging.info( "Visit the following instructions to learn " "how to find the detailed formatting errors in Azure " "DevOps CI: " "https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Code-Formatting#how-to-find-uncrustify-formatting-errors-in-continuous-integration-ci") - self._tc.LogStdError("Files with formatting errors:\n") + if self._output_file_diffs: logging.info("Calculating file diffs. This might take a while...") for formatted_file in formatted_files: - pre_formatted_file = formatted_file[:- - len(UncrustifyCheck.FORMATTED_FILE_EXTENSION)] - logging.error(pre_formatted_file) + pre_formatted_file = formatted_file[:-len(UncrustifyCheck.FORMATTED_FILE_EXTENSION)] + + msg = f"Formatting errors in {os.path.relpath(pre_formatted_file, self._abs_package_path)}" + self._tc.LogStdError(msg + '\n') + logging.info(msg) if (self._output_file_diffs or self._file_template_contents is not None or self._func_template_contents is not None): - self._tc.LogStdError( - f"Formatting errors in {os.path.relpath(pre_formatted_file, self._abs_package_path)}\n") with open(formatted_file) as ff: formatted_file_text = ff.read() @@ -615,8 +617,6 @@ def _process_uncrustify_results(self) -> None: self._tc.LogStdError(line) self._tc.LogStdError('\n') - else: - self._tc.LogStdError(pre_formatted_file) def _remove_tree(self, dir_path: str, ignore_errors: bool = False) -> None: """ From a188cfe2a9630a19c4b47f8e51c59409115489d9 Mon Sep 17 00:00:00 2001 From: Jared Sanson Date: Fri, 5 Aug 2022 09:55:24 +1200 Subject: [PATCH 2/4] Modify debug levels per PR feedback --- .pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py index dc66bc8c77..ef125109d9 100644 --- a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py +++ b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py @@ -385,7 +385,7 @@ def _get_template_file_contents(self) -> None: file_template_path = pathlib.Path(os.path.join(self._plugin_path, file_template_name)) self._file_template_contents = file_template_path.read_text() except KeyError: - logging.info("A file header template is not specified in the config file.") + logging.warn("A file header template is not specified in the config file.") except FileNotFoundError: logging.warn("The specified file header template file was not found.") try: @@ -397,7 +397,7 @@ def _get_template_file_contents(self) -> None: func_template_path = pathlib.Path(os.path.join(self._plugin_path, func_template_name)) self._func_template_contents = func_template_path.read_text() except KeyError: - logging.info("A function header template is not specified in the config file.") + logging.warn("A function header template is not specified in the config file.") except FileNotFoundError: logging.warn("The specified function header template file was not found.") @@ -577,7 +577,7 @@ def _process_uncrustify_results(self) -> None: if self._formatted_file_error_count > 0: logging.warning('Uncrustify found {0} files with formatting errors'.format(self._formatted_file_error_count)) self._tc.LogStdError("Uncrustify found {0} files with formatting errors:\n".format(self._formatted_file_error_count)) - logging.info( + logging.critical( "Visit the following instructions to learn " "how to find the detailed formatting errors in Azure " "DevOps CI: " From 9dda7dbec06d7053ce1907c5bc74f5c1d265c273 Mon Sep 17 00:00:00 2001 From: Jared Sanson Date: Fri, 5 Aug 2022 09:58:25 +1200 Subject: [PATCH 3/4] Use f-strings --- .pytool/Plugin/DependencyCheck/DependencyCheck.py | 5 ++--- .pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.pytool/Plugin/DependencyCheck/DependencyCheck.py b/.pytool/Plugin/DependencyCheck/DependencyCheck.py index 0c88ffe519..d97e5465c5 100644 --- a/.pytool/Plugin/DependencyCheck/DependencyCheck.py +++ b/.pytool/Plugin/DependencyCheck/DependencyCheck.py @@ -108,9 +108,8 @@ def RunBuildPlugin(self, packagename, Edk2pathObj, pkgconfig, environment, PLM, if mod_specific_key in pkgconfig and p in pkgconfig[mod_specific_key]: continue - msg = "Dependency Check: {0} depends on pkg {1} but pkg is not listed in AcceptableDependencies".format(file, p) - logging.error(msg) - tc.LogStdError(msg) + logging.error(f"Dependency Check: {file} depends on pkg {p} but pkg is not listed in AcceptableDependencies") + tc.LogStdError(f"Dependency Check: {file} depends on pkg {p} but pkg is not listed in AcceptableDependencies") overall_status += 1 # If XML object exists, add results diff --git a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py index ef125109d9..4b1219fd5c 100644 --- a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py +++ b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py @@ -575,8 +575,8 @@ def _process_uncrustify_results(self) -> None: self._formatted_file_error_count = len(formatted_files) if self._formatted_file_error_count > 0: - logging.warning('Uncrustify found {0} files with formatting errors'.format(self._formatted_file_error_count)) - self._tc.LogStdError("Uncrustify found {0} files with formatting errors:\n".format(self._formatted_file_error_count)) + logging.warning(f'Uncrustify found {self._formatted_file_error_count} files with formatting errors') + self._tc.LogStdError(f"Uncrustify found {self._formatted_file_error_count} files with formatting errors:\n") logging.critical( "Visit the following instructions to learn " "how to find the detailed formatting errors in Azure " @@ -590,9 +590,8 @@ def _process_uncrustify_results(self) -> None: for formatted_file in formatted_files: pre_formatted_file = formatted_file[:-len(UncrustifyCheck.FORMATTED_FILE_EXTENSION)] - msg = f"Formatting errors in {os.path.relpath(pre_formatted_file, self._abs_package_path)}" - self._tc.LogStdError(msg + '\n') - logging.info(msg) + self._tc.LogStdError(f"Formatting errors in {os.path.relpath(pre_formatted_file, self._abs_package_path)}\n") + logging.info(f"Formatting errors in {os.path.relpath(pre_formatted_file, self._abs_package_path)}") if (self._output_file_diffs or self._file_template_contents is not None or From 6730a70f35447c0ab6428dab1e99812f47557b0e Mon Sep 17 00:00:00 2001 From: Jared Sanson Date: Fri, 5 Aug 2022 10:30:48 +1200 Subject: [PATCH 4/4] Promote spell-checker warnings --- .pytool/Plugin/SpellCheck/SpellCheck.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pytool/Plugin/SpellCheck/SpellCheck.py b/.pytool/Plugin/SpellCheck/SpellCheck.py index 616216296a..c12ce6d4f5 100644 --- a/.pytool/Plugin/SpellCheck/SpellCheck.py +++ b/.pytool/Plugin/SpellCheck/SpellCheck.py @@ -186,13 +186,14 @@ def RunBuildPlugin(self, packagename, Edk2pathObj, pkgconfig, environment, PLM, # Helper - Log the syntax needed to add these words to dictionary if len(EasyFix) > 0: EasyFix = sorted(set(a.lower() for a in EasyFix)) + logging.error(f'SpellCheck found {len(EasyFix)} failing words. See CI log for details.') tc.LogStdOut("\n Easy fix:") OneString = "If these are not errors add this to your ci.yaml file.\n" OneString += '"SpellCheck": {\n "ExtendWords": [' for a in EasyFix: tc.LogStdOut(f'\n"{a}",') OneString += f'\n "{a}",' - logging.info(OneString.rstrip(",") + '\n ]\n}') + logging.critical(OneString.rstrip(",") + '\n ]\n}') # add result to test case overall_status = len(Errors)