.taskcluster.yml 19.8 KB
Newer Older
Johan Lorenzo's avatar
Johan Lorenzo committed
1
---
2
version: 1
Johan Lorenzo's avatar
Johan Lorenzo committed
3
reporting: checks-v1
4
policy:
Johan Lorenzo's avatar
Johan Lorenzo committed
5
6
    # XXX We restrict taskcluster to collaborators so priviledged tests (like UI tests) can run on PRs
    pullRequests: collaborators
7
tasks:
Johan Lorenzo's avatar
Johan Lorenzo committed
8
9
10
    - $let:
          taskgraph:
              branch: taskgraph
Tom Prince's avatar
Tom Prince committed
11
              revision: 12992b0f984884ec2b0a7bdedc3b3ba467363eb4
Johan Lorenzo's avatar
Johan Lorenzo committed
12
          trustDomain: mobile
13
      in:
14
15
16
          $let:
              # Github events have this stuff in different places...
              ownerEmail:
17
18
19
                  $if: 'tasks_for in ["cron", "action"]'
                  then: '${tasks_for}@noreply.mozilla.org'
                  else:
20
21
22
                      $if: 'tasks_for == "github-push"'
                      then: '${event.pusher.email}'
                      # Assume Pull Request
Johan Lorenzo's avatar
Johan Lorenzo committed
23
                      else:
24
25
                          $if: 'tasks_for == "github-pull-request"'
                          then: '${event.pull_request.user.login}@users.noreply.github.com'
Johan Lorenzo's avatar
Johan Lorenzo committed
26
                          else:
27
28
                              $if: 'tasks_for == "github-release"'
                              then: '${event.sender.login}@users.noreply.github.com'
29
30
31
32
33
34
              baseRepoUrl:
                  $if: 'tasks_for in ["github-push", "github-release"]'
                  then: '${event.repository.html_url}'
                  else:
                      $if: 'tasks_for == "github-pull-request"'
                      then: '${event.pull_request.base.repo.html_url}'
Johan Lorenzo's avatar
Johan Lorenzo committed
35
                      else:
36
37
38
39
40
41
42
43
                          $if: 'tasks_for in ["cron", "action"]'
                          then: '${repository.url}'
              repoUrl:
                  $if: 'tasks_for in ["github-push", "github-release"]'
                  then: '${event.repository.html_url}'
                  else:
                      $if: 'tasks_for == "github-pull-request"'
                      then: '${event.pull_request.head.repo.html_url}'
Johan Lorenzo's avatar
Johan Lorenzo committed
44
                      else:
45
46
47
48
49
50
                          $if: 'tasks_for in ["cron", "action"]'
                          then: '${repository.url}'
              project:
                  $if: 'tasks_for in ["github-push", "github-release"]'
                  then: '${event.repository.name}'
                  else:
Johan Lorenzo's avatar
Johan Lorenzo committed
51
                      $if: 'tasks_for == "github-pull-request"'
52
                      then: '${event.pull_request.head.repo.name}'
Johan Lorenzo's avatar
Johan Lorenzo committed
53
                      else:
54
55
56
57
58
59
60
61
62
63
64
                          $if: 'tasks_for in ["cron", "action"]'
                          then: '${repository.project}'
              head_branch:
                  $if: 'tasks_for == "github-pull-request"'
                  then: ${event.pull_request.head.ref}
                  else:
                      $if: 'tasks_for == "github-push"'
                      then: ${event.ref}
                      else:
                          $if: 'tasks_for == "github-release"'
                          then: '${event.release.target_commitish}'
Johan Lorenzo's avatar
Johan Lorenzo committed
65
                          else:
66
                              $if: 'tasks_for in ["action", "cron"]'
Johan Lorenzo's avatar
Johan Lorenzo committed
67
                              then: '${push.branch}'
68
69
70
71
72
73
              head_sha:
                  $if: 'tasks_for == "github-push"'
                  then: '${event.after}'
                  else:
                      $if: 'tasks_for == "github-pull-request"'
                      then: '${event.pull_request.head.sha}'
Johan Lorenzo's avatar
Johan Lorenzo committed
74
                      else:
75
76
                          $if: 'tasks_for == "github-release"'
                          then: '${event.release.tag_name}'
Johan Lorenzo's avatar
Johan Lorenzo committed
77
                          else:
78
                              $if: 'tasks_for in ["action", "cron"]'
Johan Lorenzo's avatar
Johan Lorenzo committed
79
                              then: '${push.revision}'
80

81

82
83
84
85
              head_tag:
                  $if: 'tasks_for == "github-release"'
                  then: '${event.release.tag_name}'
                  else: ''
