forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.taskcluster.yml
229 lines (212 loc) · 11.4 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
---
version: 1
reporting: checks-v1
policy:
pullRequests: public
autoCancelPreviousChecks: true
tasks:
- $let:
trustDomain: taskcluster
# We set some of these directly in tc because we don't have some mozilla-specific concepts
ownerEmail: [email protected]
level: 1
# Github events have this stuff in different places...
baseRepoUrl:
$if: 'tasks_for in ["github-push", "github-release"]'
then: '${event.repository.html_url}'
else:
$if: 'tasks_for[:19] == "github-pull-request"'
then: '${event.pull_request.base.repo.html_url}'
repoUrl:
$if: 'tasks_for in ["github-push", "github-release"]'
then: '${event.repository.html_url}'
else:
$if: 'tasks_for[:19] == "github-pull-request"'
then: '${event.pull_request.head.repo.html_url}'
project:
$if: 'tasks_for in ["github-push", "github-release"]'
then: '${event.repository.name}'
else:
$if: 'tasks_for[:19] == "github-pull-request"'
then: '${event.pull_request.head.repo.name}'
head_branch:
$if: 'tasks_for[:19] == "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}'
base_ref:
$if: 'tasks_for[:19] == "github-pull-request"'
then: ${event.pull_request.base.ref}
else:
# event.base_ref is barely documented[1]. Testing showed it's only
# defined when creating a new branch. It's null when pushing to an
# existing branch
#
# [1] https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push
$if: 'tasks_for == "github-push" && event.base_ref'
then:
$if: 'event.base_ref[:11] == "refs/heads/"'
then: {$eval: 'event.base_ref[11:]'}
else: ${event.base_ref}
else:
$if: 'tasks_for == "github-push"'
then:
$if: 'event.ref[:11] == "refs/heads/"'
then: {$eval: 'event.ref[11:]'}
else: ${event.ref}
else:
$if: 'tasks_for in ["cron", "action"]'
then:
$if: '${push.branch}[:11] == "refs/heads/"'
then: {$eval: 'push.branch[11:]'}
else: '${push.branch}'
head_ref:
$if: 'tasks_for[:19] == "github-pull-request"'
then: ${event.pull_request.head.ref}
else:
$if: 'tasks_for == "github-push"'
then: ${event.ref}
else:
$if: 'tasks_for in ["cron", "action"]'
then: '${push.branch}'
head_sha:
$if: 'tasks_for == "github-push"'
then: '${event.after}'
else:
$if: 'tasks_for[:19] == "github-pull-request"'
then: '${event.pull_request.head.sha}'
else:
$if: 'tasks_for == "github-release"'
then: '${event.release.tag_name}'
head_tag:
$if: 'tasks_for == "github-release"'
then: '${event.release.tag_name}'
else: ''
ownTaskId: {$eval: as_slugid("decision_task")}
pullRequestAction:
$if: 'tasks_for[:19] == "github-pull-request"'
then: ${event.action}
else: 'UNDEFINED'
isPullRequest:
$eval: 'tasks_for[:19] == "github-pull-request"'
in:
$if: >
(isPullRequest && pullRequestAction in ["opened", "reopened", "synchronize"])
|| (tasks_for == "github-push" && project == "taskcluster" && (event["ref"] == "refs/heads/master" || event["ref"] == "refs/heads/main"))
|| (tasks_for == "github-push" && project == "taskcluster" && event["ref"][:11] == "refs/tags/v")
|| (tasks_for == "github-push" && project == "staging-releases" && event["ref"][:27] == "refs/heads/staging-release/")
then:
schedulerId: taskcluster-level-${level}
taskId: '${ownTaskId}'
taskGroupId: '${ownTaskId}' # same as taskId; this is how automation identifies a decision task
created: {$fromNow: ''}
deadline: {$fromNow: '1 day'}
expires: {$fromNow: '1 year 1 second'} # 1 second so artifacts expire first, despite rounding errors
metadata:
owner: "${ownerEmail}"
source: '${repoUrl}/raw/${head_sha}/.taskcluster.yml'
name: Decision Task (${tasks_for})
description: Load, transform, optimize, and submit other tasks
provisionerId: proj-taskcluster
workerType: gw-ubuntu-24-04
scopes:
# `https://` is 8 characters so, ${repoUrl[8:]} is the repository without the protocol.
$if: 'tasks_for == "github-push" && event["ref"][:11] != "refs/tags/v"'
then:
$let:
short_head_branch:
$if: 'head_branch[:11] == "refs/heads/"'
then: {$eval: 'head_branch[11:]'}
else: ${head_branch}
in:
- 'assume:repo:${repoUrl[8:]}:branch:${short_head_branch}'
else:
$if: 'isPullRequest'
then:
- 'assume:repo:github.com/${event.pull_request.base.repo.full_name}:pull-request'
else:
$if: 'tasks_for == "github-push" && event["ref"][:11] == "refs/tags/v"'
then:
- 'assume:repo:${repoUrl[8:]}:tag:${head_branch[10:]}'
requires: all-completed
priority: highest
retries: 5
payload:
env:
# run-task uses these to check out the source; the inputs
# to `mach taskgraph decision` are all on the command line.
$if: 'isPullRequest'
then:
TASKCLUSTER_PULL_REQUEST_NUMBER: '${event.pull_request.number}'
features:
taskclusterProxy: true
maxRunTime: 600
# Note: This task is built server side without the context or tooling that
# exist in tree so we must hard code the hash of the mozillareleases/taskgraph-decision docker image
command:
- - bash
- "-cxe"
- |-
podman run --name taskcontainer --add-host=taskcluster:127.0.0.1 --net=host \
-e "REPOSITORIES={\"taskcluster\":\"taskcluster\"}" \
-e "RUN_ID=$${RUN_ID}" \
-e "TASKCLUSTER_BASE_REF=${base_ref}" \
-e "TASKCLUSTER_BASE_REPOSITORY=${baseRepoUrl}" \
-e "TASKCLUSTER_HEAD_REF=${head_ref}" \
-e "TASKCLUSTER_HEAD_REPOSITORY=${repoUrl}" \
-e "TASKCLUSTER_HEAD_REV=${head_sha}" \
-e "TASKCLUSTER_HEAD_TAG=${head_tag}" \
-e "TASKCLUSTER_PIP_REQUIREMENTS=taskcluster/requirements.txt" \
-e "TASKCLUSTER_PROXY_URL=$${TASKCLUSTER_PROXY_URL}" \
-e "TASKCLUSTER_PULL_REQUEST_NUMBER=$${TASKCLUSTER_PULL_REQUEST_NUMBER}" \
-e "TASKCLUSTER_REPOSITORY_TYPE=git" \
-e "TASKCLUSTER_ROOT_URL=$${TASKCLUSTER_ROOT_URL}" \
-e "TASKCLUSTER_WORKER_LOCATION=$${TASKCLUSTER_WORKER_LOCATION}" \
-e "TASK_ID=$${TASK_ID}" \
"mozillareleases/taskgraph:decision-c4ac262880970ca484105929e02dd12f00214d5f2603ab6ce4c0d17de5cd0280@sha256:2dd667994aa13fccdcdcede85c570a5eb4a5247e42875a9e95a135ef774ee469" \
run-task \
--taskcluster-checkout=/builds/worker/checkouts/src \
--task-cwd=/builds/worker/checkouts/src \
-- \
bash -cxe '
ln -s /builds/worker/artifacts artifacts
~/.local/bin/taskgraph decision \
--pushlog-id='\''0'\'' \
--pushdate='\''0'\'' \
--project='\''${project}'\'' \
--message="" \
--owner='\''${ownerEmail}'\'' \
--level='\''${level}'\'' \
--repository-type=git \
--target-tasks-method=taskcluster-branches \
--tasks-for='\''${tasks_for}'\'' \
--base-repository='\''${baseRepoUrl}'\'' \
--base-ref='\''${base_ref}'\'' \
--head-repository='\''${repoUrl}'\'' \
--head-ref='\''${head_ref}'\'' \
--head-rev='\''${head_sha}'\'' \
--head-tag='\''${head_tag}'\''
rm artifacts/actions.json # taskcluster is not using actions.json
'
exit_code=$?
podman cp 'taskcontainer:/builds/worker/artifacts' artifact0
podman cp 'taskcontainer:/builds/worker/checkouts/src/docker-contexts' artifact1
podman rm taskcontainer
exit "$${exit_code}"
artifacts:
- name: 'public'
type: 'directory'
path: 'artifact0'
expires: {$fromNow: '1 year'}
- name: 'public/docker-contexts'
type: 'directory'
path: 'artifact1'
# 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'}