upload_symbols.py (3573B)
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 upload-symbols task description template, 6 taskcluster/kinds/upload-symbols/job-template.yml into an actual task description. 7 """ 8 9 import logging 10 11 from taskgraph.transforms.base import TransformSequence 12 from taskgraph.util.dependencies import get_primary_dependency 13 from taskgraph.util.treeherder import inherit_treeherder_from_dep, join_symbol 14 15 from gecko_taskgraph.util.attributes import ( 16 RELEASE_PROJECTS, 17 copy_attributes_from_dependent_job, 18 ) 19 20 logger = logging.getLogger(__name__) 21 22 transforms = TransformSequence() 23 24 25 @transforms.add 26 def check_nightlies(config, tasks): 27 """Ensure that we upload symbols for all shippable builds, so that crash-stats can 28 resolve any reports sent to it. Try may enable full symbols but not upload them. 29 30 Putting this check here (instead of the transforms for the build kind) lets us 31 leverage the any not-for-build-platforms set in the update-symbols kind.""" 32 for task in tasks: 33 dep = get_primary_dependency(config, task) 34 assert dep 35 36 if ( 37 config.params["project"] in RELEASE_PROJECTS 38 and dep.attributes.get("shippable") 39 and not dep.attributes.get("enable-full-crashsymbols") 40 and not dep.attributes.get("skip-upload-crashsymbols") 41 ): 42 raise Exception( 43 "Shippable job %s should have enable-full-crashsymbols attribute " 44 "set to true to enable symbol upload to crash-stats" % dep.label 45 ) 46 yield task 47 48 49 @transforms.add 50 def fill_template(config, tasks): 51 for task in tasks: 52 dep = get_primary_dependency(config, task) 53 assert dep 54 55 # Fill out the dynamic fields in the task description 56 task["label"] = dep.label + "-upload-symbols" 57 58 # Skip tasks where we don't have the full crashsymbols enabled 59 if not dep.attributes.get("enable-full-crashsymbols") or dep.attributes.get( 60 "skip-upload-crashsymbols" 61 ): 62 logger.debug("Skipping upload symbols task for %s", task["label"]) 63 continue 64 65 task["worker"]["env"]["GECKO_HEAD_REPOSITORY"] = config.params[ 66 "head_repository" 67 ] 68 task["worker"]["env"]["GECKO_HEAD_REV"] = config.params["head_rev"] 69 task["worker"]["env"]["SYMBOL_SECRET"] = task["worker"]["env"][ 70 "SYMBOL_SECRET" 71 ].format(level=config.params["level"]) 72 73 attributes = copy_attributes_from_dependent_job(dep) 74 attributes.update(task.get("attributes", {})) 75 task["attributes"] = attributes 76 77 treeherder = inherit_treeherder_from_dep(task, dep) 78 th = dep.task.get("extra")["treeherder"] 79 th_symbol = th.get("symbol") 80 th_groupsymbol = th.get("groupSymbol", "?") 81 82 # Disambiguate the treeherder symbol. 83 sym = "Sym" + (th_symbol[1:] if th_symbol.startswith("B") else th_symbol) 84 treeherder.setdefault("symbol", join_symbol(th_groupsymbol, sym)) 85 task["treeherder"] = treeherder 86 87 # We only want to run these tasks if the build is run. 88 # XXX Better to run this on promote phase instead? 89 task["run-on-projects"] = dep.attributes.get("run_on_projects") 90 task["optimization"] = {"upload-symbols": None} 91 task["if-dependencies"] = [task["attributes"]["primary-kind-dependency"]] 92 93 yield task