Skip to content

Commit 2c07b47

Browse files
committed
Bug XXXXXXX - Support Github pull requests in Enterprise Firefox
1 parent e1ef683 commit 2c07b47

File tree

1 file changed

+42
-35
lines changed

1 file changed

+42
-35
lines changed

.taskcluster.yml

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -338,43 +338,50 @@ tasks:
338338
then:
339339
matrixBody: "${repository.project} push notification: https://treeherder.mozilla.org/#/jobs?repo=${repository.project}&revision=${push.revision}"
340340
# Decision task for events originating from Github
341-
- $if: 'tasks_for in ["github-push"]'
341+
- $if: 'tasks_for in ["github-push", "github-pull-request"]'
342342
then:
343343
$let:
344-
trustDomain: enterprise
345-
level: 1
346-
ownerEmail: '${event.pusher.email}'
347-
baseRepoUrl: '${event.repository.html_url}'
348-
repoUrl: '${event.repository.html_url}'
349-
project: '${event.repository.name}'
350-
head_branch: ${event.ref}
351-
head_ref: '${event.ref}'
352-
base_sha: '${event.before}'
353-
head_sha: '${event.after}'
354-
ownTaskId: {$eval: as_slugid("decision_task")}
344+
$merge:
345+
- trustDomain: enterprise
346+
level: 1
347+
ownTaskId: {$eval: as_slugid("decision_task")}
348+
- $switch:
349+
'tasks_for == "github-push"':
350+
ownerEmail: '${event.pusher.email}'
351+
baseRepoUrl: '${event.repository.html_url}'
352+
repoUrl: '${event.repository.html_url}'
353+
project: '${event.repository.name}'
354+
ref: '${event.ref}'
355+
baseRev: '${event.before}'
356+
headRev: '${event.after}'
357+
'tasks_for[:19] == "github-pull-request"':
358+
ownerEmail: '${event.pull_request.user.login}@users.noreply.github.com'
359+
baseRepoUrl: '${event.pull_request.base.repo.html_url}'
360+
repoUrl: '${event.pull_request.head.repo.html_url}'
361+
project: '${event.pull_request.base.repo.name}'
362+
ref: '${event.pull_request.head.ref}'
363+
baseRev: '${event.pull_request.base.sha}'
364+
headRev: '${event.pull_request.head.sha}'
355365
in:
356-
$if: >
357-
tasks_for == "github-push" && (head_branch == "refs/heads/enterprise-main" || head_branch == "refs/heads/enterprise-try")
358-
then:
359-
$let:
360-
short_head_ref:
361-
$if: 'head_ref[:10] == "refs/tags/"'
362-
then: {$eval: 'head_ref[10:]'}
363-
else:
364-
$if: 'head_ref[:11] == "refs/heads/"'
365-
then: {$eval: 'head_ref[11:]'}
366-
else: ${head_ref}
367-
in:
366+
$let:
367+
shortRef:
368+
$if: 'ref[:11] == "refs/heads/"'
369+
then: {$eval: 'ref[11:]'}
370+
else: ${ref}
371+
in:
372+
$if: >
373+
tasks_for == "github-push" && shortRef in ["enterprise-main", "enterprise-try"]
374+
then:
368375
taskId: '${ownTaskId}'
369-
taskGroupId: '${ownTaskId}' # same as taskId; this is how automation identifies a decision task
376+
taskGroupId: '${ownTaskId}'
370377
schedulerId: '${trustDomain}-level-${level}'
371378

372379
created: {$fromNow: ''}
373380
deadline: {$fromNow: '1 day'}
374381
expires: {$fromNow: '1 year 1 second'} # 1 second so artifacts expire first
375382
metadata:
376383
owner: "${ownerEmail}"
377-
source: "${repoUrl}/raw/${head_sha}/.taskcluster.yml"
384+
source: "${repoUrl}/raw/${headRev}/.taskcluster.yml"
378385
name: "Decision Task (Push)"
379386
description: 'The task that creates all of the other tasks in the task graph'
380387

@@ -390,11 +397,11 @@ tasks:
390397
- checks
391398
- $if: 'tasks_for == "github-push"'
392399
then:
393-
- "tc-treeherder.v2.${project}.${head_sha}"
400+
- "tc-treeherder.v2.${project}.${headRev}"
394401
- "index.${trustDomain}.v2.${project}.latest.taskgraph.decision"
395-
- "index.${trustDomain}.v2.${project}.revision.${head_sha}.taskgraph.decision"
402+
- "index.${trustDomain}.v2.${project}.revision.${headRev}.taskgraph.decision"
396403
scopes:
397-
- 'assume:repo:${repoUrl[8:]}:branch:${short_head_ref}'
404+
- 'assume:repo:${repoUrl[8:]}:branch:${shortRef}'
398405
dependencies: []
399406
requires: all-completed
400407
priority: very-low
@@ -403,10 +410,10 @@ tasks:
403410
payload:
404411
env:
405412
GECKO_BASE_REPOSITORY: '${baseRepoUrl}'
406-
GECKO_BASE_REV: '${base_sha}'
413+
GECKO_BASE_REV: '${baseRev}'
407414
GECKO_HEAD_REPOSITORY: '${repoUrl}'
408-
GECKO_HEAD_REF: '${head_ref}'
409-
GECKO_HEAD_REV: '${head_sha}'
415+
GECKO_HEAD_REF: '${ref}'
416+
GECKO_HEAD_REV: '${headRev}'
410417
GECKO_REPOSITORY_TYPE: git
411418
REPOSITORIES: {$json: {gecko: "Mozilla Firefox"}}
412419
TASKCLUSTER_CACHES: /builds/worker/checkouts
@@ -446,10 +453,10 @@ tasks:
446453
--repository-type=git \
447454
--tasks-for='${tasks_for}' \
448455
--base-repository='${baseRepoUrl}' \
449-
--base-rev='${base_sha}' \
456+
--base-rev='${baseRev}' \
450457
--head-repository='${repoUrl}' \
451-
--head-ref='${head_ref}' \
452-
--head-rev='${head_sha}'
458+
--head-ref='${ref}' \
459+
--head-rev='${headRev}'
453460
454461
artifacts:
455462
'public':

0 commit comments

Comments
 (0)