Bug 1215157 - Add --dry-run to mach taskcluster-graph; r=garndt

This commit is contained in:
Mike Shal
2015-10-14 11:26:35 -04:00
parent 0def4012ac
commit 34da8d22c2
2 changed files with 38 additions and 0 deletions

View File

@@ -292,6 +292,9 @@ class Graph(object):
@CommandArgument('--print-names-only',
action='store_true', default=False,
help="Only print the names of each scheduled task, one per line.")
@CommandArgument('--dry-run',
action='store_true', default=False,
help="Stub out taskIds and date fields from the task definitions.")
def create_graph(self, **params):
from taskcluster_graph.commit_parser import parse_commit
from slugid import nice as slugid
@@ -302,6 +305,13 @@ class Graph(object):
from taskcluster_graph.templates import Templates
import taskcluster_graph.build_task
if params['dry_run']:
from taskcluster_graph.dry_run import (
json_time_from_now,
current_json_time,
slugid,
)
project = params['project']
message = params.get('message', '') if project == 'try' else DEFAULT_TRY

View File

@@ -0,0 +1,28 @@
import datetime
from from_now import value_of
def json_time_from_now(input_str, now=None):
'''
:param str input_str: Input string (see value of)
:param datetime now: Optionally set the definition of `now`
:returns: JSON string representation of time in future.
'''
if now is None:
now = datetime.date.fromordinal(1)
time = now + value_of(input_str)
# Sorta a big hack but the json schema validator for date does not like the
# ISO dates until 'Z' (for timezone) is added...
return time.isoformat() + 'Z'
def current_json_time():
'''
:returns: JSON string representation of the current time.
'''
return datetime.date.fromordinal(1).isoformat() + 'Z'
def slugid():
return 'abcdef123456'