diff --git a/python/mozbuild/mozbuild/artifacts.py b/python/mozbuild/mozbuild/artifacts.py index ba390d03a9ea..6cb0d1cf214c 100644 --- a/python/mozbuild/mozbuild/artifacts.py +++ b/python/mozbuild/mozbuild/artifacts.py @@ -1210,27 +1210,39 @@ class TaskCache(CacheManager): # 'autoland' tree = tree.split("/")[1] if "/" in tree else tree + # Optimized builds are normally only published to the `.shippable` + # index. Some consumers (e.g. the Android Gradle python tests) run on + # autoland, where shippable Android builds aren't scheduled by default; + # with MOZ_ARTIFACT_ALLOW_NON_SHIPPABLE they fall back to the regular + # per-push opt builds. The shippable index is still tried first, so + # branches that only publish shippable builds (central, beta, release, + # esr) are unaffected. See bug 1768186 for lifting this more generally. if job.endswith("-opt"): - tree += ".shippable" - - namespace = f"{job_configuration.trust_domain}.v2.{tree}.revision.{rev}.{job_configuration.product}.{job}" - self.log( - logging.DEBUG, - "artifact", - {"namespace": namespace}, - "Searching Taskcluster index with namespace: {namespace}", - ) + if os.environ.get("MOZ_ARTIFACT_ALLOW_NON_SHIPPABLE"): + trees = [f"{tree}.shippable", tree] + else: + trees = [f"{tree}.shippable"] + else: + trees = [tree] from taskcluster.exceptions import TaskclusterRestFailure - try: - index = get_taskcluster_client("index") - task = index.findTask(namespace) - taskId = task["taskId"] - except (KeyError, TaskclusterRestFailure) as e: - if isinstance(e, TaskclusterRestFailure) and e.status_code != 404: - raise - + index = get_taskcluster_client("index") + for candidate_tree in trees: + namespace = f"{job_configuration.trust_domain}.v2.{candidate_tree}.revision.{rev}.{job_configuration.product}.{job}" + self.log( + logging.DEBUG, + "artifact", + {"namespace": namespace}, + "Searching Taskcluster index with namespace: {namespace}", + ) + try: + taskId = index.findTask(namespace)["taskId"] + break + except (KeyError, TaskclusterRestFailure) as e: + if isinstance(e, TaskclusterRestFailure) and e.status_code != 404: + raise + else: # Not all revisions correspond to pushes that produce the job we # care about; and even those that do may not have completed yet. raise ValueError(f"Task for {namespace} does not exist (yet)!") diff --git a/taskcluster/kinds/source-test/python-android.yml b/taskcluster/kinds/source-test/python-android.yml index 4be29e8d1fcf..fa17121e7164 100644 --- a/taskcluster/kinds/source-test/python-android.yml +++ b/taskcluster/kinds/source-test/python-android.yml @@ -22,6 +22,13 @@ android-gradle-build: MOZ_OBJDIR: obj-firefox PERFHERDER_EXTRA_OPTIONS: android-gradle-build TINDERBOX_OUTPUT: '1' + # The tests run artifact builds. Let `mach artifact install` accept + # the regular (non-shippable) Android opt builds, which run on every + # integration push, instead of only the shippable index. Shippable + # Android builds are release-only, so on autoland the shippable + # index is almost always empty and the pushhead search fails with + # "no built artifacts found" (bug 2062847). + MOZ_ARTIFACT_ALLOW_NON_SHIPPABLE: '1' max-run-time: 7200 run-on-repo-type: [hg] run: