upstream_artifacts.py (2081B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 from taskgraph.transforms.base import TransformSequence 6 from taskgraph.util.dependencies import get_dependencies 7 8 from android_taskgraph.util.scriptworker import generate_beetmover_upstream_artifacts 9 10 transforms = TransformSequence() 11 12 13 def _get_task_type(dep_kind): 14 if dep_kind.startswith("build-"): 15 return "build" 16 elif dep_kind.startswith("signing-"): 17 return "signing" 18 return dep_kind 19 20 21 @transforms.add 22 def build_upstream_artifacts(config, tasks): 23 for task in tasks: 24 worker_definition = { 25 "upstream-artifacts": [], 26 } 27 if "artifact_map" in task["attributes"]: 28 # Beetmover-apk tasks use declarative artifacts. 29 locale = task["attributes"].get("locale") 30 build_type = task["attributes"]["build-type"] 31 worker_definition["upstream-artifacts"] = ( 32 generate_beetmover_upstream_artifacts(config, task, build_type, locale) 33 ) 34 else: 35 only_archs = task.pop("only-archs", []) 36 for dep in get_dependencies(config, task): 37 paths = list(dep.attributes.get("artifacts", {}).values()) 38 paths.extend([ 39 apk_metadata["name"] 40 for arch, apk_metadata in dep.attributes.get("apks", {}).items() 41 if not only_archs or arch in only_archs 42 ]) 43 if dep.attributes.get("aab"): 44 paths.extend([dep.attributes.get("aab")]) 45 if paths: 46 worker_definition["upstream-artifacts"].append({ 47 "taskId": {"task-reference": f"<{dep.kind}>"}, 48 "taskType": _get_task_type(dep.kind), 49 "paths": sorted(paths), 50 }) 51 52 task.setdefault("worker", {}).update(worker_definition) 53 yield task