You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

336 lines
20 KiB

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