balrog_submit.py (6256B)
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 per-locale balrog task into an actual task description. 6 """ 7 8 from taskgraph.transforms.base import TransformSequence 9 from taskgraph.util.dependencies import get_primary_dependency 10 from taskgraph.util.schema import Schema, optionally_keyed_by, resolve_keyed_by 11 from taskgraph.util.treeherder import replace_group 12 from voluptuous import Optional, Required 13 14 from gecko_taskgraph.transforms.task import task_description_schema 15 from gecko_taskgraph.util.attributes import copy_attributes_from_dependent_job 16 17 balrog_description_schema = Schema({ 18 # unique label to describe this balrog task, defaults to balrog-{dep.label} 19 Required("label"): str, 20 Optional( 21 "update-no-wnp", 22 description="Whether the parallel `-No-WNP` blob should be updated as well.", 23 ): optionally_keyed_by("release-type", bool), 24 # treeherder is allowed here to override any defaults we use for beetmover. See 25 # taskcluster/gecko_taskgraph/transforms/task.py for the schema details, and the 26 # below transforms for defaults of various values. 27 Optional("treeherder"): task_description_schema["treeherder"], 28 Optional("attributes"): task_description_schema["attributes"], 29 Optional("dependencies"): task_description_schema["dependencies"], 30 Optional("task-from"): task_description_schema["task-from"], 31 # Shipping product / phase 32 Optional("shipping-product"): task_description_schema["shipping-product"], 33 Optional("shipping-phase"): task_description_schema["shipping-phase"], 34 Optional("run-on-repo-type"): task_description_schema["run-on-repo-type"], 35 }) 36 37 38 transforms = TransformSequence() 39 40 41 @transforms.add 42 def remove_name(config, jobs): 43 for job in jobs: 44 if "name" in job: 45 del job["name"] 46 yield job 47 48 49 transforms.add_validate(balrog_description_schema) 50 51 52 @transforms.add 53 def handle_keyed_by(config, jobs): 54 """Resolve fields that can be keyed by platform, etc.""" 55 fields = [ 56 "update-no-wnp", 57 ] 58 for job in jobs: 59 for field in fields: 60 resolve_keyed_by( 61 item=job, 62 field=field, 63 item_name=job["label"], 64 **{ 65 "project": config.params["project"], 66 "release-type": config.params["release_type"], 67 }, 68 ) 69 yield job 70 71 72 @transforms.add 73 def make_task_description(config, jobs): 74 for job in jobs: 75 dep_job = get_primary_dependency(config, job) 76 assert dep_job 77 78 job["shipping-product"] = dep_job.attributes.get("shipping_product") 79 80 treeherder = job.get("treeherder", {}) 81 treeherder.setdefault("symbol", "c-Up(N)") 82 dep_th_platform = ( 83 dep_job.task.get("extra", {}) 84 .get("treeherder", {}) 85 .get("machine", {}) 86 .get("platform", "") 87 ) 88 treeherder.setdefault("platform", f"{dep_th_platform}/opt") 89 treeherder.setdefault( 90 "tier", dep_job.task.get("extra", {}).get("treeherder", {}).get("tier", 1) 91 ) 92 treeherder.setdefault("kind", "build") 93 94 attributes = copy_attributes_from_dependent_job(dep_job) 95 96 treeherder_job_symbol = dep_job.task["extra"]["treeherder"]["symbol"] 97 treeherder["symbol"] = replace_group(treeherder_job_symbol, "c-Up") 98 99 if dep_job.attributes.get("locale"): 100 attributes["locale"] = dep_job.attributes.get("locale") 101 102 label = job["label"] 103 104 description = ( 105 "Balrog submission for locale '{locale}' for build '" 106 "{build_platform}/{build_type}'".format( 107 locale=attributes.get("locale", "en-US"), 108 build_platform=attributes.get("build_platform"), 109 build_type=attributes.get("build_type"), 110 ) 111 ) 112 113 upstream_artifacts = [ 114 { 115 "taskId": {"task-reference": "<beetmover>"}, 116 "taskType": "beetmover", 117 "paths": ["public/manifest.json"], 118 } 119 ] 120 121 dependencies = {"beetmover": dep_job.label} 122 # don't block on startup-test for release/esr, they block on manual testing anyway 123 if config.params["release_type"] in ("nightly", "beta", "release-rc"): 124 for kind_dep in config.kind_dependencies_tasks.values(): 125 if ( 126 kind_dep.kind == "startup-test" 127 and kind_dep.attributes["build_platform"] 128 == attributes.get("build_platform") 129 and kind_dep.attributes["build_type"] 130 == attributes.get("build_type") 131 and kind_dep.attributes.get("shipping_product") 132 == job.get("shipping-product") 133 ): 134 dependencies["startup-test"] = kind_dep.label 135 # We need the release created in balrog first 136 soft_dependencies = [ 137 dep.label 138 for dep in config.kind_dependencies_tasks.values() 139 if dep.kind == "release-balrog-submit-toplevel" 140 and dep.attributes.get("shipping_product") == job.get("shipping-product") 141 ] 142 143 task = { 144 "label": label, 145 "description": description, 146 "worker-type": "balrog", 147 "worker": { 148 "implementation": "balrog", 149 "upstream-artifacts": upstream_artifacts, 150 "balrog-action": "v2-submit-locale", 151 "suffixes": ["", "-No-WNP"] if job.get("update-no-wnp") else [""], 152 }, 153 "dependencies": dependencies, 154 "soft-dependencies": soft_dependencies, 155 "attributes": attributes, 156 "run-on-projects": dep_job.attributes.get("run_on_projects"), 157 "run-on-repo-type": job.get("run-on-repo-type", ["git", "hg"]), 158 "treeherder": treeherder, 159 "shipping-phase": job.get("shipping-phase", "promote"), 160 "shipping-product": job.get("shipping-product"), 161 } 162 163 yield task