forked from mozilla-mobile/android-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.taskcluster.yml
258 lines (242 loc) · 10.5 KB
/
.taskcluster.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
version: 1
policy:
pullRequests: public
tasks:
$let:
decision_task_id: {$eval: as_slugid("decision_task")}
expires_in: {$fromNow: '1 year'}
user:
# GitHub adds "[bot]" to bot usernames and that doesn't validate as email.
$if: 'event.sender.login == "bors[bot]"'
then: bors
else: ${event.sender.login}
# We define the following variable at the very top, because they are used in the
# default definition
head_branch:
$if: 'tasks_for == "github-pull-request"'
then: ${event.pull_request.head.ref}
else:
$if: 'tasks_for == "github-push"'
then: ${event.ref}
else: ${event.release.target_commitish}
head_rev:
$if: 'tasks_for == "github-pull-request"'
then: ${event.pull_request.head.sha}
else:
$if: 'tasks_for == "github-push"'
then: ${event.after}
else: ${event.release.tag_name}
repository:
$if: 'tasks_for == "github-pull-request"'
then: ${event.pull_request.head.repo.html_url}
else: ${event.repository.html_url}
scheduler_id:
$if: 'tasks_for == "cron"'
then: focus-nightly-sched # TODO: Rename to mobile-nightly-sched
else: taskcluster-github
github_repository_full_name:
$if: 'tasks_for == "github-pull-request"'
then: ${event.pull_request.base.repo.full_name}
else: ${event.repository.full_name}
is_repo_trusted:
# Pull requests on main repository can't be trusted because anybody can open a PR on it, without a review
$if: 'tasks_for in ["github-push", "github-release", "cron"] && event.repository.html_url == "https://github.com/mozilla-mobile/android-components"'
then: true
else: false
decision_task:
$if: 'tasks_for == "github-pull-request"'
then: 'pr'
else:
$if: 'tasks_for == "github-push"'
then: 'push'
else: 'release'
in:
$let:
decision_worker_type:
$if: 'is_repo_trusted'
then: mobile-3-decision
else: mobile-1-decision
build_worker_type:
$if: 'is_repo_trusted'
then: mobile-3-b-andrcmp
else: mobile-1-b-andrcmp
# TODO: revisit once bug 1533314 is done to possibly infer better priorities
tasks_priority: highest
short_head_branch:
$if: 'head_branch[:10] == "refs/tags/"'
then: {$eval: 'head_branch[10:]'}
else:
$if: 'head_branch[:11] == "refs/heads/"'
then: {$eval: 'head_branch[11:]'}
else: ${head_branch}
assume_scope_prefix: assume:repo:github.com/${github_repository_full_name}
in:
$let:
default_task_definition:
taskId: ${decision_task_id}
taskGroupId: ${decision_task_id} # Must be explicit because of Chain of Trust
schedulerId: ${scheduler_id}
created: {$fromNow: ''}
deadline: {$fromNow: '2 hours'}
expires: ${expires_in}
provisionerId: aws-provisioner-v1
workerType: ${decision_worker_type}
priority: ${tasks_priority}
requires: all-completed # Must be explicit because of Chain of Trust
retries: 5
routes:
- statuses # Automatically added by taskcluster-github. It must be explicit because of Chain of Trust
payload:
maxRunTime: 600 # Decision should remain fast enough to schedule a handful of tasks
image: mozillamobile/android-components:1.19
command:
- /bin/bash
- --login
- -cx
# The rest of the command must be defined below
env:
TASK_ID: ${decision_task_id}
TASKS_PRIORITY: ${tasks_priority}
SCHEDULER_ID: ${scheduler_id}
BUILD_WORKER_TYPE: ${build_worker_type}
MOBILE_HEAD_REPOSITORY: ${repository}
MOBILE_HEAD_BRANCH: ${head_branch}
MOBILE_HEAD_REV: ${head_rev}
features:
taskclusterProxy: true
extra:
tasks_for: ${tasks_for}
metadata:
owner: ${user}@users.noreply.github.com
source: ${repository}/raw/${head_rev}/.taskcluster.yml
in:
$if: 'tasks_for in ["github-pull-request", "github-push"]'
then:
$let:
pr_or_push_parameters:
payload:
command:
- >-
git fetch ${repository} ${head_branch}
&& git config advice.detachedHead false
&& git checkout ${head_rev}
&& ./gradlew --no-daemon --version
&& python automation/taskcluster/decision_task.py ${decision_task}
in:
- $if: 'tasks_for == "github-pull-request" && event["action"] in ["opened", "reopened", "edited", "synchronize"]'
then:
$let:
pull_request_title: ${event.pull_request.title}
pull_request_number: ${event.pull_request.number}
pull_request_url: ${event.pull_request.html_url}
in:
$mergeDeep:
- {$eval: 'default_task_definition'}
- {$eval: 'pr_or_push_parameters'}
- scopes:
- ${assume_scope_prefix}:pull-request
payload:
env:
GITHUB_PULL_TITLE: ${pull_request_title}
metadata:
name: 'Android Components - Decision task (Pull Request #${pull_request_number})'
description: 'Building and testing Android components - triggered by [#${pull_request_number}](${pull_request_url})'
- $if: 'tasks_for == "github-push" && head_branch[:10] != "refs/tags/" && head_branch != "staging.tmp" && head_branch != "trying.tmp"'
then:
$mergeDeep:
- {$eval: 'default_task_definition'}
- {$eval: 'pr_or_push_parameters'}
- scopes:
- ${assume_scope_prefix}:branch:${short_head_branch}
metadata:
name: Android Components - Decision task
description: Schedules the build and test tasks for Android components.
else:
$if: 'tasks_for in ["github-release", "cron"]'
then:
$let:
command_staging_flag:
$if: 'is_repo_trusted'
then: ''
else: '--staging'
beetmover_worker_type:
$if: 'is_repo_trusted'
then: mobile-beetmover-v1
else: mobile-beetmover-dev
beetmover_bucket:
$if: 'tasks_for == "github-release"'
then:
$if: 'is_repo_trusted'
then: maven-production
else: maven-staging
else:
$if: 'is_repo_trusted'
then: maven-snapshot-production
else: maven-snapshot-staging
in:
$let:
nightly_or_release_definition:
payload:
env:
MOBILE_TRIGGERED_BY: ${user}
BEETMOVER_WORKER_TYPE: ${beetmover_worker_type}
features:
chainOfTrust: true
artifacts:
public/task-graph.json:
type: file
path: /build/android-components/task-graph.json
expires: ${expires_in}
public/actions.json:
type: file
path: /build/android-components/actions.json
expires: ${expires_in}
public/parameters.yml:
type: file
path: /build/android-components/parameters.yml
expires: ${expires_in}
in:
- $if: 'tasks_for == "github-release" && event["action"] == "published"'
then:
$mergeDeep:
- {$eval: 'default_task_definition'}
- {$eval: 'nightly_or_release_definition'}
- scopes:
- ${assume_scope_prefix}:release
payload:
command:
- >-
git fetch ${repository} --tags
&& git config advice.detachedHead false
&& git checkout ${event.release.tag_name}
&& ./gradlew --no-daemon --version
&& python automation/taskcluster/decision_task.py release
${command_staging_flag}
metadata:
name: Android Components - Decision task (${event.release.tag_name})
description: Build and publish release versions.
- $if: 'tasks_for == "cron"'
then:
$mergeDeep:
- {$eval: 'default_task_definition'}
- {$eval: 'nightly_or_release_definition'}
- scopes:
# XXX Replace with your own hook, if you perform staging releases
- assume:hook-id:project-mobile/android-components-snapshot-release
payload:
command:
- >-
git fetch ${repository} ${head_branch}
&& git config advice.detachedHead false
&& git checkout ${head_rev}
&& ./gradlew --no-daemon --version
&& python automation/taskcluster/decision_task.py release --snapshot
${command_staging_flag}
extra:
cron: {$json: {$eval: 'cron'}}
metadata:
name: Android Components - Decision task for Snapshot release
description: Schedules the snapshot release of Android components.