[fenix] Taskgraph skeleton
[gecko.git] / mobile / android / fenix / .taskcluster.yml
blob4a1491a2b2c6555866752cddd4c3ef49fee89753
1 ---
2 version: 1
3 reporting: checks-v1
4 policy:
5     # XXX We restrict taskcluster to collaborators so priviledged tests (like UI tests) can run on PRs
6     pullRequests: collaborators
7 tasks:
8     - $let:
9           taskgraph:
10               branch: taskgraph
11               revision: 0c5a68749f9a7672a7e56604b69a7bd41b036614
12           trustDomain: mobile
13       in:
14           $if: 'tasks_for in ["github-pull-request", "github-push", "action", "cron"]'
15           then:
16               $let:
17                   # Github events have this stuff in different places...
18                   ownerEmail:
19                       $if: 'tasks_for == "github-push"'
20                       then: '${event.pusher.email}'
21                       # Assume Pull Request
22                       else:
23                           $if: 'tasks_for == "github-pull-request"'
24                           then: '${event.pull_request.user.login}@users.noreply.github.com'
25                           else:
26                               $if: 'tasks_for in ["cron", "action"]'
27                               then: '${tasks_for}@noreply.mozilla.org'
28                   baseRepoUrl:
29                       $if: 'tasks_for == "github-push"'
30                       then: '${event.repository.html_url}'
31                       else:
32                           $if: 'tasks_for == "github-pull-request"'
33                           then: '${event.pull_request.base.repo.html_url}'
34                           else:
35                               $if: 'tasks_for in ["cron", "action"]'
36                               then: '${repository.url}'
37                   repoUrl:
38                       $if: 'tasks_for == "github-push"'
39                       then: '${event.repository.html_url}'
40                       else:
41                           $if: 'tasks_for == "github-pull-request"'
42                           then: '${event.pull_request.head.repo.html_url}'
43                           else:
44                               $if: 'tasks_for in ["cron", "action"]'
45                               then: '${repository.url}'
46                   project:
47                       $if: 'tasks_for == "github-push"'
48                       then: '${event.repository.name}'
49                       else:
50                           $if: 'tasks_for == "github-pull-request"'
51                           then: '${event.pull_request.head.repo.name}'
52                           else:
53                               $if: 'tasks_for in ["cron", "action"]'
54                               then: '${repository.project}'
55                   head_branch:
56                       $if: 'tasks_for == "github-pull-request"'
57                       then: ${event.pull_request.head.ref}
58                       else:
59                           $if: 'tasks_for == "github-push"'
60                           then: ${event.ref}
61                           else:
62                               $if: 'tasks_for in ["cron", "action"]'
63                               then: '${push.branch}'
64                   head_sha:
65                       $if: 'tasks_for == "github-push"'
66                       then: '${event.after}'
67                       else:
68                           $if: 'tasks_for == "github-pull-request"'
69                           then: '${event.pull_request.head.sha}'
70                           else:
71                               $if: 'tasks_for in ["cron", "action"]'
72                               then: '${push.revision}'
73                   ownTaskId:
74                       $if: '"github" in tasks_for'
75                       then: {$eval: as_slugid("decision_task")}
76                       else:
77                           $if: 'tasks_for == "cron"'
78                           then: '${ownTaskId}'
79               in:
80                   $let:
81                       level:
82                           $if: 'tasks_for in ["github-push", "github-release", "action", "cron"] && repoUrl == "https://github.com/mozilla-mobile/fenix"'
83                           then: '3'
84                           else:
85                               $if: 'tasks_for in ["cron", "action"]'
86                               then: '${repository.level}'
87                               else: 1
88                   in:
89                       taskId: '${ownTaskId}'
90                       taskGroupId:
91                           $if: 'tasks_for == "action"'
92                           then:
93                               '${action.taskGroupId}'
94                           else:
95                               '${ownTaskId}'  # same as taskId; this is how automation identifies a decision task
96                       schedulerId: '${trustDomain}-level-${level}'
97                       created: {$fromNow: ''}
98                       deadline: {$fromNow: '1 day'}
99                       expires: {$fromNow: '1 year 1 second'}  # 1 second so artifacts expire first, despite rounding errors
100                       metadata:
101                           $merge:
102                               - owner: "${ownerEmail}"
103                                 source: '${repoUrl}/raw/${head_sha}/.taskcluster.yml'
104                               - $if: 'tasks_for in ["github-push", "github-pull-request"]'
105                                 then:
106                                     name: "Decision Task"
107                                     description: 'The task that creates all of the other tasks in the task graph'
108                                 else:
109                                     $if: 'tasks_for == "action"'
110                                     then:
111                                         name: "Action: ${action.title}"
112                                         description: '${action.description}'
113                                     else:
114                                         name: "Decision Task for cron job ${cron.job_name}"
115                                         description: 'Created by a [cron task](https://tools.taskcluster.net/tasks/${cron.task_id})'
116                       provisionerId: "aws-provisioner-v1"
117                       workerType: "mobile-${level}-decision"
118                       tags:
119                           $if: 'tasks_for in ["github-push", "github-pull-request"]'
120                           then:
121                               kind: decision-task
122                           else:
123                               $if: 'tasks_for == "action"'
124                               then:
125                                   kind: 'action-callback'
126                               else:
127                                   $if: 'tasks_for == "cron"'
128                                   then:
129                                       kind: cron-task
130                       routes:
131                           $flatten:
132                               - checks
133                               - $if: 'tasks_for != "github-pull-request"'
134                                 then:
135                                     - "tc-treeherder.v2.${project}.${head_sha}"
136                                 else: []
137                       scopes:
138                           # `https://` is 8 characters so, ${repoUrl[8:]} is the repository without the protocol.
139                           $if: 'tasks_for == "github-push"'
140                           then:
141                               $let:
142                                   short_head_branch:
143                                       $if: 'head_branch[:10] == "refs/tags/"'
144                                       then: {$eval: 'head_branch[10:]'}
145                                       else:
146                                           $if: 'head_branch[:11] == "refs/heads/"'
147                                           then: {$eval: 'head_branch[11:]'}
148                                           else: ${head_branch}
149                               in:
150                                   - 'assume:repo:${repoUrl[8:]}:branch:${short_head_branch}'
151                           else:
152                               $if: 'tasks_for == "github-pull-request"'
153                               then:
154                                   - 'assume:repo:github.com/${event.pull_request.base.repo.full_name}:pull-request'
155                               else:
156                                   $if: 'tasks_for == "action"'
157                                   then:
158                                       # when all actions are hooks, we can calculate this directly rather than using a variable
159                                       - '${action.repo_scope}'
160                                   else:
161                                       - 'assume:repo:${repoUrl[8:]}:cron:${cron.job_name}'
163                       requires: all-completed
164                       priority: lowest
165                       retries: 5
167                       payload:
168                           env:
169                               # run-task uses these to check out the source; the inputs
170                               # to `mach taskgraph decision` are all on the command line.
171                               $merge:
172                                   - MOBILE_BASE_REPOSITORY: '${baseRepoUrl}'
173                                     MOBILE_HEAD_REPOSITORY: '${repoUrl}'
174                                     MOBILE_HEAD_REF: '${head_branch}'
175                                     MOBILE_HEAD_REV: '${head_sha}'
176                                     MOBILE_REPOSITORY_TYPE: git
177                                     TASKGRAPH_BASE_REPOSITORY: https://hg.mozilla.org/ci/taskgraph
178                                     TASKGRAPH_HEAD_REPOSITORY: https://hg.mozilla.org/ci/${taskgraph.branch}
179                                     TASKGRAPH_HEAD_REV: ${taskgraph.revision}
180                                     TASKGRAPH_REPOSITORY_TYPE: hg
181                                     REPOSITORIES: {$json: {mobile: "Fenix", taskgraph: "Taskgraph"}}
182                                     HG_STORE_PATH: /builds/worker/checkouts/hg-store
183                                     ANDROID_SDK_ROOT: /builds/worker/android-sdk
184                                   - $if: 'tasks_for in ["github-pull-request"]'
185                                     then:
186                                         MOBILE_PULL_REQUEST_NUMBER: '${event.pull_request.number}'
187                                   - $if: 'tasks_for == "action"'
188                                     then:
189                                         ACTION_TASK_GROUP_ID: '${action.taskGroupId}'  # taskGroupId of the target task
190                                         ACTION_TASK_ID: {$json: {$eval: 'taskId'}}  # taskId of the target task (JSON-encoded)
191                                         ACTION_INPUT: {$json: {$eval: 'input'}}
192                                         ACTION_CALLBACK: '${action.cb_name}'
193                           features:
194                               taskclusterProxy: true
195                               chainOfTrust: true
196                           # Note: This task is built server side without the context or tooling that
197                           # exist in tree so we must hard code the hash
198                           image:
199                               mozillareleases/taskgraph:decision-mobile-6020473b1a928d8df50e234a7ca2e81ade2220a4fb5fbe16b02477dd64a49728@sha256:98d226736b7d03907114bf37938002b90e8a37cbe3a297690e349f1ddddb1d7c
201                           maxRunTime: 1800
203                           command:
204                               - /usr/local/bin/run-task
205                               - '--mobile-checkout=/builds/worker/checkouts/src'
206                               - '--taskgraph-checkout=/builds/worker/checkouts/taskgraph'
207                               - '--task-cwd=/builds/worker/checkouts/src'
208                               - '--'
209                               - bash
210                               - -cx
211                               - $let:
212                                     extraArgs: {$if: 'tasks_for == "cron"', then: '${cron.quoted_args}', else: ''}
213                                 in:
214                                     $if: 'tasks_for == "action"'
215                                     then: >
216                                         cd /builds/worker/checkouts/src &&
217                                         ln -s /builds/worker/artifacts artifacts &&
218                                         taskgraph action-callback
219                                     else: >
220                                         PIP_IGNORE_INSTALLED=0 pip install --user /builds/worker/checkouts/taskgraph &&
221                                         taskcluster/scripts/install-sdk.sh &&
222                                         ln -s /builds/worker/artifacts artifacts &&
223                                         ~/.local/bin/taskgraph decision
224                                         --pushlog-id='0'
225                                         --pushdate='0'
226                                         --project='${project}'
227                                         --message=""
228                                         --owner='${ownerEmail}'
229                                         --level='${level}'
230                                         --base-repository="$MOBILE_BASE_REPOSITORY"
231                                         --head-repository="$MOBILE_HEAD_REPOSITORY"
232                                         --head-ref="$MOBILE_HEAD_REF"
233                                         --head-rev="$MOBILE_HEAD_REV"
234                                         --repository-type="$MOBILE_REPOSITORY_TYPE"
235                                         --tasks-for='${tasks_for}'
236                                         ${extraArgs}
238                           artifacts:
239                               'public':
240                                   type: 'directory'
241                                   path: '/builds/worker/artifacts'
242                                   expires: {$fromNow: '1 year'}
244                       extra:
245                           $merge:
246                               - treeherder:
247                                     $merge:
248                                         - machine:
249                                               platform: gecko-decision
250                                         - $if: 'tasks_for in ["github-push", "github-pull-request"]'
251                                           then:
252                                               symbol: D
253                                           else:
254                                               $if: 'tasks_for == "action"'
255                                               then:
256                                                   groupName: 'action-callback'
257                                                   groupSymbol: AC
258                                                   symbol: "${action.symbol}"
259                                               else:
260                                                   groupSymbol: cron
261                                                   symbol: "${cron.job_symbol}"
262                               - $if: 'tasks_for == "action"'
263                                 then:
264                                     parent: '${action.taskGroupId}'
265                                     action:
266                                         name: '${action.name}'
267                                         context:
268                                             taskGroupId: '${action.taskGroupId}'
269                                             taskId: {$eval: 'taskId'}
270                                             input: {$eval: 'input'}
271                               - $if: 'tasks_for == "cron"'
272                                 then:
273                                     cron: {$json: {$eval: 'cron'}}
274                               - tasks_for: '${tasks_for}'