86
87
88
89
              ownTaskId:
                  $if: '"github" in tasks_for'
                  then: {$eval: as_slugid("decision_task")}
                  else:
90
                      $if: 'tasks_for in ["cron", "action"]'
91
                      then: '${ownTaskId}'
92
93
94
95
              pullRequestAction:
                  $if: 'tasks_for == "github-pull-request"'
                  then: ${event.action}
                  else: 'UNDEFINED'
96
97
98
99
              releaseAction:
                  $if: 'tasks_for == "github-release"'
                  then: ${event.action}
                  else: 'UNDEFINED'
100
          in:
101
102
              $if: >
                tasks_for in ["action", "cron"]
103
                || (tasks_for == "github-pull-request" && pullRequestAction in ["opened", "reopened", "synchronize"])
104
                || (tasks_for == "github-push" && head_branch[:10] != "refs/tags/")
105
                || (tasks_for == "github-release" && releaseAction == "published")
106
              then:
Johan Lorenzo's avatar
Johan Lorenzo committed
107
108
109
110
                  $let:
                      level:
                          $if: 'tasks_for in ["github-push", "github-release", "action", "cron"] && repoUrl == "https://github.com/mozilla-mobile/fenix"'
                          then: '3'
111
                          else: '1'
112
113
114
115

                      short_head_branch:
                          $if: 'head_branch[:11] == "refs/heads/"'
                          then: {$eval: 'head_branch[11:]'}
Johan Lorenzo's avatar
Johan Lorenzo committed
116
                  in:
117
118
                    $mergeDeep:
                        - $if: 'tasks_for != "action"'
Johan Lorenzo's avatar
Johan Lorenzo committed
119
                          then:
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
                              taskId: '${ownTaskId}'
                        - taskGroupId:
                              $if: 'tasks_for == "action"'
                              then:
                                  '${action.taskGroupId}'
                              else:
                                  '${ownTaskId}'  # same as taskId; this is how automation identifies a decision task
                          schedulerId: '${trustDomain}-level-${level}'
                          created: {$fromNow: ''}
                          deadline: {$fromNow: '1 day'}
                          expires: {$fromNow: '1 year 1 second'}  # 1 second so artifacts expire first, despite rounding errors
                          metadata:
                              $merge:
                                  - owner: "${ownerEmail}"
                                    source: '${repoUrl}/raw/${head_sha}/.taskcluster.yml'
                                  - $if: 'tasks_for in ["github-push", "github-pull-request", "github-release"]'
Johan Lorenzo's avatar
Johan Lorenzo committed
136
                                    then:
137
138
                                        name: "Decision Task"
                                        description: 'The task that creates all of the other tasks in the task graph'
Johan Lorenzo's avatar
Johan Lorenzo committed
139
                                    else:
140
141
142
                                        $if: 'tasks_for == "action"'
                                        then:
                                            name: "Action: ${action.title}"
143
144
145
146
                                            description: |
                                                ${action.description}

                                                Action triggered by clientID `${clientId}`
147
148
149
150
151
152
153
                                        else:
                                            name: "Decision Task for cron job ${cron.job_name}"
                                            description: 'Created by a [cron task](https://firefox-ci-tc.services.mozilla.com/tasks/${cron.task_id})'
                          provisionerId: "mobile-${level}"
                          workerType: "decision"
                          tags:
                              $if: 'tasks_for in ["github-push", "github-pull-request"]'
Johan Lorenzo's avatar
Johan Lorenzo committed
154
                              then:
155
                                  kind: decision-task
Johan Lorenzo's avatar
Johan Lorenzo committed
156
                              else:
157
                                  $if: 'tasks_for == "action"'
Johan Lorenzo's avatar
Johan Lorenzo committed
158
                                  then:
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
                                      kind: 'action-callback'
                                  else:
                                      $if: 'tasks_for == "cron"'
                                      then:
                                          kind: cron-task
                          routes:
                              $flattenDeep:
                                  - checks
                                  - $if: 'level == "3"'
                                    then:
                                        - tc-treeherder.v2.${project}.${head_sha}
                                        # TODO Bug 1601928: Make this scope fork-friendly once ${project} is better defined. This will enable
                                        # staging release promotion on forks.
                                        - $if: 'tasks_for == "github-push"'
                                          then:
174
175
                                              - index.mobile.v2.${project}.branch.${short_head_branch}.latest.taskgraph.decision
                                              - index.mobile.v2.${project}.branch.${short_head_branch}.revision.${head_sha}.taskgraph.decision
