Bug 1293733: accept pushdate from command line; r=garndt
authorDustin J. Mitchell <dustin@mozilla.com>
Wed, 13 Jul 2016 18:50:50 +0000
changeset 308768 2a271d53d9784d68e05349f719ef5dc093c523f0
parent 308767 82eba2e77c35de3026ee1c501dc43d13b57df508
child 308769 88ea7345ceaccc1da8422de8c5dbf6a08c4ce237
push idunknown
push userunknown
push dateunknown
reviewersgarndt
bugs1293733
milestone51.0a1
Bug 1293733: accept pushdate from command line; r=garndt MozReview-Commit-ID: BrGiowlMVCa
.taskcluster.yml
taskcluster/docs/parameters.rst
taskcluster/mach_commands.py
taskcluster/taskgraph/decision.py
taskcluster/taskgraph/task/legacy.py
--- a/.taskcluster.yml
+++ b/.taskcluster.yml
@@ -97,16 +97,17 @@ tasks:
           - '--'
           - bash
           - -cx
           - >
               cd /home/worker/checkouts/gecko &&
               ln -s /home/worker/artifacts artifacts &&
               ./mach --log-no-times taskgraph decision
               --pushlog-id='{{pushlog_id}}'
+              --pushdate='{{pushdate}}'
               --project='{{project}}'
               --message='{{comment}}'
               --owner='{{owner}}'
               --level='{{level}}'
               --base-repository='https://hg.mozilla.org/mozilla-central'
               --head-repository='{{{url}}}'
               --head-ref='{{revision}}'
               --head-rev='{{revision}}'
--- a/taskcluster/docs/parameters.rst
+++ b/taskcluster/docs/parameters.rst
@@ -40,16 +40,20 @@ Push Information
    value may be forged and *must not* be relied on for authentication.
 
 ``message``
    The commit message
 
 ``pushlog_id``
    The ID from the ``hg.mozilla.org`` pushlog
 
+``pushdate``
+   The timestamp of the push to the repository that triggered this decision
+   task.  Expressed as an integer seconds since the UNIX epoch.
+
 Tree Information
 ----------------
 
 ``project``
    Another name for what may otherwise be called tree or branch or
    repository.  This is the unqualified name, such as ``mozilla-central`` or
    ``cedar``.
 
--- a/taskcluster/mach_commands.py
+++ b/taskcluster/mach_commands.py
@@ -128,16 +128,21 @@ class MachCommands(MachCommandBase):
                      help='Treeherder revision hash (long revision id) to attach results to')
     @CommandArgument('--project',
                      required=True,
                      help='Project to use for creating task graph. Example: --project=try')
     @CommandArgument('--pushlog-id',
                      dest='pushlog_id',
                      required=True,
                      default=0)
+    @CommandArgument('--pushdate',
+                     dest='pushdate',
+                     required=True,
+                     type=int,
+                     default=0)
     @CommandArgument('--owner',
                      required=True,
                      help='email address of who owns this graph')
     @CommandArgument('--level',
                      required=True,
                      help='SCM level of this repository')
     def taskgraph_decision(self, **options):
         """Run the decision task: generate a task graph and submit to
--- a/taskcluster/taskgraph/decision.py
+++ b/taskcluster/taskgraph/decision.py
@@ -102,16 +102,17 @@ def get_decision_parameters(options):
     parameters = {n: options[n] for n in [
         'base_repository',
         'head_repository',
         'head_rev',
         'head_ref',
         'message',
         'project',
         'pushlog_id',
+        'pushdate',
         'owner',
         'level',
         'target_tasks_method',
     ] if n in options}
 
     project = parameters['project']
     try:
         parameters.update(PER_PROJECT_PARAMETERS[project])
--- a/taskcluster/taskgraph/task/legacy.py
+++ b/taskcluster/taskgraph/task/legacy.py
@@ -368,31 +368,29 @@ class LegacyTask(base.Task):
 
         jobs = templates.load(job_path, {})
 
         job_graph, trigger_tests = parse_commit(message, jobs)
 
         cmdline_interactive = params.get('interactive', False)
 
         # Default to current time if querying the head rev fails
-        push_epoch = int(time.time())
         vcs_info = query_vcs_info(params['head_repository'], params['head_rev'])
         changed_files = set()
         if vcs_info:
-            push_epoch = vcs_info.pushdate
 
             logger.debug(
                 '{} commits influencing task scheduling:'.format(len(vcs_info.changesets)))
             for c in vcs_info.changesets:
                 logger.debug("{cset} {desc}".format(
                     cset=c['node'][0:12],
                     desc=c['desc'].splitlines()[0].encode('ascii', 'ignore')))
                 changed_files |= set(c['files'])
 
-        pushdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(push_epoch))
+        pushdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(params['pushdate']))
 
         # Template parameters used when expanding the graph
         parameters = dict(gaia_info().items() + {
             'index': 'index',
             'project': project,
             'pushlog_id': params.get('pushlog_id', 0),
             'docker_image': docker_image,
             'base_repository': params['base_repository'] or
@@ -400,17 +398,17 @@ class LegacyTask(base.Task):
             'head_repository': params['head_repository'],
             'head_ref': params['head_ref'] or params['head_rev'],
             'head_rev': params['head_rev'],
             'pushdate': pushdate,
             'pushtime': pushdate[8:],
             'year': pushdate[0:4],
             'month': pushdate[4:6],
             'day': pushdate[6:8],
-            'rank': push_epoch,
+            'rank': params['pushdate'],
             'owner': params['owner'],
             'level': params['level'],
         }.items())
 
         routes_file = os.path.join(root, 'routes.json')
         with open(routes_file) as f:
             contents = json.load(f)
             json_routes = contents['routes']