|
| 1 | +--- |
| 2 | +version: 1 |
| 3 | +reporting: checks-v1 |
| 4 | +policy: |
| 5 | + pullRequests: collaborators |
| 6 | +tasks: |
| 7 | + - $let: |
| 8 | + # XXX Set to `true` for private repos |
| 9 | + privateRepo: false |
| 10 | + # XXX Use |
| 11 | + # `system` for system add-on, |
| 12 | + # `privileged` for AMO or self-hosted privileged add-on, |
| 13 | + # `mozillaonline-privileged` for Mozilla China add-on, |
| 14 | + # `normandy-privileged` for normandy add-on |
| 15 | + # to enable siging on push/PR. |
| 16 | + xpiSigningType: "privileged" |
| 17 | + # The below doesn't need changing on initial repo setup |
| 18 | + template: |
| 19 | + repo: https://github.com/mozilla-extensions/xpi-template |
| 20 | + branch: main |
| 21 | + trustDomain: xpi |
| 22 | + in: |
| 23 | + $if: > |
| 24 | + tasks_for in ["github-push", "action", "cron"] || (tasks_for == |
| 25 | + "github-pull-request" && event.action in ["opened", "reopened", |
| 26 | + "synchronize"]) |
| 27 | + then: |
| 28 | + $let: |
| 29 | + # Github events have this stuff in different places... |
| 30 | + ownerEmail: |
| 31 | + $if: 'tasks_for == "github-push"' |
| 32 | + then: "${event.pusher.email}" |
| 33 | + # Assume Pull Request |
| 34 | + else: |
| 35 | + $if: 'tasks_for == "github-pull-request"' |
| 36 | + then: "${event.pull_request.user.login}@users.noreply.github.com" |
| 37 | + else: |
| 38 | + $if: 'tasks_for in ["cron", "action"]' |
| 39 | + then: "${tasks_for}@noreply.mozilla.org" |
| 40 | + project: |
| 41 | + $if: 'tasks_for == "github-push"' |
| 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 in ["cron", "action"]' |
| 57 | + then: "${push.branch}" |
| 58 | + head_sha: |
| 59 | + $if: 'tasks_for == "github-push"' |
| 60 | + then: "${event.after}" |
| 61 | + else: |
| 62 | + $if: 'tasks_for == "github-pull-request"' |
| 63 | + then: "${event.pull_request.head.sha}" |
| 64 | + else: |
| 65 | + $if: 'tasks_for in ["cron", "action"]' |
| 66 | + then: "${push.revision}" |
| 67 | + ownTaskId: |
| 68 | + $if: '"github" in tasks_for' |
| 69 | + then: { $eval: as_slugid("decision_task") } |
| 70 | + else: |
| 71 | + $if: 'tasks_for in ["cron", "action"]' |
| 72 | + then: "${ownTaskId}" |
| 73 | + repoFullName: |
| 74 | + $if: 'tasks_for in "github-push"' |
| 75 | + then: "${event.repository.full_name}" |
| 76 | + else: |
| 77 | + $if: 'tasks_for == "github-pull-request"' |
| 78 | + then: "${event.pull_request.base.repo.full_name}" |
| 79 | + else: |
| 80 | + $if: 'tasks_for in ["cron", "action"]' |
| 81 | + # Trim https://github.com/ |
| 82 | + then: "${repository.url[19:]}" |
| 83 | + baseRepoUrl: |
| 84 | + $if: "!privateRepo" # public repo |
| 85 | + then: |
| 86 | + $if: 'tasks_for == "github-push"' |
| 87 | + then: "${event.repository.html_url}" |
| 88 | + else: |
| 89 | + $if: 'tasks_for == "github-pull-request"' |
| 90 | + then: "${event.pull_request.base.repo.html_url}" |
| 91 | + else: |
| 92 | + $if: 'tasks_for in ["cron", "action"]' |
| 93 | + then: "${repository.url}" |
| 94 | + else: |
| 95 | + $if: 'tasks_for == "github-push"' |
| 96 | + then: "${event.repository.ssh_url}" |
| 97 | + else: |
| 98 | + $if: 'tasks_for == "github-pull-request"' |
| 99 | + then: "${event.pull_request.base.repo.ssh_url}" |
| 100 | + else: |
| 101 | + $if: 'tasks_for in ["cron", "action"]' |
| 102 | + then: "${repository.url}" |
| 103 | + repoUrl: |
| 104 | + $if: "!privateRepo" # public repo |
| 105 | + then: |
| 106 | + $if: 'tasks_for == "github-push"' |
| 107 | + then: "${event.repository.html_url}" |
| 108 | + else: |
| 109 | + $if: 'tasks_for == "github-pull-request"' |
| 110 | + then: "${event.pull_request.head.repo.html_url}" |
| 111 | + else: |
| 112 | + $if: 'tasks_for in ["cron", "action"]' |
| 113 | + then: "${repository.url}" |
| 114 | + else: |
| 115 | + $if: 'tasks_for == "github-push"' |
| 116 | + then: "${event.repository.ssh_url}" |
| 117 | + else: |
| 118 | + $if: 'tasks_for == "github-pull-request"' |
| 119 | + then: "${event.pull_request.base.repo.ssh_url}" |
| 120 | + else: |
| 121 | + $if: 'tasks_for in ["cron", "action"]' |
| 122 | + then: "${repository.url}" |
| 123 | + in: |
| 124 | + $let: |
| 125 | + level: 1 |
| 126 | + in: |
| 127 | + taskId: |
| 128 | + $if: 'tasks_for != "action"' |
| 129 | + then: "${ownTaskId}" |
| 130 | + taskGroupId: |
| 131 | + $if: 'tasks_for == "action"' |
| 132 | + then: "${action.taskGroupId}" |
| 133 | + else: "${ownTaskId}" # same as taskId; this is how automation identifies a decision task |
| 134 | + schedulerId: "${trustDomain}-level-${level}" |
| 135 | + created: { $fromNow: "" } |
| 136 | + deadline: { $fromNow: "1 day" } |
| 137 | + expires: { $fromNow: "1 year 1 second" } # 1 second so artifacts expire first, despite rounding errors |
| 138 | + metadata: |
| 139 | + $merge: |
| 140 | + - owner: "${ownerEmail}" |
| 141 | + - $if: "!privateRepo" # public repo |
| 142 | + then: |
| 143 | + source: "${repoUrl}/raw/${head_sha}/.taskcluster.yml" |
| 144 | + else: |
| 145 | + source: "ssh://github.com/${repoUrl[15:-4]}/raw/${head_sha}/.taskcluster.yml" |
| 146 | + - $if: 'tasks_for in ["github-push", "github-pull-request"]' |
| 147 | + then: |
| 148 | + name: "Decision Task" |
| 149 | + description: |
| 150 | + "The task that creates all of the other tasks in the task |
| 151 | + graph" |
| 152 | + else: |
| 153 | + $if: 'tasks_for == "action"' |
| 154 | + then: |
| 155 | + name: "Action: ${action.title}" |
| 156 | + description: "${action.description}" |
| 157 | + else: |
| 158 | + name: "Decision Task for cron job ${cron.job_name}" |
| 159 | + description: |
| 160 | + "Created by a [cron |
| 161 | + task](https://tools.taskcluster.net/tasks/${cron.task_id})" |
| 162 | + provisionerId: "xpi-${level}" |
| 163 | + workerType: "decision-gcp" |
| 164 | + tags: |
| 165 | + $if: 'tasks_for in ["github-push", "github-pull-request"]' |
| 166 | + then: |
| 167 | + kind: decision-task |
| 168 | + else: |
| 169 | + $if: 'tasks_for == "action"' |
| 170 | + then: |
| 171 | + kind: "action-callback" |
| 172 | + else: |
| 173 | + $if: 'tasks_for == "cron"' |
| 174 | + then: |
| 175 | + kind: cron-task |
| 176 | + routes: |
| 177 | + $flatten: |
| 178 | + - checks |
| 179 | + - $if: 'tasks_for == "github-push"' |
| 180 | + then: |
| 181 | + - "index.${trustDomain}.v2.${project}.revision.${head_sha}.taskgraph.decision" |
| 182 | + else: [] |
| 183 | + scopes: |
| 184 | + $if: 'tasks_for == "github-push"' |
| 185 | + then: |
| 186 | + $let: |
| 187 | + short_head_branch: |
| 188 | + $if: 'head_branch[:10] == "refs/tags/"' |
| 189 | + then: { $eval: "head_branch[10:]" } |
| 190 | + else: |
| 191 | + $if: 'head_branch[:11] == "refs/heads/"' |
| 192 | + then: { $eval: "head_branch[11:]" } |
| 193 | + else: ${head_branch} |
| 194 | + in: |
| 195 | + - "assume:repo:github.com/${repoFullName}:branch:${short_head_branch}" |
| 196 | + |
| 197 | + else: |
| 198 | + $if: 'tasks_for == "github-pull-request"' |
| 199 | + then: |
| 200 | + - "assume:repo:github.com/${repoFullName}:pull-request" |
| 201 | + |
| 202 | + else: |
| 203 | + $if: 'tasks_for == "action"' |
| 204 | + then: |
| 205 | + # when all actions are hooks, we can calculate this directly rather than using a variable |
| 206 | + - "${action.repo_scope}" |
| 207 | + else: |
| 208 | + - "assume:repo:github.com/${repoFullName}:cron:${cron.job_name}" |
| 209 | + |
| 210 | + requires: all-completed |
| 211 | + priority: lowest |
| 212 | + retries: 5 |
| 213 | + |
| 214 | + payload: |
| 215 | + env: |
| 216 | + # run-task uses these to check out the source; the inputs |
| 217 | + # to `mach taskgraph decision` are all on the command line. |
| 218 | + $merge: |
| 219 | + - XPI_BASE_REPOSITORY: "${baseRepoUrl}" |
| 220 | + XPI_HEAD_REPOSITORY: "${repoUrl}" |
| 221 | + XPI_HEAD_REF: "${head_branch}" |
| 222 | + XPI_HEAD_REV: "${head_sha}" |
| 223 | + XPI_REPOSITORY_TYPE: git |
| 224 | + XPI_SIGNING_TYPE: "${xpiSigningType}" |
| 225 | + TEMPLATE_BASE_REPOSITORY: "${template.repo}" |
| 226 | + TEMPLATE_HEAD_REPOSITORY: "${template.repo}" |
| 227 | + TEMPLATE_HEAD_REV: "${template.branch}" |
| 228 | + TEMPLATE_HEAD_REF: "${template.branch}" |
| 229 | + TEMPLATE_PIP_REQUIREMENTS: taskcluster/requirements.txt |
| 230 | + TEMPLATE_REPOSITORY_TYPE: git |
| 231 | + REPOSITORIES: |
| 232 | + { |
| 233 | + $json: |
| 234 | + { xpi: "XPI Manifest", template: "XPI Template" }, |
| 235 | + } |
| 236 | + - $if: "privateRepo" |
| 237 | + then: |
| 238 | + XPI_SSH_SECRET_NAME: project/xpi/xpi-github-clone-ssh |
| 239 | + - $if: 'tasks_for in ["github-pull-request"]' |
| 240 | + then: |
| 241 | + XPI_PULL_REQUEST_NUMBER: "${event.pull_request.number}" |
| 242 | + - $if: 'tasks_for == "action"' |
| 243 | + then: |
| 244 | + ACTION_TASK_GROUP_ID: "${action.taskGroupId}" # taskGroupId of the target task |
| 245 | + ACTION_TASK_ID: { $json: { $eval: "taskId" } } # taskId of the target task (JSON-encoded) |
| 246 | + ACTION_INPUT: { $json: { $eval: "input" } } |
| 247 | + ACTION_CALLBACK: "${action.cb_name}" |
| 248 | + features: |
| 249 | + taskclusterProxy: true |
| 250 | + chainOfTrust: true |
| 251 | + # Note: This task is built server side without the context or tooling that |
| 252 | + # exist in tree so we must hard code the hash |
| 253 | + image: mozillareleases/taskgraph:run-task-v9.2.1@sha256:2b9aeb5dbe8b99cec63eec2ef377e823b54ec3f564d9b732f1333883d950dc74 |
| 254 | + |
| 255 | + maxRunTime: 1800 |
| 256 | + |
| 257 | + command: |
| 258 | + - /usr/local/bin/run-task |
| 259 | + - "--xpi-checkout=/builds/worker/checkouts/src" |
| 260 | + - "--template-checkout=/builds/worker/checkouts/template" |
| 261 | + - "--task-cwd=/builds/worker/checkouts/src" |
| 262 | + - "--" |
| 263 | + - bash |
| 264 | + - -cx |
| 265 | + - $let: |
| 266 | + extraArgs: |
| 267 | + { |
| 268 | + $if: 'tasks_for == "cron"', |
| 269 | + then: "${cron.quoted_args}", |
| 270 | + else: "", |
| 271 | + } |
| 272 | + in: |
| 273 | + $if: 'tasks_for == "action"' |
| 274 | + then: > |
| 275 | + cd /builds/worker/checkouts/src && rm -rf taskcluster && |
| 276 | + ln -s /builds/worker/checkouts/template/taskcluster |
| 277 | + taskcluster && ln -s /builds/worker/artifacts artifacts && |
| 278 | + ~/.local/bin/taskgraph action-callback |
| 279 | + else: > |
| 280 | + rm -rf taskcluster && ln -s |
| 281 | + /builds/worker/checkouts/template/taskcluster taskcluster |
| 282 | + && ln -s /builds/worker/artifacts artifacts && |
| 283 | + ~/.local/bin/taskgraph decision --pushlog-id='0' |
| 284 | + --pushdate='0' --project='${project}' --message="" |
| 285 | + --owner='${ownerEmail}' --level='${level}' |
| 286 | + --base-repository="$XPI_BASE_REPOSITORY" |
| 287 | + --head-repository="$XPI_HEAD_REPOSITORY" |
| 288 | + --head-ref="$XPI_HEAD_REF" --head-rev="$XPI_HEAD_REV" |
| 289 | + --repository-type="$XPI_REPOSITORY_TYPE" |
| 290 | + --tasks-for='${tasks_for}' ${extraArgs} |
| 291 | +
|
| 292 | + artifacts: |
| 293 | + "public": |
| 294 | + type: "directory" |
| 295 | + path: "/builds/worker/artifacts" |
| 296 | + expires: { $fromNow: "1 year" } |
| 297 | + |
| 298 | + extra: |
| 299 | + $merge: |
| 300 | + - $if: 'tasks_for == "action"' |
| 301 | + then: |
| 302 | + parent: "${action.taskGroupId}" |
| 303 | + action: |
| 304 | + name: "${action.name}" |
| 305 | + context: |
| 306 | + taskGroupId: "${action.taskGroupId}" |
| 307 | + taskId: { $eval: "taskId" } |
| 308 | + input: { $eval: "input" } |
| 309 | + - $if: 'tasks_for == "cron"' |
| 310 | + then: |
| 311 | + cron: { $json: { $eval: "cron" } } |
| 312 | + - tasks_for: "${tasks_for}" |
0 commit comments