176
                                              - index.mobile.v2.${project}.revision.${head_sha}.taskgraph.decision
177
178
                                        - $if: 'tasks_for == "cron"'
                                          then:
179
                                              # cron context provides ${head_branch} as a short one
180
181
182
                                              - index.mobile.v2.${project}.branch.${head_branch}.latest.taskgraph.decision-${cron.job_name}
                                              - index.mobile.v2.${project}.branch.${head_branch}.revision.${head_sha}.taskgraph.decision-${cron.job_name}
                                              - index.mobile.v2.${project}.branch.${head_branch}.revision.${head_sha}.taskgraph.cron.${ownTaskId}
183
184
                          scopes:
                              $if: 'tasks_for == "github-push"'
Johan Lorenzo's avatar
Johan Lorenzo committed
185
                              then:
186
187
                                  # `https://` is 8 characters so, ${repoUrl[8:]} is the repository without the protocol.
                                  - 'assume:repo:${repoUrl[8:]}:branch:${short_head_branch}'
Johan Lorenzo's avatar
Johan Lorenzo committed
188
                              else:
189
                                  $if: 'tasks_for == "github-pull-request"'
Johan Lorenzo's avatar
Johan Lorenzo committed
190
                                  then:
191
                                      - 'assume:repo:github.com/${event.pull_request.base.repo.full_name}:pull-request'
Johan Lorenzo's avatar
Johan Lorenzo committed
192
                                  else:
193
                                      $if: 'tasks_for == "github-release"'
194
                                      then:
195
                                          - 'assume:repo:${repoUrl[8:]}:release'
196
                                      else:
197
198
199
200
201
202
                                          $if: 'tasks_for == "action"'
                                          then:
                                              # when all actions are hooks, we can calculate this directly rather than using a variable
                                              - '${action.repo_scope}'
                                          else:
                                              - 'assume:repo:${repoUrl[8:]}:cron:${cron.job_name}'
Johan Lorenzo's avatar
Johan Lorenzo committed
203

204
205
206
                          requires: all-completed
                          priority: lowest
                          retries: 5
Johan Lorenzo's avatar
Johan Lorenzo committed
207

208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
                          payload:
                              env:
                                  # run-task uses these to check out the source; the inputs
                                  # to `mach taskgraph decision` are all on the command line.
                                  $merge:
                                      - MOBILE_BASE_REPOSITORY: '${baseRepoUrl}'
                                        MOBILE_HEAD_REPOSITORY: '${repoUrl}'
                                        MOBILE_HEAD_REF: '${head_branch}'
                                        MOBILE_HEAD_REV: '${head_sha}'
                                        MOBILE_HEAD_TAG: '${head_tag}'
                                        MOBILE_REPOSITORY_TYPE: git
                                        TASKGRAPH_BASE_REPOSITORY: https://hg.mozilla.org/ci/taskgraph
                                        TASKGRAPH_HEAD_REPOSITORY: https://hg.mozilla.org/ci/${taskgraph.branch}
                                        TASKGRAPH_HEAD_REV: ${taskgraph.revision}
                                        TASKGRAPH_REPOSITORY_TYPE: hg
                                        REPOSITORIES: {$json: {mobile: "Fenix", taskgraph: "Taskgraph"}}
                                        HG_STORE_PATH: /builds/worker/checkouts/hg-store
                                        ANDROID_SDK_ROOT: /builds/worker/android-sdk
                                      - $if: 'tasks_for in ["github-pull-request"]'
                                        then:
                                            MOBILE_PULL_REQUEST_NUMBER: '${event.pull_request.number}'
                                      - $if: 'tasks_for == "action"'
                                        then:
                                            ACTION_TASK_GROUP_ID: '${action.taskGroupId}'  # taskGroupId of the target task
                                            ACTION_TASK_ID: {$json: {$eval: 'taskId'}}  # taskId of the target task (JSON-encoded)
                                            ACTION_INPUT: {$json: {$eval: 'input'}}
                                            ACTION_CALLBACK: '${action.cb_name}'
                                      - $if: 'tasks_for == "github-release"'
                                        then:
                                            MOBILE_HEAD_TAG: '${event.release.tag_name}'
                              features:
                                  taskclusterProxy: true
                                  chainOfTrust: true
                              # Note: This task is built server side without the context or tooling that
                              # exist in tree so we must hard code the hash
                              image:
244
                                  mozillareleases/taskgraph:decision-mobile-6607973bc60e32323a541861cc5856cd6a0f51ea9fd664ef7d43bca8df53db47@sha256:8c471aacc469ea8e7bb4846c16efe086f7350a5cc1df570cc6c86b22895a2456
