scriptworker_canary.py (1700B)
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 Build a command to run `mach release push-scriptworker-canaries`. 6 """ 7 8 from shlex import quote as shell_quote 9 10 from mozrelease.scriptworker_canary import TASK_TYPES 11 from taskgraph.transforms.base import TransformSequence 12 13 transforms = TransformSequence() 14 15 16 @transforms.add 17 def build_command(config, jobs): 18 scriptworkers = config.params["try_task_config"].get( 19 "scriptworker-canary-workers", [] 20 ) 21 # Filter the list of workers to those we have configured a set of canary 22 # tasks for. 23 scriptworkers = [ 24 scriptworker for scriptworker in scriptworkers if scriptworker in TASK_TYPES 25 ] 26 27 if not scriptworkers: 28 return 29 30 for job in jobs: 31 command = ["release", "push-scriptworker-canary"] 32 for scriptworker in scriptworkers: 33 command.extend(["--scriptworker", scriptworker]) 34 addresses = job.pop("addresses") 35 for address in addresses: 36 command.extend(["--address", address]) 37 if "ssh-key-secret" in job: 38 ssh_key_secret = job.pop("ssh-key-secret") 39 command.extend(["--ssh-key-secret", ssh_key_secret]) 40 job.setdefault("scopes", []).append(f"secrets:get:{ssh_key_secret}") 41 42 job.setdefault("run", {}).update({ 43 "using": "mach", 44 "mach": " ".join(map(shell_quote, command)), 45 }) 46 job.setdefault("routes", []).extend([ 47 f"notify.email.{address}.on-failed" for address in addresses 48 ]) 49 yield job