Import l10n.
[gecko.git] / mobile / android / focus-android / .taskcluster.yml
blobd432aaaf8f2e19bd9450c5ad7a932973d5062b20
1 version: 1
2 reporting: checks-v1
3 policy:
4   pullRequests: collaborators
5 tasks:
6     - $let:
7           trustDomain: mobile
9           # Github events have this stuff in different places...
10           ownerEmail:
11               $if: 'tasks_for in ["cron", "action"]'
12               then: '${tasks_for}@noreply.mozilla.org'
13               else:
14                   $if: 'tasks_for == "github-push"'
15                   then:
16                       $if: 'event.pusher.email'
17                       then: '${event.pusher.email}'
18                       else: '${event.pusher.name}@users.noreply.github.com'
19                   else:
20                       $if: 'tasks_for == "github-pull-request"'
21                       then: '${event.pull_request.user.login}@users.noreply.github.com'
22           baseRepoUrl:
23               $if: 'tasks_for in ["github-push", "github-release"]'
24               then: '${event.repository.html_url}'
25               else:
26                   $if: 'tasks_for == "github-pull-request"'
27                   then: '${event.pull_request.base.repo.html_url}'
28                   else:
29                       $if: 'tasks_for in ["cron", "action"]'
30                       then: '${repository.url}'
31           repoUrl:
32               $if: 'tasks_for in ["github-push", "github-release"]'
33               then: '${event.repository.html_url}'
34               else:
35                   $if: 'tasks_for == "github-pull-request"'
36                   then: '${event.pull_request.head.repo.html_url}'
37                   else:
38                       $if: 'tasks_for in ["cron", "action"]'
39                       then: '${repository.url}'
40           project:
41               $if: 'tasks_for in ["github-push", "github-release"]'
42               then: '${event.repository.name}'
43               else:
44                   $if: 'tasks_for == "github-pull-request"'
45                   then: '${event.pull_request.head.repo.name}'
46                   else:
47                       $if: 'tasks_for in ["cron", "action"]'
48                       then: '${repository.project}'
49           head_branch:
50               $if: 'tasks_for == "github-pull-request"'
51               then: ${event.pull_request.head.ref}
52               else:
53                   $if: 'tasks_for == "github-push"'
54                   then: ${event.ref}
55                   else:
56                       $if: 'tasks_for == "github-release"'
57                       then: '${event.release.target_commitish}'
58                       else:
59                           $if: 'tasks_for in ["action", "cron"]'
60                           then: '${push.branch}'
61           head_sha:
62               $if: 'tasks_for == "github-push"'
63               then: '${event.after}'
64               else:
65                   $if: 'tasks_for == "github-pull-request"'
66                   then: '${event.pull_request.head.sha}'
67                   else:
68                       $if: 'tasks_for == "github-release"'
69                       then: '${event.release.tag_name}'
70                       else:
71                           $if: 'tasks_for in ["action", "cron"]'
72                           then: '${push.revision}'
75           head_tag:
76               $if: 'tasks_for == "github-release"'
77               then: '${event.release.tag_name}'
78               else: ''
79           ownTaskId:
80               $if: '"github" in tasks_for'
81               then: {$eval: as_slugid("decision_task")}
82               else:
83                   $if: 'tasks_for in ["cron", "action"]'
84                   then: '${ownTaskId}'
85           pullRequestAction:
86               $if: 'tasks_for == "github-pull-request"'
87               then: ${event.action}
88               else: 'UNDEFINED'
89           releaseAction:
90               $if: 'tasks_for == "github-release"'
91               then: ${event.action}
92               else: 'UNDEFINED'
93       in:
94           $if: >
95               tasks_for in ["action", "cron"]
96               || (tasks_for == "github-pull-request" && pullRequestAction in ["opened", "reopened", "synchronize"])
97               || (tasks_for == "github-push" && head_branch[:10] != "refs/tags/") && (head_branch != "staging.tmp") && (head_branch != "trying.tmp")
98           then:
99                 $let:
100                     level:
101                         $if: 'tasks_for in ["github-push", "github-release", "action", "cron"] && repoUrl == "https://github.com/mozilla-mobile/focus-android"'
102                         then: '3'
103                         else: '1'
105                     short_head_branch:
106                         $if: 'head_branch[:11] == "refs/heads/"'
107                         then: {$eval: 'head_branch[11:]'}
108                 in:
109                   $mergeDeep:
110                       - $if: 'tasks_for != "action"'
111                         then:
112                             taskId: '${ownTaskId}'
113                       - taskGroupId:
114                             $if: 'tasks_for == "action"'
115                             then:
116                                 '${action.taskGroupId}'
117                             else:
118                                 '${ownTaskId}'  # same as taskId; this is how automation identifies a decision task
119                         schedulerId: '${trustDomain}-level-${level}'
120                         created: {$fromNow: ''}
121                         deadline: {$fromNow: '1 day'}
122                         expires: {$fromNow: '1 year 1 second'}  # 1 second so artifacts expire first, despite rounding errors
123                         metadata:
124                             $merge:
125                                 - owner: "${ownerEmail}"
126                                   source: '${repoUrl}/raw/${head_sha}/.taskcluster.yml'
127                                 - $if: 'tasks_for in ["github-push", "github-pull-request", "github-release"]'
128                                   then:
129                                       name: "Decision Task"
130                                       description: 'The task that creates all of the other tasks in the task graph'
131                                   else:
132                                       $if: 'tasks_for == "action"'
133                                       then:
134                                           name: "Action: ${action.title}"
135                                           description: |
136                                               ${action.description}
138                                               Action triggered by clientID `${clientId}`
139                                       else:
140                                           name: "Decision Task for cron job ${cron.job_name}"
141                                           description: 'Created by a [cron task](https://firefox-ci-tc.services.mozilla.com/tasks/${cron.task_id})'
142                         provisionerId: "mobile-${level}"
143                         workerType: "decision-gcp"
144                         tags:
145                             $if: 'tasks_for == "github-pull-request" && event["action"] in ["opened", "reopened", "synchronize"]'
146                             then:
147                                 kind: decision-task
148                             else:
149                                 $if: 'tasks_for == "action"'
150                                 then:
151                                     kind: 'action-callback'
152                                 else:
153                                     $if: 'tasks_for == "cron"'
154                                     then:
155                                         kind: cron-task
156                         routes:
157                             $flattenDeep:
158                                 - checks
159                                 - $if: 'level == "3" || repoUrl == "https://github.com/mozilla-releng/staging-focus-android"'
160                                   then:
161                                       - tc-treeherder.v2.${project}.${head_sha}
162                                       # TODO Bug 1601928: Make this scope fork-friendly once ${project} is better defined. This will enable
163                                       # staging release promotion on forks.
164                                       - $if: 'tasks_for == "github-push"'
165                                         then:
166                                             - index.mobile.v2.${project}.branch.${short_head_branch}.latest.taskgraph.decision
167                                             - index.mobile.v2.${project}.branch.${short_head_branch}.revision.${head_sha}.taskgraph.decision
168                                             - index.mobile.v2.${project}.revision.${head_sha}.taskgraph.decision
169                                       - $if: 'tasks_for == "cron"'
170                                         then:
171                                             # cron context provides ${head_branch} as a short one
172                                             - index.mobile.v2.${project}.branch.${head_branch}.latest.taskgraph.decision-${cron.job_name}
173                                             - index.mobile.v2.${project}.branch.${head_branch}.revision.${head_sha}.taskgraph.decision-${cron.job_name}
174                                             - index.mobile.v2.${project}.branch.${head_branch}.revision.${head_sha}.taskgraph.cron.${ownTaskId}
175                         scopes:
176                             $if: 'tasks_for == "github-push"'
177                             then:
178                                 # `https://` is 8 characters so, ${repoUrl[8:]} is the repository without the protocol.
179                                 - 'assume:repo:${repoUrl[8:]}:branch:${short_head_branch}'
180                             else:
181                                 $if: 'tasks_for == "github-pull-request"'
182                                 then:
183                                     - 'assume:repo:github.com/${event.pull_request.base.repo.full_name}:pull-request'
184                                 else:
185                                     $if: 'tasks_for == "github-release"'
186                                     then:
187                                         - 'assume:repo:${repoUrl[8:]}:release'
188                                     else:
189                                         $if: 'tasks_for == "action"'
190                                         then:
191                                             # when all actions are hooks, we can calculate this directly rather than using a variable
192                                             - '${action.repo_scope}'
193                                         else:
194                                             - 'assume:repo:${repoUrl[8:]}:cron:${cron.job_name}'
196                         requires: all-completed
197                         priority: lowest
198                         retries: 5
200                         payload:
201                             env:
202                                 # run-task uses these to check out the source; the inputs
203                                 # to `mach taskgraph decision` are all on the command line.
204                                 $merge:
205                                     - MOBILE_BASE_REPOSITORY: '${baseRepoUrl}'
206                                       MOBILE_HEAD_REPOSITORY: '${repoUrl}'
207                                       MOBILE_HEAD_REF: '${head_branch}'
208                                       MOBILE_HEAD_REV: '${head_sha}'
209                                       MOBILE_HEAD_TAG: '${head_tag}'
210                                       MOBILE_PIP_REQUIREMENTS: taskcluster/requirements.txt
211                                       MOBILE_REPOSITORY_TYPE: git
212                                       MOZ_AUTOMATION: "1"
213                                       REPOSITORIES: {$json: {mobile: "Focus-Android"}}
214                                       ANDROID_SDK_ROOT: /builds/worker/android-sdk
215                                     - $if: 'tasks_for in ["github-pull-request"]'
216                                       then:
217                                           MOBILE_PULL_REQUEST_NUMBER: '${event.pull_request.number}'
218                                     - $if: 'tasks_for == "action"'
219                                       then:
220                                           ACTION_TASK_GROUP_ID: '${action.taskGroupId}'  # taskGroupId of the target task
221                                           ACTION_TASK_ID: {$json: {$eval: 'taskId'}}  # taskId of the target task (JSON-encoded)
222                                           ACTION_INPUT: {$json: {$eval: 'input'}}
223                                           ACTION_CALLBACK: '${action.cb_name}'
224                                     - $if: 'tasks_for == "github-release"'
225                                       then:
226                                           MOBILE_HEAD_TAG: '${event.release.tag_name}'
227                             features:
228                                 taskclusterProxy: true
229                                 chainOfTrust: true
230                             # Note: This task is built server side without the context or tooling that
231                             # exist in tree so we must hard code the hash
232                             image:
233                                 mozillareleases/taskgraph:decision-mobile-625975b642c148be4c6f1d8ee5cedf7399f5d0dd33d275ff69d5934e3082d4a9@sha256:bfb26700182486e1c6c52701baea6f386fa39e5e25417423c27845933605ad43
235                             maxRunTime: 1800
237                             command:
238                                 - /usr/local/bin/run-task
239                                 - '--mobile-checkout=/builds/worker/checkouts/vcs'
240                                 - '--task-cwd=/builds/worker/checkouts/vcs'
241                                 - '--'
242                                 - bash
243                                 - -cx
244                                 - $let:
245                                       extraArgs: {$if: 'tasks_for == "cron"', then: '${cron.quoted_args}', else: ''}
246                                   in:
247                                       $if: 'tasks_for == "action"'
248                                       then: >
249                                           taskcluster/scripts/decision-install-sdk.sh &&
250                                           ln -s /builds/worker/artifacts artifacts &&
251                                           ~/.local/bin/taskgraph action-callback
252                                       else: >
253                                           taskcluster/scripts/decision-install-sdk.sh &&
254                                           ln -s /builds/worker/artifacts artifacts &&
255                                           ~/.local/bin/taskgraph decision
256                                           --pushlog-id='0'
257                                           --pushdate='0'
258                                           --project='${project}'
259                                           --message=""
260                                           --owner='${ownerEmail}'
261                                           --level='${level}'
262                                           --base-repository="$MOBILE_BASE_REPOSITORY"
263                                           --head-repository="$MOBILE_HEAD_REPOSITORY"
264                                           --head-ref="$MOBILE_HEAD_REF"
265                                           --head-rev="$MOBILE_HEAD_REV"
266                                           --head-tag="$MOBILE_HEAD_TAG"
267                                           --repository-type="$MOBILE_REPOSITORY_TYPE"
268                                           --tasks-for='${tasks_for}'
269                                           ${extraArgs}
271                             artifacts:
272                                 'public':
273                                     type: 'directory'
274                                     path: '/builds/worker/artifacts'
275                                     expires: {$fromNow: '1 year'}
276                                 'public/docker-contexts':
277                                     type: 'directory'
278                                     path: '/builds/worker/checkouts/vcs/docker-contexts'
279                                     # This needs to be at least the deadline of the
280                                     # decision task + the docker-image task deadlines.
281                                     # It is set to a week to allow for some time for
282                                     # debugging, but they are not useful long-term.
283                                     expires: {$fromNow: '7 day'}
285                         extra:
286                             $merge:
287                                 - treeherder:
288                                       $merge:
289                                           - machine:
290                                                 platform: gecko-decision
291                                           - $if: 'tasks_for in ["github-push", "github-pull-request"]'
292                                             then:
293                                                 symbol: D
294                                             else:
295                                                 $if: 'tasks_for == "github-release"'
296                                                 then:
297                                                     symbol: 'ship_focus_android'
298                                                 else:
299                                                     $if: 'tasks_for == "action"'
300                                                     then:
301                                                         groupName: 'action-callback'
302                                                         groupSymbol: AC
303                                                         symbol: "${action.symbol}"
304                                                     else:
305                                                         groupSymbol: cron
306                                                         symbol: "${cron.job_symbol}"
307                                 - $if: 'tasks_for == "action"'
308                                   then:
309                                       parent: '${action.taskGroupId}'
310                                       action:
311                                           name: '${action.name}'
312                                           context:
313                                               taskGroupId: '${action.taskGroupId}'
314                                               taskId: {$eval: 'taskId'}
315                                               input: {$eval: 'input'}
316                                               clientId: {$eval: 'clientId'}
317                                 - $if: 'tasks_for == "cron"'
318                                   then:
319                                       cron: {$json: {$eval: 'cron'}}
320                                 - tasks_for: '${tasks_for}'