Johan Lorenzo's avatar
Johan Lorenzo committed
245

246
                              maxRunTime: 1800
Johan Lorenzo's avatar
Johan Lorenzo committed
247

248
249
250
251
252
253
254
255
256
257
258
259
260
261
                              command:
                                  - /usr/local/bin/run-task
                                  - '--mobile-checkout=/builds/worker/checkouts/src'
                                  - '--taskgraph-checkout=/builds/worker/checkouts/taskgraph'
                                  - '--task-cwd=/builds/worker/checkouts/src'
                                  - '--'
                                  - bash
                                  - -cx
                                  - $let:
                                        extraArgs: {$if: 'tasks_for == "cron"', then: '${cron.quoted_args}', else: ''}
                                    in:
                                        $if: 'tasks_for == "action"'
                                        then: >
                                            PIP_IGNORE_INSTALLED=0 pip install --user /builds/worker/checkouts/taskgraph &&
262
                                            taskcluster/scripts/decision-install-sdk.sh &&
263
264
265
266
267
                                            ln -s /builds/worker/artifacts artifacts &&
                                            ~/.local/bin/taskgraph action-callback
                                        else: >
                                            PIP_IGNORE_INSTALLED=0 pip install --user /builds/worker/checkouts/taskgraph &&
                                            PIP_IGNORE_INSTALLED=0 pip install --user arrow taskcluster pyyaml &&
268
                                            taskcluster/scripts/decision-install-sdk.sh &&
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
                                            ln -s /builds/worker/artifacts artifacts &&
                                            ~/.local/bin/taskgraph decision
                                            --pushlog-id='0'
                                            --pushdate='0'
                                            --project='${project}'
                                            --message=""
                                            --owner='${ownerEmail}'
                                            --level='${level}'
                                            --base-repository="$MOBILE_BASE_REPOSITORY"
                                            --head-repository="$MOBILE_HEAD_REPOSITORY"
                                            --head-ref="$MOBILE_HEAD_REF"
                                            --head-rev="$MOBILE_HEAD_REV"
                                            --head-tag="$MOBILE_HEAD_TAG"
                                            --repository-type="$MOBILE_REPOSITORY_TYPE"
                                            --tasks-for='${tasks_for}'
                                            ${extraArgs}
Johan Lorenzo's avatar
Johan Lorenzo committed
285

286
287
288
289
290
                              artifacts:
                                  'public':
                                      type: 'directory'
                                      path: '/builds/worker/artifacts'
                                      expires: {$fromNow: '1 year'}
Tom Prince's avatar
Tom Prince committed
291
292
293
294
295
296
297
298
                                  'public/docker-contexts':
                                      type: 'directory'
                                      path: '/builds/worker/checkouts/src/docker-contexts'
                                      # This needs to be at least the deadline of the
                                      # decision task + the docker-image task deadlines.
                                      # It is set to a week to allow for some time for
                                      # debugging, but they are not useful long-term.
                                      expires: {$fromNow: '7 day'}
Johan Lorenzo's avatar
Johan Lorenzo committed
299

300
301
302
303
304
305
306
                          extra:
                              $merge:
                                  - treeherder:
                                        $merge:
                                            - machine:
                                                  platform: gecko-decision
                                            - $if: 'tasks_for in ["github-push", "github-pull-request"]'
Johan Lorenzo's avatar
Johan Lorenzo committed
307
                                              then:
308
                                                  symbol: D
Johan Lorenzo's avatar
Johan Lorenzo committed
309
                                              else:
310
                                                  $if: 'tasks_for == "github-release"'
311
                                                  then:
312
                                                      symbol: 'ship_fenix'
313
                                                  else:
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
                                                      $if: 'tasks_for == "action"'
                                                      then:
                                                          groupName: 'action-callback'
                                                          groupSymbol: AC
                                                          symbol: "${action.symbol}"
                                                      else:
                                                          groupSymbol: cron
                                                          symbol: "${cron.job_symbol}"
                                  - $if: 'tasks_for == "action"'
                                    then:
                                        parent: '${action.taskGroupId}'
                                        action:
                                            name: '${action.name}'
                                            context:
                                                taskGroupId: '${action.taskGroupId}'
                                                taskId: {$eval: 'taskId'}
                                                input: {$eval: 'input'}
331
                                                clientId: {$eval: 'clientId'}
332
333
334
335
                                  - $if: 'tasks_for == "cron"'
                                    then:
                                        cron: {$json: {$eval: 'cron'}}
                                  - tasks_for: '${tasks_for}'