Bug 1594330 - Fix GeckoProfile callback action r=jmaher
authorIonut Goldan <igoldan@mozilla.com>
Wed, 13 Nov 2019 15:57:27 +0000
changeset 501761 1936d7a01173063eeeb672a29e519be5249b9a5f
parent 501760 a64b015e2fb96ffa9f5a4b2bde94752f7ed2fe2b
child 501762 27f06b7cc987734c9f55742f18351b5e40ea3aed
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs1594330
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1594330 - Fix GeckoProfile callback action r=jmaher Differential Revision: https://phabricator.services.mozilla.com/D52826
taskcluster/taskgraph/actions/gecko_profile.py
--- a/taskcluster/taskgraph/actions/gecko_profile.py
+++ b/taskcluster/taskgraph/actions/gecko_profile.py
@@ -5,16 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import logging
 
 import requests
 from requests.exceptions import HTTPError
+from six import string_types
 
 from .registry import register_callback_action
 from .util import create_tasks, combine_task_graph_files
 from taskgraph.util.taskcluster import get_artifact_from_index
 from taskgraph.util.taskgraph import find_decision_task
 from taskgraph.taskgraph import TaskGraph
 from taskgraph.util import taskcluster
 
@@ -80,44 +81,45 @@ def geckoprofile_action(parameters, grap
             continue
 
         if label in full_task_graph.tasks.keys():
             def modifier(task):
                 if task.label != label:
                     return task
 
                 cmd = task.task['payload']['command']
-                task.task['payload']['command'] = add_args_to_command(cmd, ['--geckoProfile'])
+                task.task['payload']['command'] = add_args_to_perf_command(cmd, ['--geckoProfile'])
                 task.task['extra']['treeherder']['symbol'] += '-p'
                 return task
 
             create_tasks(graph_config, [label], full_task_graph, label_to_taskid,
                          push_params, push_decision_task_id, push, modifier=modifier)
             backfill_pushes.append(push)
         else:
             logging.info('Could not find {} on {}. Skipping.'.format(label, push))
     combine_task_graph_files(backfill_pushes)
 
 
-def add_args_to_command(cmd_parts, extra_args=[]):
+def add_args_to_perf_command(payload_commands, extra_args=[]):
     """
         Add custom command line args to a given command.
         args:
-          cmd_parts: the raw command as seen by taskcluster
-          extra_args: array of args we want to add
+          payload_commands: the raw command as seen by taskcluster
+          extra_args: array of args we want to inject
     """
-    cmd_type = 'default'
-    if len(cmd_parts) == 1 and isinstance(cmd_parts[0], dict):
-        # windows has single cmd part as dict: 'task-reference', with long string
-        cmd_parts = cmd_parts[0]['task-reference'].split(' ')
-        cmd_type = 'dict'
-    elif len(cmd_parts) == 1 and isinstance(cmd_parts[0], list):
-        # osx has an single value array with an array inside
-        cmd_parts = cmd_parts[0]
-        cmd_type = 'subarray'
+    perf_command_idx = -1  # currently, it's the last (or only) command
+    perf_command = payload_commands[perf_command_idx]
 
-    cmd_parts.extend(extra_args)
+    command_form = 'default'
+    if isinstance(perf_command, string_types):
+        # windows has a single command, in long string form
+        perf_command = perf_command.split(' ')
+        command_form = 'string'
+    # osx & linux have an array of subarrays
 
-    if cmd_type == 'dict':
-        cmd_parts = [{'task-reference': ' '.join(cmd_parts)}]
-    elif cmd_type == 'subarray':
-        cmd_parts = [cmd_parts]
-    return cmd_parts
+    perf_command.extend(extra_args)
+
+    if command_form == 'string':
+        # pack it back to list
+        perf_command = ' '.join(perf_command)
+
+    payload_commands[perf_command_idx] = perf_command
+    return payload_commands