Fix DetermineAndroidBranch in various places
Generate the list from ground truth instead of hardcoding.
BUG=b:158811826
TEST=./run_tests
Change-Id: I9bedfa422762f95a6deeb4f705d9b013ae3a1847
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2247966
Tested-by: Shao-Chuan Lee <shaochuan@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Shao-Chuan Lee <shaochuan@chromium.org>
diff --git a/cbuildbot/cbuildbot_run.py b/cbuildbot/cbuildbot_run.py
index d9b3089..0c0196d 100644
--- a/cbuildbot/cbuildbot_run.py
+++ b/cbuildbot/cbuildbot_run.py
@@ -799,8 +799,8 @@
ebuild_path = portage_util.FindEbuildForBoardPackage(android_package, board)
host_ebuild_path = path_util.FromChrootPath(ebuild_path)
# We assume all targets pull from the same branch and that we always
- # have an ARM_TARGET, ARM_USERDEBUG_TARGET, or an X86_USERDEBUG_TARGET.
- targets = ['ARM_TARGET', 'ARM_USERDEBUG_TARGET', 'X86_USERDEBUG_TARGET']
+ # have at least one of the following targets.
+ targets = constants.ANDROID_ALL_BUILD_TARGETS
ebuild_content = osutils.SourceEnvironment(host_ebuild_path, targets)
for target in targets:
if target in ebuild_content:
diff --git a/cbuildbot/stages/workspace_stages.py b/cbuildbot/stages/workspace_stages.py
index 9b8dcb3..bf27d98 100644
--- a/cbuildbot/stages/workspace_stages.py
+++ b/cbuildbot/stages/workspace_stages.py
@@ -745,8 +745,8 @@
host_ebuild_path = path_util.FromChrootPath(ebuild_path,
source_path=self._build_root)
# We assume all targets pull from the same branch and that we always
- # have an ARM_TARGET or an X86_USERDEBUG_TARGET.
- targets = ['ARM_TARGET', 'X86_USERDEBUG_TARGET']
+ # have at least one of the following targets.
+ targets = constants.ANDROID_ALL_BUILD_TARGETS
ebuild_content = osutils.SourceEnvironment(host_ebuild_path, targets)
logging.info('Got ebuild env: %s', ebuild_content)
for target in targets:
diff --git a/lib/constants.py b/lib/constants.py
index 04d282d..8e4a0f3 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -7,6 +7,7 @@
from __future__ import print_function
+import itertools
import os
def _FindSourceRoot():
@@ -326,6 +327,19 @@
r'(\.zip|/XkbToKcmConverter)$'),
}
+# These refer to *_TARGET variables in Android ebuild files, used when
+# parsing ebuilds to determine the corresponding Android branch.
+# NOTE: We may use `|` operator to union dict keys after we completely go
+# Python 3.
+ANDROID_ALL_BUILD_TARGETS = frozenset(
+ x + '_TARGET' for x in itertools.chain(
+ ANDROID_PI_BUILD_TARGETS,
+ ANDROID_VMPI_BUILD_TARGETS,
+ ANDROID_VMMST_BUILD_TARGETS,
+ ANDROID_VMRVC_BUILD_TARGETS,
+ )
+)
+
ARC_BUCKET_URL = 'gs://chromeos-arc-images/builds'
ARC_BUCKET_ACLS = {
'APPS': 'googlestorage_acl_public.txt',
diff --git a/service/packages.py b/service/packages.py
index 393d224..f95f28e 100644
--- a/service/packages.py
+++ b/service/packages.py
@@ -781,10 +781,7 @@
ebuild_path = portage_util.FindEbuildForBoardPackage(android_package, board)
# We assume all targets pull from the same branch and that we always
# have at least one of the following targets.
- # TODO(crbug.com/1087167): Ensure this condition in PFQ to avoid CQ breakage.
- targets = ['ARM_TARGET', 'ARM_USERDEBUG_TARGET', 'X86_USERDEBUG_TARGET',
- 'ARM64_TARGET', 'ARM64_USERDEBUG_TARGET', 'X86_64_TARGET',
- 'X86_64_USERDEBUG_TARGET']
+ targets = constants.ANDROID_ALL_BUILD_TARGETS
ebuild_content = osutils.SourceEnvironment(ebuild_path, targets)
for target in targets:
if target in ebuild_content: