@@ -54,7 +54,7 @@ policy:
5454tasks :
5555 # NOTE: support for actions in ci-admin requires that the `tasks` property be an array *before* JSON-e rendering
5656 # takes place.
57- - $if : ' tasks_for in ["hg-push", "action", "cron"] '
57+ - $if : ' tasks_for in ["hg-push", "cron"] || (tasks_for == " action" && parameters["repository_type"] == "hg") '
5858 then :
5959 $let :
6060 # sometimes the push user is just `ffxbld` or the like, but we want an email-like field..
@@ -340,7 +340,7 @@ tasks:
340340 then :
341341 matrixBody : " ${repository.project} push notification: https://treeherder.mozilla.org/#/jobs?repo=${repository.project}&revision=${push.revision}"
342342 # Decision task for events originating from Github
343- - $if : ' tasks_for[:6] == "github"'
343+ - $if : ' tasks_for[:6] == "github" || (tasks_for in ["action", "pr-action"] && parameters["repository_type"] == "git") '
344344 then :
345345 $let :
346346 $merge :
@@ -370,6 +370,17 @@ tasks:
370370 baseRev : ' ${event.pull_request.base.sha}'
371371 headRev : ' ${event.pull_request.head.sha}'
372372 isPullRequest : true
373+ ' tasks_for in ["action", "pr-action"] ' :
374+ ownerEmail : ' ${tasks_for}@noreply.mozilla.org'
375+ baseRepoUrl : ' ${repository.url}'
376+ repoUrl : ' ${repository.url}'
377+ project : ' ${repository.project}'
378+ ref : ' ${push.branch}'
379+ baseRev : ' ${push.revision}'
380+ headRev : ' ${push.revision}'
381+ ownTaskId : ' ${ownTaskId}'
382+ eventType : action
383+ eventAction : null
373384 in :
374385 $let :
375386 shortRef :
@@ -378,34 +389,54 @@ tasks:
378389 else : ${ref}
379390 in :
380391 $if : >
381- (eventType == "push" && shortRef == "enterprise-main")
392+ eventType == "action"
393+ || (eventType == "push" && shortRef == "enterprise-main")
382394 || (isPullRequest && eventAction in ["opened", "reopened", "synchronize"])
383395 then :
384396 $let :
385397 level :
386- $if : ' eventType == "push" && repoUrl == "https://github.com/mozilla/enterprise-firefox" && shortRef == "enterprise-main"'
398+ $if : ' (tasks_for == "action" || eventType == "push") && repoUrl == "https://github.com/mozilla/enterprise-firefox" && shortRef == "enterprise-main"'
387399 then : 3
388400 else : 1
389401 in :
390402 taskId : ' ${ownTaskId}'
391- taskGroupId : ' ${ ownTaskId}'
403+ taskGroupId : {$if: 'eventType == "action"', then: '${action.taskGroupId}', else: '${ ownTaskId}'}
392404 schedulerId : ' ${trustDomain}-level-${level}'
393-
394405 created : {$fromNow: ''}
395406 deadline : {$fromNow: '1 day'}
396407 expires : {$fromNow: '1 year 1 second'} # 1 second so artifacts expire first
397408 metadata :
398- owner : " ${ownerEmail}"
399- source : " ${repoUrl}/raw/${headRev}/.taskcluster.yml"
400- name : " Decision Task (${eventType})"
401- description : ' The task that creates all of the other tasks in the task graph'
409+ $merge :
410+ - owner : " ${ownerEmail}"
411+ source : " ${repoUrl}/raw/${headRev}/.taskcluster.yml"
412+ - $switch :
413+ ' tasks_for == "action" ' :
414+ name : " Action: ${action.title}"
415+ description : |
416+ ${action.description}
417+
418+ Action triggered by clientID `${clientId}`
419+ ' tasks_for == "pr-action" ' :
420+ name : " PR action: ${action.title}"
421+ description : |
422+ ${action.description}
423+
424+ PR action triggered by clientID `${clientId}`
425+ $default :
426+ name : " Decision Task (${eventType})"
427+ description : ' The task that creates all of the other tasks in the task graph'
402428
403429 provisionerId : " ${trustDomain}-${level}"
404430 workerType : " decision"
405431
406432 tags :
407- createdForUser : " ${ownerEmail}"
408- kind : decision-task
433+ $merge :
434+ - createdForUser : " ${ownerEmail}"
435+ - $switch :
436+ ' eventType == "action" ' :
437+ kind : action-callback
438+ ' $default ' :
439+ kind : decision-task
409440
410441 routes :
411442 $flattenDeep :
@@ -417,15 +448,19 @@ tasks:
417448 - " tc-treeherder.v2.${project}.${headRev}"
418449 - " index.${trustDomain}.v2.${project}.latest.taskgraph.decision"
419450 - " index.${trustDomain}.v2.${project}.revision.${headRev}.taskgraph.decision"
451+ ' eventType == "action" ' :
452+ - " index.${trustDomain}.v2.${project}.revision.${headRev}.taskgraph.actions.${ownTaskId}"
420453 scopes :
421454 $switch :
422455 isPullRequest :
423456 - ' assume:repo:${baseRepoUrl[8:]}:${eventType}'
424457 ' eventType == "push" ' :
425458 - ' assume:repo:${repoUrl[8:]}:branch:${shortRef}'
459+ ' eventType == "action" ' :
460+ - ' assume:repo:${repoUrl[8:]}:action:${action.action_perm}'
426461 dependencies : []
427462 requires : all-completed
428- priority : very-low
463+ priority : {$if: 'eventType == "action"', then: "lowest", else: " very-low"}
429464 retries : 5
430465
431466 payload :
@@ -450,6 +485,12 @@ tasks:
450485 - $if : ' isPullRequest'
451486 then :
452487 GECKO_PULL_REQUEST_NUMBER : ' ${event.pull_request.number}'
488+ - $if : ' eventType == "action"'
489+ then :
490+ ACTION_TASK_GROUP_ID : ' ${action.taskGroupId}'
491+ ACTION_TASK_ID : {$json: {$eval: 'taskId'}}
492+ ACTION_INPUT : {$json: {$eval: 'input'}}
493+ ACTION_CALLBACK : ' ${action.cb_name}'
453494 cache :
454495 " ${trustDomain}-level-${level}-${project}-checkouts-git-shallow-v1 " : /builds/worker/checkouts
455496
@@ -466,7 +507,12 @@ tasks:
466507 - ' --'
467508 - bash
468509 - -cx
469- - >
510+ - $if : ' eventType == "action"'
511+ then : >
512+ cd /builds/worker/checkouts/gecko &&
513+ ln -s /builds/worker/artifacts artifacts &&
514+ ./mach --log-no-times taskgraph action-callback
515+ else : >
470516 cd /builds/worker/checkouts/gecko &&
471517 ln -s /builds/worker/artifacts artifacts &&
472518 ./mach --log-no-times taskgraph decision \
@@ -500,7 +546,24 @@ tasks:
500546 extra :
501547 $merge :
502548 - treeherder :
503- machine :
504- platform : gecko-decision
505- symbol : D
549+ $merge :
550+ - machine :
551+ platform : gecko-decision
552+ - $switch :
553+ ' eventType == "action" ' :
554+ groupName : ' action-callback'
555+ groupSymbol : AC
556+ symbol : ' ${action.symbol}'
557+ $default :
558+ symbol : D
559+ - $if : ' eventType == "action"'
560+ then :
561+ parent : ' ${action.taskGroupId}'
562+ action :
563+ name : ' ${action.name}'
564+ context :
565+ taskGroupId : ' ${action.taskGroupId}'
566+ taskId : {$eval: 'taskId'}
567+ input : {$eval: 'input'}
568+ clientId : {$eval: 'clientId'}
506569 - tasks_for : ' ${tasks_for}'
0 commit comments