Bug 1212942 - Add pushdate routes; r=garndt,jlund

This commit is contained in:
Mike Shal 2015-10-09 09:26:34 -04:00
Родитель 312565be9b
Коммит 18bdfef857
5 изменённых файлов: 69 добавлений и 0 удалений

Просмотреть файл

@ -1396,12 +1396,17 @@ or run without that action (ie: --no-{action})"
repo = self._query_repo()
revision = self.query_revision()
pushinfo = self.vcs_query_pushinfo(repo, revision)
pushdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(pushinfo.pushdate))
index = self.config.get('taskcluster_index', 'index.garbage.staging')
fmt = {
'index': index,
'project': self.buildbot_config['properties']['branch'],
'head_rev': revision,
'pushdate': pushdate,
'year': pushdate[0:4],
'month': pushdate[4:6],
'day': pushdate[6:8],
'build_product': self.config['stage_product'],
'build_name': self.query_build_name(),
'build_type': self.query_build_type(),

Просмотреть файл

@ -11,6 +11,7 @@ This script manages Desktop repacks for nightly builds.
import os
import re
import sys
import time
import shlex
import logging
@ -965,6 +966,7 @@ class DesktopSingleLocale(LocalesMixin, ReleaseMixin, MockMixin, BuildbotMixin,
if not repo:
self.fatal("Unable to determine repository for querying the push info.")
pushinfo = self.vcs_query_pushinfo(repo, revision, vcs='hgtool')
pushdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(pushinfo.pushdate))
routes_json = os.path.join(self.query_abs_dirs()['abs_mozilla_dir'],
'testing/taskcluster/routes.json')
@ -980,6 +982,10 @@ class DesktopSingleLocale(LocalesMixin, ReleaseMixin, MockMixin, BuildbotMixin,
'index': self.config.get('taskcluster_index', 'index.garbage.staging'),
'project': branch,
'head_rev': revision,
'pushdate': pushdate,
'year': pushdate[0:4],
'month': pushdate[4:6],
'day': pushdate[6:8],
'build_product': self.config['stage_product'],
'build_name': self.query_build_name(),
'build_type': self.query_build_type(),

Просмотреть файл

@ -15,6 +15,7 @@ import os
import re
import subprocess
import sys
import time
import shlex
try:
@ -486,6 +487,7 @@ class MobileSingleLocale(MockMixin, LocalesMixin, ReleaseMixin,
revision = self.query_revision()
repo = self.query_l10n_repo()
pushinfo = self.vcs_query_pushinfo(repo, revision, vcs='hgtool')
pushdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(pushinfo.pushdate))
routes_json = os.path.join(self.query_abs_dirs()['abs_mozilla_dir'],
'testing/taskcluster/routes.json')
with open(routes_json) as f:
@ -506,6 +508,10 @@ class MobileSingleLocale(MockMixin, LocalesMixin, ReleaseMixin,
'index': self.config.get('taskcluster_index', 'index.garbage.staging'),
'project': branch,
'head_rev': revision,
'pushdate': pushdate,
'year': pushdate[0:4],
'month': pushdate[4:6],
'day': pushdate[6:8],
'build_product': self.config['stage_product'],
'build_name': self.query_build_name(),
'build_type': self.query_build_type(),

Просмотреть файл

@ -11,6 +11,8 @@ import os
import json
import copy
import sys
import time
from collections import namedtuple
from mach.decorators import (
CommandArgument,
@ -203,6 +205,44 @@ def remove_caches_from_task(task):
except KeyError:
pass
def query_pushinfo(repository, revision):
"""Query the pushdate and pushid of a repository/revision.
This is intended to be used on hg.mozilla.org/mozilla-central and
similar. It may or may not work for other hg repositories.
"""
PushInfo = namedtuple('PushInfo', ['pushid', 'pushdate'])
try:
import urllib2
url = '%s/json-pushes?changeset=%s' % (repository, revision)
sys.stderr.write("Querying URL for pushdate: %s\n" % url)
contents = json.load(urllib2.urlopen(url))
# The contents should be something like:
# {
# "28537": {
# "changesets": [
# "1d0a914ae676cc5ed203cdc05c16d8e0c22af7e5",
# ],
# "date": 1428072488,
# "user": "user@mozilla.com"
# }
# }
#
# So we grab the first element ("28537" in this case) and then pull
# out the 'date' field.
pushid = contents.iterkeys().next()
pushdate = contents[pushid]['date']
return PushInfo(pushid, pushdate)
except Exception:
sys.stderr.write(
"Error querying pushinfo for repository '%s' revision '%s'\n" % (
repository, revision,
)
)
return None
@CommandProvider
class DecisionTask(object):
@Command('taskcluster-decision', category="ci",
@ -333,6 +373,12 @@ class Graph(object):
cmdline_interactive = params.get('interactive', False)
# Default to current time if querying the head rev fails
pushdate = time.strftime('%Y%m%d%H%M%S', time.gmtime())
pushinfo = query_pushinfo(params['head_repository'], params['head_rev'])
if pushinfo:
pushdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(pushinfo.pushdate))
# Template parameters used when expanding the graph
parameters = dict(gaia_info().items() + {
'index': 'index',
@ -344,6 +390,10 @@ class Graph(object):
'head_repository': params['head_repository'],
'head_ref': params['head_ref'] or params['head_rev'],
'head_rev': params['head_rev'],
'pushdate': pushdate,
'year': pushdate[0:4],
'month': pushdate[4:6],
'day': pushdate[6:8],
'owner': params['owner'],
'from_now': json_time_from_now,
'now': current_json_time(),

Просмотреть файл

@ -1,6 +1,7 @@
{
"routes": [
"{index}.gecko.v2.{project}.revision.{head_rev}.{build_product}.{build_name}-{build_type}",
"{index}.gecko.v2.{project}.pushdate.{year}.{month}.{day}.{pushdate}.{build_product}.{build_name}-{build_type}",
"{index}.gecko.v2.{project}.latest.{build_product}.{build_name}-{build_type}"
],
"nightly": [
@ -11,6 +12,7 @@
],
"l10n": [
"{index}.gecko.v2.{project}.revision.{head_rev}.{build_product}-l10n.{build_name}-{build_type}.{locale}",
"{index}.gecko.v2.{project}.pushdate.{year}.{month}.{day}.{pushdate}.{build_product}-l10n.{build_name}-{build_type}.{locale}",
"{index}.gecko.v2.{project}.latest.{build_product}-l10n.{build_name}-{build_type}.{locale}"
]
}