|
| 1 | +# yamllint disable rule:line-length |
| 2 | +# This file is rendered via JSON-e by |
| 3 | +# - github events - https://github.com/taskcluster/taskcluster/tree/main/services/github |
| 4 | +# - cron tasks - https://hg.mozilla.org/ci/ci-admin/file/default/build-decision/ |
| 5 | +# - action tasks - taskcluster/taskgraph/actions/registry.py |
| 6 | +--- |
| 7 | +version: 1 |
| 8 | +reporting: checks-v1 |
| 9 | +autoCancelPreviousChecks: true |
| 10 | +policy: |
| 11 | + pullRequests: public |
| 12 | +tasks: |
| 13 | + - $let: |
| 14 | + trustDomain: "mozilla" |
| 15 | + ownerEmail: |
| 16 | + $switch: |
| 17 | + 'tasks_for == "github-push"': '${event.pusher.email}' |
| 18 | + 'tasks_for == "github-release"': '${event.sender.login}@users.noreply.github.com' |
| 19 | + 'tasks_for[:19] == "github-pull-request"': '${event.pull_request.user.login}@users.noreply.github.com' |
| 20 | + 'tasks_for in ["cron", "action", "pr-action"]': '${tasks_for}@noreply.mozilla.org' |
| 21 | + baseRepoUrl: |
| 22 | + $switch: |
| 23 | + 'tasks_for[:19] == "github-pull-request"': '${event.pull_request.base.repo.html_url}' |
| 24 | + 'tasks_for in ["cron", "action"]': '${repository.url}' |
| 25 | + 'tasks_for == "pr-action"': '${repository.base_url}' |
| 26 | + $default: '${event.repository.html_url}' |
| 27 | + repoUrl: |
| 28 | + $switch: |
| 29 | + 'tasks_for[:19] == "github-pull-request"': '${event.pull_request.head.repo.html_url}' |
| 30 | + 'tasks_for in ["cron", "action", "pr-action"]': '${repository.url}' |
| 31 | + $default: '${event.repository.html_url}' |
| 32 | + project: |
| 33 | + $switch: |
| 34 | + 'tasks_for in ["github-push", "github-release"]': '${event.repository.name}' |
| 35 | + 'tasks_for[:19] == "github-pull-request"': '${event.pull_request.base.repo.name}' |
| 36 | + 'tasks_for in ["cron", "action", "pr-action"]': '${repository.project}' |
| 37 | + head_branch: |
| 38 | + $switch: |
| 39 | + 'tasks_for[:19] == "github-pull-request"': ${event.pull_request.head.ref} |
| 40 | + 'tasks_for == "github-push"': ${event.ref} |
| 41 | + 'tasks_for == "github-release"': '${event.release.target_commitish}' |
| 42 | + 'tasks_for in ["cron", "action", "pr-action"]': '${push.branch}' |
| 43 | + base_ref: |
| 44 | + $switch: |
| 45 | + 'tasks_for[:19] == "github-pull-request"': ${event.pull_request.base.ref} |
| 46 | + 'tasks_for == "github-push" && event.base_ref': ${event.base_ref} |
| 47 | + 'tasks_for == "github-push" && !(event.base_ref)': ${event.ref} |
| 48 | + 'tasks_for == "github-release"': '' |
| 49 | + 'tasks_for in ["cron", "action"]': '${push.branch}' |
| 50 | + 'tasks_for == "pr-action"': '${push.base_branch}' |
| 51 | + head_ref: |
| 52 | + $switch: |
| 53 | + 'tasks_for[:19] == "github-pull-request"': ${event.pull_request.head.ref} |
| 54 | + 'tasks_for == "github-push"': ${event.ref} |
| 55 | + 'tasks_for == "github-release"': ${event.release.tag_name} |
| 56 | + 'tasks_for in ["cron", "action", "pr-action"]': '${push.branch}' |
| 57 | + base_sha: |
| 58 | + $switch: |
| 59 | + 'tasks_for == "github-push"': '${event.before}' |
| 60 | + 'tasks_for == "github-release"': '${event.release.target_commitish}' |
| 61 | + 'tasks_for[:19] == "github-pull-request"': '${event.pull_request.base.sha}' |
| 62 | + 'tasks_for in ["cron", "action", "pr-action"]': '${push.revision}' |
| 63 | + head_sha: |
| 64 | + $switch: |
| 65 | + 'tasks_for == "github-push"': '${event.after}' |
| 66 | + 'tasks_for == "github-release"': '${event.release.tag_name}' |
| 67 | + 'tasks_for[:19] == "github-pull-request"': '${event.pull_request.head.sha}' |
| 68 | + 'tasks_for in ["cron", "action", "pr-action"]': '${push.revision}' |
| 69 | + ownTaskId: |
| 70 | + $switch: |
| 71 | + '"github" in tasks_for': {$eval: as_slugid("decision_task")} |
| 72 | + 'tasks_for in ["cron", "action", "pr-action"]': '${ownTaskId}' |
| 73 | + pullRequestAction: |
| 74 | + $switch: |
| 75 | + 'tasks_for[:19] == "github-pull-request"': ${event.action} |
| 76 | + $default: 'UNDEFINED' |
| 77 | + releaseAction: |
| 78 | + $if: 'tasks_for == "github-release"' |
| 79 | + then: ${event.action} |
| 80 | + else: 'UNDEFINED' |
| 81 | + isPullRequest: |
| 82 | + $eval: 'tasks_for[:19] == "github-pull-request"' |
| 83 | + in: |
| 84 | + $let: |
| 85 | + short_base_ref: |
| 86 | + $switch: |
| 87 | + 'base_ref[:10] == "refs/tags/"': '${base_ref[10:]}' |
| 88 | + 'base_ref[:11] == "refs/heads/"': '${base_ref[11:]}' |
| 89 | + $default: '${base_ref}' |
| 90 | + short_head_ref: |
| 91 | + $switch: |
| 92 | + 'head_ref[:10] == "refs/tags/"': '${head_ref[10:]}' |
| 93 | + 'head_ref[:11] == "refs/heads/"': '${head_ref[11:]}' |
| 94 | + $default: '${head_ref}' |
| 95 | + level: |
| 96 | + $if: 'isPullRequest || tasks_for == "pr-action"' |
| 97 | + then: "1" |
| 98 | + else: "1" |
| 99 | + in: |
| 100 | + $if: > |
| 101 | + tasks_for in ["action", "pr-action", "cron"] |
| 102 | + || (tasks_for == "github-push" && short_head_ref == "main") |
| 103 | + || (isPullRequest && pullRequestAction in ["opened", "reopened", "synchronize"]) |
| 104 | + then: |
| 105 | + taskId: {$if: 'tasks_for != "action" && tasks_for != "pr-action"', then: '${ownTaskId}'} |
| 106 | + taskGroupId: |
| 107 | + $if: 'tasks_for in ["action", "pr-action"]' |
| 108 | + then: |
| 109 | + '${action.taskGroupId}' |
| 110 | + else: |
| 111 | + '${ownTaskId}' # same as taskId; this is how automation identifies a decision task |
| 112 | + schedulerId: '${trustDomain}-level-${level}' |
| 113 | + created: {$fromNow: ''} |
| 114 | + deadline: {$fromNow: '1 day'} |
| 115 | + expires: {$fromNow: '1 year 1 second'} # 1 second so artifacts expire first |
| 116 | + metadata: |
| 117 | + $merge: |
| 118 | + - owner: "${ownerEmail}" |
| 119 | + source: "${repoUrl}/raw/${head_sha}/.taskcluster.yml" |
| 120 | + - $switch: |
| 121 | + 'tasks_for == "github-push" || isPullRequest': |
| 122 | + name: "Decision Task" |
| 123 | + description: 'The task that creates all of the other tasks in the task graph' |
| 124 | + 'tasks_for == "action"': |
| 125 | + name: "Action: ${action.title}" |
| 126 | + description: | |
| 127 | + ${action.description} |
| 128 | +
|
| 129 | + Action triggered by clientID `${clientId}` |
| 130 | + 'tasks_for == "pr-action"': |
| 131 | + name: "PR action: ${action.title}" |
| 132 | + description: | |
| 133 | + ${action.description} |
| 134 | +
|
| 135 | + PR action triggered by clientID `${clientId}` |
| 136 | + $default: |
| 137 | + name: "Decision Task for cron job ${cron.job_name}" |
| 138 | + description: 'Created by a [cron task](https://firefox-ci-tc.services.mozilla.com/tasks/${cron.task_id})' |
| 139 | + |
| 140 | + provisionerId: "${trustDomain}-${level}" |
| 141 | + workerType: "decision-gcp" |
| 142 | + |
| 143 | + tags: |
| 144 | + $switch: |
| 145 | + 'tasks_for == "github-push" || isPullRequest': |
| 146 | + createdForUser: "${ownerEmail}" |
| 147 | + kind: decision-task |
| 148 | + 'tasks_for in ["action", "pr-action"]': |
| 149 | + createdForUser: '${ownerEmail}' |
| 150 | + kind: 'action-callback' |
| 151 | + 'tasks_for == "cron"': |
| 152 | + kind: cron-task |
| 153 | + |
| 154 | + routes: |
| 155 | + $flatten: |
| 156 | + - checks |
| 157 | + - $switch: |
| 158 | + 'tasks_for == "github-push"': |
| 159 | + - "index.${trustDomain}.v2.${project}.latest.taskgraph.decision" |
| 160 | + - "index.${trustDomain}.v2.${project}.revision.${head_sha}.taskgraph.decision" |
| 161 | + 'tasks_for == "action"': |
| 162 | + - "index.${trustDomain}.v2.${project}.revision.${head_sha}.taskgraph.actions.${ownTaskId}" |
| 163 | + 'tasks_for == "cron"': |
| 164 | + - "index.${trustDomain}.v2.${project}.latest.taskgraph.decision-${cron.job_name}" |
| 165 | + - "index.${trustDomain}.v2.${project}.revision.${head_sha}.taskgraph.decision-${cron.job_name}" |
| 166 | + # list each cron task on this revision, so actions can find them |
| 167 | + - 'index.${trustDomain}.v2.${project}.revision.${head_sha}.cron.${ownTaskId}' |
| 168 | + $default: [] |
| 169 | + |
| 170 | + scopes: |
| 171 | + $switch: |
| 172 | + 'tasks_for in ["github-push"]': |
| 173 | + - 'assume:repo:${repoUrl[8:]}:branch:${short_head_ref}' |
| 174 | + 'isPullRequest': |
| 175 | + - 'assume:repo:github.com/${event.pull_request.base.repo.full_name}:${tasks_for[7:]}' |
| 176 | + 'tasks_for == "action"': |
| 177 | + - 'assume:repo:${repoUrl[8:]}:action:${action.action_perm}' |
| 178 | + 'tasks_for == "pr-action"': |
| 179 | + - 'assume:repo:${repoUrl[8:]}:pr-action:${action.action_perm}' |
| 180 | + $default: |
| 181 | + - 'assume:repo:${repoUrl[8:]}:cron:${cron.job_name}' |
| 182 | + |
| 183 | + dependencies: [] |
| 184 | + requires: all-completed |
| 185 | + |
| 186 | + priority: |
| 187 | + $switch: |
| 188 | + 'tasks_for == "cron"': low |
| 189 | + 'tasks_for == "github-push"|| isPullRequest': very-low |
| 190 | + $default: lowest # tasks_for in ['action', 'pr-action'] |
| 191 | + retries: 5 |
| 192 | + |
| 193 | + payload: |
| 194 | + $let: |
| 195 | + normProject: |
| 196 | + $eval: 'join(split(project, "-"), "_")' |
| 197 | + normProjectUpper: |
| 198 | + $eval: 'uppercase(join(split(project, "-"), "_"))' |
| 199 | + in: |
| 200 | + env: |
| 201 | + # run-task uses these to check out the source; the inputs to |
| 202 | + # `taskgraph decision` are all on the command line. |
| 203 | + $merge: |
| 204 | + - ${normProjectUpper}_BASE_REPOSITORY: '${baseRepoUrl}' |
| 205 | + ${normProjectUpper}_BASE_REF: '${short_base_ref}' |
| 206 | + ${normProjectUpper}_BASE_REV: '${base_sha}' |
| 207 | + ${normProjectUpper}_HEAD_REPOSITORY: '${repoUrl}' |
| 208 | + ${normProjectUpper}_HEAD_REF: '${short_head_ref}' |
| 209 | + ${normProjectUpper}_HEAD_REV: '${head_sha}' |
| 210 | + ${normProjectUpper}_REPOSITORY_TYPE: git |
| 211 | + REPOSITORIES: |
| 212 | + $json: |
| 213 | + ${normProject}: ${normProject} |
| 214 | + - $if: 'isPullRequest' |
| 215 | + then: |
| 216 | + ${normProjectUpper}_PULL_REQUEST_NUMBER: '${event.pull_request.number}' |
| 217 | + - $if: 'tasks_for in ["action", "pr-action"]' |
| 218 | + then: |
| 219 | + ACTION_TASK_GROUP_ID: '${action.taskGroupId}' # taskGroupId of the target task |
| 220 | + ACTION_TASK_ID: {$json: {$eval: 'taskId'}} # taskId of the target task (JSON-encoded) |
| 221 | + ACTION_INPUT: {$json: {$eval: 'input'}} |
| 222 | + ACTION_CALLBACK: '${action.cb_name}' |
| 223 | + |
| 224 | + cache: |
| 225 | + "${trustDomain}-project-${project}-level-${level}-checkouts-sparse-v2": /builds/worker/checkouts |
| 226 | + |
| 227 | + features: |
| 228 | + taskclusterProxy: true |
| 229 | + |
| 230 | + image: mozillareleases/taskgraph:decision-v14.2.1 |
| 231 | + maxRunTime: 1800 |
| 232 | + |
| 233 | + command: |
| 234 | + - run-task |
| 235 | + - '--${normProject}-checkout=/builds/worker/checkouts/src' |
| 236 | + - '--' |
| 237 | + - bash |
| 238 | + - -cx |
| 239 | + - $let: |
| 240 | + extraArgs: {$if: 'tasks_for == "cron"', then: '${cron.quoted_args}', else: ''} |
| 241 | + in: |
| 242 | + $if: 'tasks_for in ["action", "pr-action"]' |
| 243 | + then: > |
| 244 | + cd /builds/worker/checkouts/src && |
| 245 | + ln -s /builds/worker/artifacts artifacts && |
| 246 | + taskgraph action-callback |
| 247 | + else: > |
| 248 | + cd /builds/worker/checkouts/src && |
| 249 | + ln -s /builds/worker/artifacts artifacts && |
| 250 | + taskgraph decision |
| 251 | + --pushlog-id='0' |
| 252 | + --pushdate='0' |
| 253 | + --project='${project}' |
| 254 | + --owner='${ownerEmail}' |
| 255 | + --level='${level}' |
| 256 | + --repository-type=git |
| 257 | + --tasks-for='${tasks_for}' |
| 258 | + --base-repository='${baseRepoUrl}' |
| 259 | + --base-ref='${base_ref}' |
| 260 | + --base-rev='${base_sha}' |
| 261 | + --head-repository='${repoUrl}' |
| 262 | + --head-ref='${head_ref}' |
| 263 | + --head-rev='${head_sha}' |
| 264 | + ${extraArgs} |
| 265 | +
|
| 266 | + artifacts: |
| 267 | + 'public': |
| 268 | + type: 'directory' |
| 269 | + path: '/builds/worker/artifacts' |
| 270 | + expires: {$fromNow: '1 year'} |
| 271 | + 'public/docker-contexts': |
| 272 | + type: 'directory' |
| 273 | + path: '/builds/worker/checkouts/src/docker-contexts' |
| 274 | + # This needs to be at least the deadline of the |
| 275 | + # decision task + the docker-image task deadlines. |
| 276 | + # It is set to a week to allow for some time for |
| 277 | + # debugging, but they are not useful long-term. |
| 278 | + expires: {$fromNow: '7 day'} |
| 279 | + |
| 280 | + extra: |
| 281 | + $merge: |
| 282 | + - $if: 'tasks_for in ["action", "pr-action"]' |
| 283 | + then: |
| 284 | + parent: '${action.taskGroupId}' |
| 285 | + action: |
| 286 | + name: '${action.name}' |
| 287 | + context: |
| 288 | + taskGroupId: '${action.taskGroupId}' |
| 289 | + taskId: {$eval: 'taskId'} |
| 290 | + input: {$eval: 'input'} |
| 291 | + clientId: {$eval: 'clientId'} |
| 292 | + - $if: 'tasks_for == "cron"' |
| 293 | + then: |
| 294 | + cron: {$json: {$eval: 'cron'}} |
| 295 | + - tasks_for: '${tasks_for}' |
0 commit comments