2023-03-22 22:40:44 +03:00
|
|
|
# yamllint disable rule:line-length
|
|
|
|
# This file is rendered via JSON-e by
|
|
|
|
# - github events - https://github.com/taskcluster/taskcluster/tree/main/services/github
|
|
|
|
# - cron tasks - https://hg.mozilla.org/ci/ci-admin/file/default/build-decision/
|
|
|
|
# - action tasks - taskcluster/taskgraph/actions/registry.py
|
|
|
|
---
|
|
|
|
version: 1
|
|
|
|
reporting: checks-v1
|
|
|
|
policy:
|
|
|
|
pullRequests: public
|
|
|
|
tasks:
|
|
|
|
- $let:
|
|
|
|
trustDomain: "translations"
|
|
|
|
ownerEmail:
|
|
|
|
$switch:
|
|
|
|
'tasks_for == "github-push"': '${event.pusher.email}'
|
|
|
|
'tasks_for[:19] == "github-pull-request"': '${event.pull_request.user.login}@users.noreply.github.com'
|
2024-02-15 03:09:54 +03:00
|
|
|
'tasks_for in ["cron", "action", "pr-action"]': '${tasks_for}@noreply.mozilla.org'
|
2023-03-22 22:40:44 +03:00
|
|
|
baseRepoUrl:
|
|
|
|
$switch:
|
|
|
|
'tasks_for == "github-push"': '${event.repository.html_url}'
|
|
|
|
'tasks_for[:19] == "github-pull-request"': '${event.pull_request.base.repo.html_url}'
|
|
|
|
'tasks_for in ["cron", "action"]': '${repository.url}'
|
2024-02-15 03:09:54 +03:00
|
|
|
'tasks_for == "pr-action"': '${repository.base_url}'
|
2023-03-22 22:40:44 +03:00
|
|
|
repoUrl:
|
|
|
|
$switch:
|
|
|
|
'tasks_for == "github-push"': '${event.repository.html_url}'
|
|
|
|
'tasks_for[:19] == "github-pull-request"': '${event.pull_request.head.repo.html_url}'
|
2024-02-15 03:09:54 +03:00
|
|
|
'tasks_for in ["cron", "action", "pr-action"]': '${repository.url}'
|
2023-03-22 22:40:44 +03:00
|
|
|
project:
|
|
|
|
$switch:
|
|
|
|
'tasks_for == "github-push"': '${event.repository.name}'
|
|
|
|
'tasks_for[:19] == "github-pull-request"': '${event.pull_request.head.repo.name}'
|
2024-02-15 03:09:54 +03:00
|
|
|
'tasks_for in ["cron", "action", "pr-action"]': '${repository.project}'
|
2023-03-22 22:40:44 +03:00
|
|
|
head_branch:
|
|
|
|
$switch:
|
|
|
|
'tasks_for[:19] == "github-pull-request"': ${event.pull_request.head.ref}
|
|
|
|
'tasks_for == "github-push"': ${event.ref}
|
|
|
|
'tasks_for == "github-release"': '${event.release.target_commitish}'
|
2024-02-15 03:09:54 +03:00
|
|
|
'tasks_for in ["action", "cron", "pr-action"]': '${push.branch}'
|
2023-12-01 21:04:36 +03:00
|
|
|
base_ref:
|
|
|
|
$switch:
|
|
|
|
'tasks_for[:19] == "github-pull-request"': ${event.pull_request.base.ref}
|
|
|
|
'tasks_for == "github-push" && event.base_ref': ${event.base_ref}
|
|
|
|
'tasks_for == "github-push"': ${event.ref}
|
|
|
|
'tasks_for in ["cron", "action"]': '${push.branch}'
|
2024-02-15 03:09:54 +03:00
|
|
|
'tasks_for == "pr-action"': '${push.base_branch}'
|
2023-03-22 22:40:44 +03:00
|
|
|
head_ref:
|
|
|
|
$switch:
|
|
|
|
'tasks_for[:19] == "github-pull-request"': ${event.pull_request.head.ref}
|
|
|
|
'tasks_for == "github-push"': ${event.ref}
|
2024-02-15 03:09:54 +03:00
|
|
|
'tasks_for in ["cron", "action", "pr-action"]': '${push.branch}'
|
2023-12-01 21:04:36 +03:00
|
|
|
base_sha:
|
|
|
|
$switch:
|
|
|
|
'tasks_for == "github-push"': '${event.before}'
|
|
|
|
'tasks_for[:19] == "github-pull-request"': '${event.pull_request.base.sha}'
|
2024-02-15 03:09:54 +03:00
|
|
|
'tasks_for in ["cron", "action", "pr-action"]': '${push.revision}'
|
2023-03-22 22:40:44 +03:00
|
|
|
head_sha:
|
|
|
|
$switch:
|
|
|
|
'tasks_for == "github-push"': '${event.after}'
|
|
|
|
'tasks_for[:19] == "github-pull-request"': '${event.pull_request.head.sha}'
|
2024-02-15 03:09:54 +03:00
|
|
|
'tasks_for in ["cron", "action", "pr-action"]': '${push.revision}'
|
2023-03-22 22:40:44 +03:00
|
|
|
ownTaskId:
|
|
|
|
$switch:
|
|
|
|
'"github" in tasks_for': {$eval: as_slugid("decision_task")}
|
|
|
|
'tasks_for in ["cron", "action"]': '${ownTaskId}'
|
|
|
|
pullRequestAction:
|
|
|
|
$switch:
|
|
|
|
'tasks_for[:19] == "github-pull-request"': ${event.action}
|
|
|
|
$default: 'UNDEFINED'
|
|
|
|
isPullRequest:
|
|
|
|
$eval: 'tasks_for[:19] == "github-pull-request"'
|
|
|
|
in:
|
2023-12-05 23:00:35 +03:00
|
|
|
$let:
|
|
|
|
short_base_ref:
|
|
|
|
$if: 'base_ref[:11] == "refs/heads/"'
|
|
|
|
then: {$eval: 'base_ref[11:]'}
|
|
|
|
else: ${base_ref}
|
2023-03-22 22:40:44 +03:00
|
|
|
|
2023-12-05 23:00:35 +03:00
|
|
|
short_head_ref:
|
|
|
|
$if: 'head_ref[:11] == "refs/heads/"'
|
|
|
|
then: {$eval: 'head_ref[11:]'}
|
|
|
|
else: ${head_ref}
|
|
|
|
in:
|
|
|
|
$if: >
|
2024-09-06 20:53:31 +03:00
|
|
|
tasks_for in ["action", "pr-action", "cron"]
|
|
|
|
|| (tasks_for == "github-push" && (head_branch == "refs/heads/main" || head_branch[:18] == "refs/heads/release" || head_branch[:14] == "refs/heads/dev"))
|
2023-12-05 23:00:35 +03:00
|
|
|
|| (isPullRequest && pullRequestAction in ["opened", "reopened", "synchronize"])
|
|
|
|
then:
|
|
|
|
$let:
|
|
|
|
level: 1
|
|
|
|
in:
|
2024-02-15 03:09:54 +03:00
|
|
|
taskId: {$if: 'tasks_for != "action" && tasks_for != "pr-action"', then: '${ownTaskId}'}
|
2023-12-05 23:00:35 +03:00
|
|
|
taskGroupId:
|
2024-02-15 03:09:54 +03:00
|
|
|
$if: 'tasks_for in ["action", "pr-action"]'
|
2023-12-05 23:00:35 +03:00
|
|
|
then:
|
|
|
|
'${action.taskGroupId}'
|
|
|
|
else:
|
|
|
|
'${ownTaskId}' # same as taskId; this is how automation identifies a decision task
|
|
|
|
schedulerId: '${trustDomain}-level-${level}'
|
|
|
|
created: {$fromNow: ''}
|
|
|
|
deadline: {$fromNow: '1 day'}
|
|
|
|
expires: {$fromNow: '1 year 1 second'} # 1 second so artifacts expire first
|
|
|
|
metadata:
|
|
|
|
$merge:
|
|
|
|
- owner: "${ownerEmail}"
|
|
|
|
source: "${repoUrl}/raw/${head_sha}/.taskcluster.yml"
|
|
|
|
- $switch:
|
|
|
|
'tasks_for == "github-push" || isPullRequest':
|
|
|
|
name: "Decision Task (${tasks_for[7:]})" # strip out "github-" from tasks_for
|
|
|
|
description: 'The task that creates all of the other tasks in the task graph'
|
|
|
|
'tasks_for == "action"':
|
|
|
|
name: "Action: ${action.title}"
|
|
|
|
description: |
|
|
|
|
${action.description}
|
|
|
|
|
|
|
|
Action triggered by clientID `${clientId}`
|
2024-02-15 03:09:54 +03:00
|
|
|
'tasks_for == "pr-action"':
|
|
|
|
name: "PR action: ${action.title}"
|
|
|
|
description: |
|
|
|
|
${action.description}
|
|
|
|
PR action triggered by clientID `${clientId}`
|
2023-12-05 23:00:35 +03:00
|
|
|
$default:
|
|
|
|
name: "Decision Task for cron job ${cron.job_name}"
|
|
|
|
description: 'Created by a [cron task](https://firefox-ci-tc.services.mozilla.com/tasks/${cron.task_id})'
|
|
|
|
|
|
|
|
provisionerId: "${trustDomain}-${level}"
|
|
|
|
workerType: "decision-gcp"
|
|
|
|
|
|
|
|
tags:
|
|
|
|
$switch:
|
|
|
|
'tasks_for == "github-push" || isPullRequest':
|
|
|
|
createdForUser: "${ownerEmail}"
|
|
|
|
kind: decision-task
|
2024-02-15 03:09:54 +03:00
|
|
|
'tasks_for in ["action", "pr-action"]':
|
2023-12-05 23:00:35 +03:00
|
|
|
createdForUser: '${ownerEmail}'
|
|
|
|
kind: 'action-callback'
|
|
|
|
'tasks_for == "cron"':
|
|
|
|
kind: cron-task
|
|
|
|
|
|
|
|
routes:
|
|
|
|
$flatten:
|
|
|
|
- checks
|
|
|
|
- $if: '!isPullRequest'
|
|
|
|
then:
|
|
|
|
- tc-treeherder.v2.${project}.${head_sha}
|
|
|
|
- $switch:
|
|
|
|
'tasks_for == "github-push"':
|
|
|
|
- "index.${trustDomain}.v2.${project}.latest.taskgraph.decision"
|
|
|
|
- "index.${trustDomain}.v2.${project}.revision.${head_sha}.taskgraph.decision"
|
|
|
|
'tasks_for == "action"':
|
|
|
|
- "index.${trustDomain}.v2.${project}.revision.${head_sha}.taskgraph.actions.${ownTaskId}"
|
|
|
|
'tasks_for == "cron"':
|
|
|
|
- "index.${trustDomain}.v2.${project}.latest.taskgraph.decision-${cron.job_name}"
|
|
|
|
- "index.${trustDomain}.v2.${project}.revision.${head_sha}.taskgraph.decision-${cron.job_name}"
|
|
|
|
# list each cron task on this revision, so actions can find them
|
|
|
|
- 'index.${trustDomain}.v2.${project}.revision.${head_sha}.cron.${ownTaskId}'
|
|
|
|
$default: []
|
|
|
|
|
|
|
|
scopes:
|
|
|
|
$switch:
|
|
|
|
'tasks_for in ["github-push"]':
|
|
|
|
$let:
|
|
|
|
short_head_ref:
|
|
|
|
$if: 'head_ref[:10] == "refs/tags/"'
|
|
|
|
then: {$eval: 'head_ref[10:]'}
|
|
|
|
else:
|
|
|
|
$if: 'head_ref[:11] == "refs/heads/"'
|
|
|
|
then: {$eval: 'head_ref[11:]'}
|
|
|
|
else: ${head_ref}
|
|
|
|
in:
|
|
|
|
- 'assume:repo:${repoUrl[8:]}:branch:${short_head_ref}'
|
|
|
|
'isPullRequest':
|
|
|
|
- 'assume:repo:github.com/${event.pull_request.base.repo.full_name}:${tasks_for[7:]}'
|
|
|
|
'tasks_for == "action"':
|
2024-02-15 19:13:22 +03:00
|
|
|
- 'assume:repo:${baseRepoUrl[8:]}:action:${action.action_perm}'
|
2024-02-15 03:09:54 +03:00
|
|
|
'tasks_for == "pr-action"':
|
2024-02-15 19:13:22 +03:00
|
|
|
- 'assume:repo:${baseRepoUrl[8:]}:pr-action:${action.action_perm}'
|
2023-12-05 23:00:35 +03:00
|
|
|
$default:
|
|
|
|
- 'assume:repo:${repoUrl[8:]}:cron:${cron.job_name}'
|
|
|
|
|
|
|
|
dependencies: []
|
|
|
|
requires: all-completed
|
|
|
|
|
|
|
|
priority:
|
|
|
|
$switch:
|
|
|
|
'tasks_for == "cron"': low
|
|
|
|
'tasks_for == "github-push"|| isPullRequest': very-low
|
2024-02-15 03:09:54 +03:00
|
|
|
$default: lowest # tasks_for in ['action', 'pr-action']
|
2023-12-05 23:00:35 +03:00
|
|
|
retries: 5
|
|
|
|
|
|
|
|
payload:
|
|
|
|
$let:
|
|
|
|
normProject:
|
|
|
|
$eval: 'join(split(project, "-"), "_")'
|
|
|
|
normProjectUpper:
|
|
|
|
$eval: 'uppercase(join(split(project, "-"), "_"))'
|
|
|
|
in:
|
|
|
|
env:
|
|
|
|
# run-task uses these to check out the source; the inputs to
|
|
|
|
# `taskgraph decision` are all on the command line.
|
|
|
|
$merge:
|
|
|
|
- ${normProjectUpper}_BASE_REPOSITORY: '${baseRepoUrl}'
|
|
|
|
${normProjectUpper}_BASE_REF: '${short_base_ref}'
|
|
|
|
${normProjectUpper}_BASE_REV: '${base_sha}'
|
|
|
|
${normProjectUpper}_HEAD_REPOSITORY: '${repoUrl}'
|
|
|
|
${normProjectUpper}_HEAD_REF: '${head_ref}'
|
|
|
|
${normProjectUpper}_HEAD_REV: '${head_sha}'
|
|
|
|
${normProjectUpper}_REPOSITORY_TYPE: git
|
|
|
|
REPOSITORIES:
|
|
|
|
$json:
|
|
|
|
${normProject}: ${normProject}
|
|
|
|
- $if: 'isPullRequest'
|
|
|
|
then:
|
|
|
|
${normProjectUpper}_PULL_REQUEST_NUMBER: '${event.pull_request.number}'
|
2024-02-15 03:09:54 +03:00
|
|
|
- $if: 'tasks_for in ["action", "pr-action"]'
|
2023-12-05 23:00:35 +03:00
|
|
|
then:
|
|
|
|
ACTION_TASK_GROUP_ID: '${action.taskGroupId}' # taskGroupId of the target task
|
|
|
|
ACTION_TASK_ID: {$json: {$eval: 'taskId'}} # taskId of the target task (JSON-encoded)
|
|
|
|
ACTION_INPUT: {$json: {$eval: 'input'}}
|
|
|
|
ACTION_CALLBACK: '${action.cb_name}'
|
|
|
|
|
|
|
|
cache:
|
|
|
|
"${trustDomain}-level-${level}-checkouts-sparse-v2": /builds/worker/checkouts
|
|
|
|
|
|
|
|
features:
|
|
|
|
taskclusterProxy: true
|
|
|
|
|
2024-09-06 16:56:06 +03:00
|
|
|
image: mozillareleases/taskgraph:decision-v11.0.0@sha256:8c57e30214c85625856479812e63212dc2873b1ffcd97467a7c93508cbb3075a
|
2023-12-05 23:00:35 +03:00
|
|
|
maxRunTime: 1800
|
2024-05-23 23:08:06 +03:00
|
|
|
onExitStatus:
|
|
|
|
retry:
|
|
|
|
# 128 happens when cloning this repository fails
|
|
|
|
- 128
|
2023-12-05 23:00:35 +03:00
|
|
|
|
|
|
|
command:
|
|
|
|
- run-task
|
|
|
|
- '--${normProject}-checkout=/builds/worker/checkouts/src'
|
|
|
|
- '--'
|
|
|
|
- bash
|
|
|
|
- -cx
|
|
|
|
- $let:
|
|
|
|
extraArgs: {$if: 'tasks_for == "cron"', then: '${cron.quoted_args}', else: ''}
|
|
|
|
in:
|
2024-02-15 03:09:54 +03:00
|
|
|
$if: 'tasks_for in ["action", "pr-action"]'
|
2023-12-05 23:00:35 +03:00
|
|
|
then: >
|
|
|
|
cd /builds/worker/checkouts/src &&
|
|
|
|
ln -s /builds/worker/artifacts artifacts &&
|
2024-03-28 17:02:13 +03:00
|
|
|
taskgraph action-callback
|
2023-12-05 23:00:35 +03:00
|
|
|
else: >
|
|
|
|
cd /builds/worker/checkouts/src &&
|
|
|
|
ln -s /builds/worker/artifacts artifacts &&
|
2024-03-28 17:02:13 +03:00
|
|
|
taskgraph decision
|
2023-12-05 23:00:35 +03:00
|
|
|
--pushlog-id='0'
|
|
|
|
--pushdate='0'
|
|
|
|
--project='${project}'
|
|
|
|
--owner='${ownerEmail}'
|
|
|
|
--level='${level}'
|
|
|
|
--repository-type=git
|
|
|
|
--tasks-for='${tasks_for}'
|
|
|
|
--base-repository='${baseRepoUrl}'
|
|
|
|
--base-ref='${short_base_ref}'
|
|
|
|
--base-rev='${base_sha}'
|
|
|
|
--head-repository='${repoUrl}'
|
|
|
|
--head-ref='${head_ref}'
|
|
|
|
--head-rev='${head_sha}'
|
|
|
|
${extraArgs}
|
|
|
|
|
|
|
|
artifacts:
|
|
|
|
'public':
|
|
|
|
type: 'directory'
|
|
|
|
path: '/builds/worker/artifacts'
|
|
|
|
expires: {$fromNow: '1 year'}
|
|
|
|
'public/docker-contexts':
|
|
|
|
type: 'directory'
|
|
|
|
path: '/builds/worker/checkouts/src/docker-contexts'
|
|
|
|
# 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'}
|
|
|
|
|
|
|
|
extra:
|
|
|
|
$merge:
|
|
|
|
- treeherder:
|
|
|
|
$merge:
|
|
|
|
- machine:
|
|
|
|
platform: gecko-decision
|
|
|
|
- $if: 'tasks_for == "github-push" || isPullRequest'
|
|
|
|
then:
|
|
|
|
symbol: D
|
|
|
|
else:
|
2024-02-15 03:09:54 +03:00
|
|
|
$if: 'tasks_for in ["action", "pr-action"]'
|
2023-12-05 23:00:35 +03:00
|
|
|
then:
|
|
|
|
groupName: 'action-callback'
|
|
|
|
groupSymbol: AC
|
|
|
|
symbol: "${action.symbol}"
|
|
|
|
else:
|
|
|
|
groupSymbol: cron
|
|
|
|
symbol: "${cron.job_symbol}"
|
2024-02-15 03:09:54 +03:00
|
|
|
- $if: 'tasks_for in ["action", "pr-action"]'
|
2023-12-05 23:00:35 +03:00
|
|
|
then:
|
|
|
|
parent: '${action.taskGroupId}'
|
|
|
|
action:
|
|
|
|
name: '${action.name}'
|
|
|
|
context:
|
|
|
|
taskGroupId: '${action.taskGroupId}'
|
|
|
|
taskId: {$eval: 'taskId'}
|
|
|
|
input: {$eval: 'input'}
|
|
|
|
clientId: {$eval: 'clientId'}
|
|
|
|
- $if: 'tasks_for == "cron"'
|
|
|
|
then:
|
|
|
|
cron: {$json: {$eval: 'cron'}}
|
|
|
|
- tasks_for: '${tasks_for}'
|