From dce7935887b3bbd6c3beaf0d1d139e1c1026adb5 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Mon, 31 Oct 2022 22:31:36 -0400 Subject: [PATCH] edk2_pr_eval.py: Build all packages on file change outside package Updates `get_packages_to_build()` to return all possible packages if a file is modified outside a package. Originally, this was implemented behind a new argument with the default behavior unchanged. However, feedback indicated it would be easier to adopt without an argument and this would be acceptable behavior. This does mean some files, such as documentation files, could trigger packages to build that would have not previously built. However, the impact and frequency of this is considered minimal enough to not justify additional complexity. The change mainly focuses on files such as dependency trackers (e.g. PIP requirements, submodules), Python scripts, and other files that can impact overall build results. Requires https://github.com/tianocore/edk2-pytool-library/pull/186. Signed-off-by: Michael Kubacki --- edk2toolext/invocables/edk2_pr_eval.py | 16 ++++++++++++++++ integration_test/edk2_stuart_pr_eval.robot | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/edk2toolext/invocables/edk2_pr_eval.py b/edk2toolext/invocables/edk2_pr_eval.py index e2673a615..2e55d3e99 100644 --- a/edk2toolext/invocables/edk2_pr_eval.py +++ b/edk2toolext/invocables/edk2_pr_eval.py @@ -120,6 +120,22 @@ def get_packages_to_build(self, possible_packages: list) -> dict: if rc != 0: return {} + # + # Policy 0 - A file outside a package was modified and force build + # all packages on a modified file outside a package setting + # is enabled. + # + # Note: GetContainingPackage() returns the top most directory from the + # workspace root for a given file path if the file is not in a + # package. + # + for f in files: + if not self.edk2_path_obj.GetContainingPackage(os.path.abspath(f)): + return dict.fromkeys(possible_packages, + "Policy 0 - Build all packages if " + "a file is modified outside a " + "package.") + remaining_packages = possible_packages.copy() # start with all possible packages and remove each # package once it is determined to be build. This optimization # avoids checking packages that already will be built. diff --git a/integration_test/edk2_stuart_pr_eval.robot b/integration_test/edk2_stuart_pr_eval.robot index a41c0e558..06644fa98 100644 --- a/integration_test/edk2_stuart_pr_eval.robot +++ b/integration_test/edk2_stuart_pr_eval.robot @@ -314,6 +314,6 @@ Test Stuart PR for changing a file at the root of repo # Platform CI test DSC dependnency on implementation file # Policy 4 ${pkgs}= Stuart pr evaluation ${platform_ci_file} OvmfPkg ${default_branch} ${EMPTY} ${ws_root} - Should Be Empty ${pkgs} + Confirm same contents ${pkgs} OvmfPkg [Teardown] Delete branch ${branch_name} ${default_branch} ${ws_root}