Bug 1215157 - Add --dry-run to mach taskcluster-graph; r=garndt
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
28
testing/taskcluster/taskcluster_graph/dry_run.py
Normal file
28
testing/taskcluster/taskcluster_graph/dry_run.py
Normal 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'
|
||||
Reference in New Issue
Block a user