Bug 1524358 - use ownTaskId, instead of as_slugid('decision'), in .taskcluster.yml r=Callek,tomprince

This is a forward-looking change to allow evaluation of .taskcluster.yml in
situations where as_slugid is not defined -- such as in the Taskcluster hooks
service.

Differential Revision: https://phabricator.services.mozilla.com/D18269

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dustin J. Mitchell 2019-02-01 23:27:47 +00:00
Родитель da6fa3a08b
Коммит 0a44f01f62
2 изменённых файлов: 6 добавлений и 14 удалений

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

@ -7,6 +7,7 @@
# repository: {url, project, level}, # repository: {url, project, level},
# now, # now,
# as_slugid: // function # as_slugid: // function
# ownTaskId: // taskId of the task that will be created
# } # }
# #
# - cron tasks - See taskcluster/taskgraph/cron/decision.py # - cron tasks - See taskcluster/taskgraph/cron/decision.py
@ -16,7 +17,7 @@
# repository: {url, project, level}, # repository: {url, project, level},
# cron: {task_id, job_name, job_symbol, quoted_args}, # cron: {task_id, job_name, job_symbol, quoted_args},
# now, # now,
# as_slugid, // function # ownTaskId: // taskId of the task that will be created
# } # }
# #
# - action tasks - See: # - action tasks - See:
@ -58,13 +59,13 @@ tasks:
# ensure there's no trailing `/` on the repo URL # ensure there's no trailing `/` on the repo URL
repoUrl: {$if: 'repository.url[-1] == "/"', then: {$eval: 'repository.url[:-1]'}, else: {$eval: 'repository.url'}} repoUrl: {$if: 'repository.url[-1] == "/"', then: {$eval: 'repository.url[:-1]'}, else: {$eval: 'repository.url'}}
in: in:
taskId: {$if: 'tasks_for != "action"', then: '${as_slugid("decision")}'} taskId: {$if: 'tasks_for != "action"', then: '${ownTaskId}'}
taskGroupId: taskGroupId:
$if: 'tasks_for == "action"' $if: 'tasks_for == "action"'
then: then:
'${action.taskGroupId}' '${action.taskGroupId}'
else: else:
'${as_slugid("decision")}' # same as taskId; this is how automation identifies a decision tsak '${ownTaskId}' # same as taskId; this is how automation identifies a decision tsak
schedulerId: 'gecko-level-${repository.level}' schedulerId: 'gecko-level-${repository.level}'
created: {$fromNow: ''} created: {$fromNow: ''}
@ -137,7 +138,7 @@ tasks:
- "index.gecko.v2.${repository.project}.revision.${push.revision}.taskgraph.decision-${cron.job_name}" - "index.gecko.v2.${repository.project}.revision.${push.revision}.taskgraph.decision-${cron.job_name}"
- "index.gecko.v2.${repository.project}.pushlog-id.${push.pushlog_id}.decision-${cron.job_name}" - "index.gecko.v2.${repository.project}.pushlog-id.${push.pushlog_id}.decision-${cron.job_name}"
# list each cron task on this revision, so actions can find them # list each cron task on this revision, so actions can find them
- 'index.gecko.v2.${repository.project}.revision.${push.revision}.cron.${as_slugid("decision")}' - 'index.gecko.v2.${repository.project}.revision.${push.revision}.cron.${ownTaskId}'
# BUG 1500166 Notify ciduty by email if a nightly hook fails # BUG 1500166 Notify ciduty by email if a nightly hook fails
- "notify.email.ciduty+failedcron@mozilla.com.on-failed" - "notify.email.ciduty+failedcron@mozilla.com.on-failed"
- "notify.email.ciduty+exceptioncron@mozilla.com.on-exception" - "notify.email.ciduty+exceptioncron@mozilla.com.on-exception"

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

@ -43,15 +43,6 @@ def make_decision_task(params, root, symbol, arguments=[]):
params['repository_url'], params['repository_url'],
params['head_rev']) params['head_rev'])
slugids = {}
def as_slugid(name):
# https://github.com/taskcluster/json-e/issues/164
name = name[0]
if name not in slugids:
slugids[name] = slugid.nice()
return slugids[name]
# provide a similar JSON-e context to what mozilla-taskcluster provides: # provide a similar JSON-e context to what mozilla-taskcluster provides:
# https://docs.taskcluster.net/reference/integrations/mozilla-taskcluster/docs/taskcluster-yml # https://docs.taskcluster.net/reference/integrations/mozilla-taskcluster/docs/taskcluster-yml
# but with a different tasks_for and an extra `cron` section # but with a different tasks_for and an extra `cron` section
@ -78,7 +69,7 @@ def make_decision_task(params, root, symbol, arguments=[]):
'quoted_args': ' '.join(pipes.quote(a) for a in arguments), 'quoted_args': ' '.join(pipes.quote(a) for a in arguments),
}, },
'now': current_json_time(), 'now': current_json_time(),
'as_slugid': as_slugid, 'ownTaskId': slugid.nice(),
} }
rendered = jsone.render(taskcluster_yml, context) rendered = jsone.render(taskcluster_yml, context)