beetmover_push_to_release.py (3238B)
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-push-to-release task into a task description. 6 """ 7 8 from taskgraph.transforms.base import TransformSequence 9 from taskgraph.util.schema import Schema, taskref_or_string 10 from voluptuous import Optional, Required 11 12 from gecko_taskgraph.transforms.task import task_description_schema 13 from gecko_taskgraph.util.scriptworker import ( 14 add_scope_prefix, 15 get_beetmover_bucket_scope, 16 ) 17 18 beetmover_push_to_release_description_schema = Schema({ 19 Required("name"): str, 20 Required("product"): str, 21 Required("treeherder-platform"): str, 22 Optional("attributes"): {str: object}, 23 Optional("task-from"): task_description_schema["task-from"], 24 Optional("run"): {str: object}, 25 Optional("run-on-projects"): task_description_schema["run-on-projects"], 26 Optional("run-on-repo-type"): task_description_schema["run-on-repo-type"], 27 Optional("dependencies"): {str: taskref_or_string}, 28 Optional("index"): {str: str}, 29 Optional("routes"): [str], 30 Required("shipping-phase"): task_description_schema["shipping-phase"], 31 Required("shipping-product"): task_description_schema["shipping-product"], 32 Optional("extra"): task_description_schema["extra"], 33 }) 34 35 36 transforms = TransformSequence() 37 transforms.add_validate(beetmover_push_to_release_description_schema) 38 39 40 @transforms.add 41 def make_beetmover_push_to_release_description(config, jobs): 42 for job in jobs: 43 treeherder = job.get("treeherder", {}) 44 treeherder.setdefault("symbol", "Rel(BM-C)") 45 treeherder.setdefault("tier", 1) 46 treeherder.setdefault("kind", "build") 47 treeherder.setdefault("platform", job["treeherder-platform"]) 48 49 label = job["name"] 50 description = "Beetmover push to release for '{product}'".format( 51 product=job["product"] 52 ) 53 54 bucket_scope = get_beetmover_bucket_scope(config) 55 action_scope = add_scope_prefix(config, "beetmover:action:push-to-releases") 56 57 task = { 58 "label": label, 59 "description": description, 60 "worker-type": "beetmover", 61 "scopes": [bucket_scope, action_scope], 62 "product": job["product"], 63 "dependencies": job["dependencies"], 64 "attributes": job.get("attributes", {}), 65 "run-on-projects": job.get("run-on-projects"), 66 "run-on-repo-type": job.get("run-on-repo-type", ["git", "hg"]), 67 "treeherder": treeherder, 68 "shipping-phase": job.get("shipping-phase", "push"), 69 "shipping-product": job.get("shipping-product"), 70 "routes": job.get("routes", []), 71 "extra": job.get("extra", {}), 72 "worker": job.get("worker", {}), 73 } 74 75 yield task 76 77 78 @transforms.add 79 def make_beetmover_push_to_release_worker(config, jobs): 80 for job in jobs: 81 worker = { 82 "implementation": "beetmover-push-to-release", 83 "product": job["product"], 84 } 85 job["worker"] = worker 86 del job["product"] 87 88 yield job