beetmover_android_app.py (3808B)
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 Transform the beetmover task into an actual task description. 6 """ 7 8 import logging 9 10 from gecko_taskgraph.transforms.task import ( 11 task_description_schema as gecko_task_description_schema, 12 ) 13 from taskgraph.transforms.base import TransformSequence 14 from taskgraph.transforms.task import task_description_schema 15 from taskgraph.util.schema import optionally_keyed_by, resolve_keyed_by 16 from voluptuous import ALLOW_EXTRA, Optional, Required, Schema 17 18 from android_taskgraph.util.scriptworker import generate_beetmover_artifact_map 19 20 logger = logging.getLogger(__name__) 21 22 beetmover_description_schema = Schema( 23 { 24 # unique name to describe this beetmover task, defaults to {dep.label}-beetmover 25 Required("name"): str, 26 Required("worker"): {"upstream-artifacts": [dict]}, 27 # treeherder is allowed here to override any defaults we use for beetmover. 28 Optional("treeherder"): task_description_schema["treeherder"], 29 Optional("attributes"): task_description_schema["attributes"], 30 Optional("dependencies"): task_description_schema["dependencies"], 31 Optional("bucket-scope"): optionally_keyed_by("level", "build-type", str), 32 Optional("run-on-repo-type"): gecko_task_description_schema["run-on-repo-type"], 33 }, 34 extra=ALLOW_EXTRA, 35 ) 36 37 transforms = TransformSequence() 38 transforms.add_validate(beetmover_description_schema) 39 40 41 @transforms.add 42 def make_task_description(config, tasks): 43 for task in tasks: 44 attributes = task["attributes"] 45 46 label = "beetmover-{}".format(task["name"]) 47 description = "Beetmover submission for build type '{build_type}'".format( 48 build_type=attributes.get("build-type"), 49 ) 50 51 if task.get("locale"): 52 attributes["locale"] = task["locale"] 53 54 resolve_keyed_by( 55 task, 56 "bucket-scope", 57 item_name=task["name"], 58 **{ 59 "build-type": task["attributes"]["build-type"], 60 "level": config.params["level"], 61 }, 62 ) 63 bucket_scope = task.pop("bucket-scope") 64 65 taskdesc = { 66 "label": label, 67 "description": description, 68 "worker-type": "beetmover-android", 69 "worker": task["worker"], 70 "scopes": [ 71 bucket_scope, 72 "project:releng:beetmover:action:direct-push-to-bucket", 73 ], 74 "dependencies": task["dependencies"], 75 "attributes": attributes, 76 "treeherder": task["treeherder"], 77 "run-on-repo-type": task.get("run-on-repo-type", ["git", "hg"]), 78 } 79 80 yield taskdesc 81 82 83 _STAGING_PREFIX = "staging-" 84 85 86 def craft_release_properties(config, task): 87 params = config.params 88 89 return { 90 "app-name": "fenix", # TODO: Support focus 91 "app-version": str(params["version"]), 92 "branch": params["project"], 93 "build-id": str(params["moz_build_date"]), 94 "hash-type": "sha512", 95 "platform": "android", 96 } 97 98 99 @transforms.add 100 def make_task_worker(config, tasks): 101 for task in tasks: 102 locale = task["attributes"].get("locale") 103 build_type = task["attributes"]["build-type"] 104 105 task["worker"].update({ 106 "implementation": "beetmover", 107 "release-properties": craft_release_properties(config, task), 108 "artifact-map": generate_beetmover_artifact_map( 109 config, task, platform=build_type, locale=locale 110 ), 111 }) 112 113 if locale: 114 task["worker"]["locale"] = locale 115 116 yield task