Bug 1568466 - part 1: Make .taskcluster.yml support action hooks

fennec/nightly
Johan Lorenzo 5 years ago committed by Sebastian Kaspari
parent f85961d9a9
commit cb1cd1e4c7

@ -63,8 +63,11 @@ tasks:
$if: 'tasks_for == "github-release"' $if: 'tasks_for == "github-release"'
then: '${event.release.target_commitish}' then: '${event.release.target_commitish}'
else: else:
$if: 'tasks_for in ["cron", "action"]' $if: 'tasks_for == "cron"'
then: '${push.branch}' then: '${push.branch}'
else:
$if: 'tasks_for == "action"'
then: ${parameters.head_ref}
head_sha: head_sha:
$if: 'tasks_for == "github-push"' $if: 'tasks_for == "github-push"'
then: '${event.after}' then: '${event.after}'
@ -75,18 +78,21 @@ tasks:
$if: 'tasks_for == "github-release"' $if: 'tasks_for == "github-release"'
then: '${event.release.tag_name}' then: '${event.release.tag_name}'
else: else:
$if: 'tasks_for in ["cron", "action"]' $if: 'tasks_for == "cron"'
then: '${push.revision}' then: '${push.revision}'
else:
$if: 'tasks_for == "action"'
then: ${parameters.head_rev}
head_tag: head_tag:
$if: 'tasks_for == "github-release"' $if: 'tasks_for == "github-release"'
then: '${event.release.tag_name}' then: '${event.release.tag_name}'
else: '' else: ''
ownTaskId: ownTaskId:
$if: '"github" in tasks_for' $if: '"github" in tasks_for'
then: {$eval: as_slugid("decision_task")} then: {$eval: as_slugid("decision_task")}
else: else:
$if: 'tasks_for == "cron"' $if: 'tasks_for in ["cron", "action"]'
then: '${ownTaskId}' then: '${ownTaskId}'
releaseAction: releaseAction:
$if: 'tasks_for == "github-release"' $if: 'tasks_for == "github-release"'
@ -102,198 +108,213 @@ tasks:
$if: 'tasks_for in ["github-push", "github-release", "action", "cron"] && repoUrl == "https://github.com/mozilla-mobile/fenix"' $if: 'tasks_for in ["github-push", "github-release", "action", "cron"] && repoUrl == "https://github.com/mozilla-mobile/fenix"'
then: '3' then: '3'
else: '1' else: '1'
short_head_branch:
$if: 'head_branch[:11] == "refs/heads/"'
then: {$eval: 'head_branch[11:]'}
in: in:
taskId: '${ownTaskId}' $mergeDeep:
taskGroupId: - $if: 'tasks_for != "action"'
$if: 'tasks_for == "action"'
then: then:
'${action.taskGroupId}' taskId: '${ownTaskId}'
else: - taskGroupId:
'${ownTaskId}' # same as taskId; this is how automation identifies a decision task $if: 'tasks_for == "action"'
schedulerId: '${trustDomain}-level-${level}' then:
created: {$fromNow: ''} '${action.taskGroupId}'
deadline: {$fromNow: '1 day'} else:
expires: {$fromNow: '1 year 1 second'} # 1 second so artifacts expire first, despite rounding errors '${ownTaskId}' # same as taskId; this is how automation identifies a decision task
metadata: schedulerId: '${trustDomain}-level-${level}'
$merge: created: {$fromNow: ''}
- owner: "${ownerEmail}" deadline: {$fromNow: '1 day'}
source: '${repoUrl}/raw/${head_sha}/.taskcluster.yml' expires: {$fromNow: '1 year 1 second'} # 1 second so artifacts expire first, despite rounding errors
- $if: 'tasks_for in ["github-push", "github-pull-request", "github-release"]' metadata:
then: $merge:
name: "Decision Task" - owner: "${ownerEmail}"
description: 'The task that creates all of the other tasks in the task graph' source: '${repoUrl}/raw/${head_sha}/.taskcluster.yml'
else: - $if: 'tasks_for in ["github-push", "github-pull-request", "github-release"]'
$if: 'tasks_for == "action"'
then: then:
name: "Action: ${action.title}" name: "Decision Task"
description: '${action.description}' description: 'The task that creates all of the other tasks in the task graph'
else: else:
name: "Decision Task for cron job ${cron.job_name}" $if: 'tasks_for == "action"'
description: 'Created by a [cron task](https://firefox-ci-tc.services.mozilla.com/tasks/${cron.task_id})' then:
provisionerId: "mobile-${level}" name: "Action: ${action.title}"
workerType: "decision" description: '${action.description}'
tags: else:
$if: 'tasks_for in ["github-push", "github-pull-request"]' name: "Decision Task for cron job ${cron.job_name}"
then: description: 'Created by a [cron task](https://firefox-ci-tc.services.mozilla.com/tasks/${cron.task_id})'
kind: decision-task provisionerId: "mobile-${level}"
else: workerType: "decision"
$if: 'tasks_for == "action"' tags:
$if: 'tasks_for in ["github-push", "github-pull-request"]'
then: then:
kind: 'action-callback' kind: decision-task
else: else:
$if: 'tasks_for == "cron"' $if: 'tasks_for == "action"'
then: then:
kind: cron-task kind: 'action-callback'
routes: else:
$flatten: $if: 'tasks_for == "cron"'
- checks then:
- $if: 'level == "3"' kind: cron-task
then: routes:
- "tc-treeherder.v2.${project}.${head_sha}" $flattenDeep:
else: [] - checks
scopes: - $if: 'level == "3"'
# `https://` is 8 characters so, ${repoUrl[8:]} is the repository without the protocol. then:
$if: 'tasks_for == "github-push"' - tc-treeherder.v2.${project}.${head_sha}
then: # TODO Bug 1601928: Make this scope fork-friendly once ${project} is better defined. This will enable
$let: # staging release promotion on forks.
short_head_branch: - $if: 'tasks_for == "github-push"'
$if: 'head_branch[:11] == "refs/heads/"' then:
then: {$eval: 'head_branch[11:]'} - index.project.mobile.${project}.v2.branch.${short_head_branch}.latest.taskgraph.decision
else: ${head_branch} - index.project.mobile.${project}.v2.branch.${short_head_branch}.revision.${head_sha}.taskgraph.decision
in: - $if: 'tasks_for == "cron"'
- 'assume:repo:${repoUrl[8:]}:branch:${short_head_branch}' then:
else: - index.project.mobile.${project}.v2.branch.${short_head_branch}.latest.taskgraph.decision-${cron.job_name}
$if: 'tasks_for == "github-pull-request"' - index.project.mobile.${project}.v2.branch.${short_head_branch}.revision.${head_sha}.taskgraph.decision-${cron.job_name}
- index.project.mobile.${project}.v2.branch.${short_head_branch}.revision.${head_sha}.taskgraph.cron.${ownTaskId}
scopes:
$if: 'tasks_for == "github-push"'
then: then:
- 'assume:repo:github.com/${event.pull_request.base.repo.full_name}:pull-request' # `https://` is 8 characters so, ${repoUrl[8:]} is the repository without the protocol.
- 'assume:repo:${repoUrl[8:]}:branch:${short_head_branch}'
else: else:
$if: 'tasks_for == "github-release"' $if: 'tasks_for == "github-pull-request"'
then: then:
- 'assume:repo:${repoUrl[8:]}:release' - 'assume:repo:github.com/${event.pull_request.base.repo.full_name}:pull-request'
else: else:
$if: 'tasks_for == "action"' $if: 'tasks_for == "github-release"'
then: then:
# when all actions are hooks, we can calculate this directly rather than using a variable - 'assume:repo:${repoUrl[8:]}:release'
- '${action.repo_scope}'
else: else:
- 'assume:repo:${repoUrl[8:]}:cron:${cron.job_name}' $if: 'tasks_for == "action"'
then:
# when all actions are hooks, we can calculate this directly rather than using a variable
- '${action.repo_scope}'
else:
- 'assume:repo:${repoUrl[8:]}:cron:${cron.job_name}'
requires: all-completed requires: all-completed
priority: lowest priority: lowest
retries: 5 retries: 5
payload: payload:
env: env:
# run-task uses these to check out the source; the inputs # run-task uses these to check out the source; the inputs
# to `mach taskgraph decision` are all on the command line. # to `mach taskgraph decision` are all on the command line.
$merge: $merge:
- MOBILE_BASE_REPOSITORY: '${baseRepoUrl}' - MOBILE_BASE_REPOSITORY: '${baseRepoUrl}'
MOBILE_HEAD_REPOSITORY: '${repoUrl}' MOBILE_HEAD_REPOSITORY: '${repoUrl}'
MOBILE_HEAD_REF: '${head_branch}' MOBILE_HEAD_REF: '${head_branch}'
MOBILE_HEAD_REV: '${head_sha}' MOBILE_HEAD_REV: '${head_sha}'
MOBILE_HEAD_TAG: '${head_tag}' MOBILE_HEAD_TAG: '${head_tag}'
MOBILE_REPOSITORY_TYPE: git MOBILE_REPOSITORY_TYPE: git
TASKGRAPH_BASE_REPOSITORY: https://hg.mozilla.org/ci/taskgraph TASKGRAPH_BASE_REPOSITORY: https://hg.mozilla.org/ci/taskgraph
TASKGRAPH_HEAD_REPOSITORY: https://hg.mozilla.org/ci/${taskgraph.branch} TASKGRAPH_HEAD_REPOSITORY: https://hg.mozilla.org/ci/${taskgraph.branch}
TASKGRAPH_HEAD_REV: ${taskgraph.revision} TASKGRAPH_HEAD_REV: ${taskgraph.revision}
TASKGRAPH_REPOSITORY_TYPE: hg TASKGRAPH_REPOSITORY_TYPE: hg
REPOSITORIES: {$json: {mobile: "Fenix", taskgraph: "Taskgraph"}} REPOSITORIES: {$json: {mobile: "Fenix", taskgraph: "Taskgraph"}}
HG_STORE_PATH: /builds/worker/checkouts/hg-store HG_STORE_PATH: /builds/worker/checkouts/hg-store
ANDROID_SDK_ROOT: /builds/worker/android-sdk ANDROID_SDK_ROOT: /builds/worker/android-sdk
- $if: 'tasks_for in ["github-pull-request"]' - $if: 'tasks_for in ["github-pull-request"]'
then: then:
MOBILE_PULL_REQUEST_NUMBER: '${event.pull_request.number}' MOBILE_PULL_REQUEST_NUMBER: '${event.pull_request.number}'
- $if: 'tasks_for == "action"' - $if: 'tasks_for == "action"'
then: then:
ACTION_TASK_GROUP_ID: '${action.taskGroupId}' # taskGroupId of the target task 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_TASK_ID: {$json: {$eval: 'taskId'}} # taskId of the target task (JSON-encoded)
ACTION_INPUT: {$json: {$eval: 'input'}} ACTION_INPUT: {$json: {$eval: 'input'}}
ACTION_CALLBACK: '${action.cb_name}' ACTION_CALLBACK: '${action.cb_name}'
features: - $if: 'tasks_for == "github-release"'
taskclusterProxy: true then:
chainOfTrust: true MOBILE_HEAD_TAG: '${event.release.tag_name}'
# Note: This task is built server side without the context or tooling that features:
# exist in tree so we must hard code the hash taskclusterProxy: true
image: chainOfTrust: true
mozillareleases/taskgraph:decision-mobile-6020473b1a928d8df50e234a7ca2e81ade2220a4fb5fbe16b02477dd64a49728@sha256:98d226736b7d03907114bf37938002b90e8a37cbe3a297690e349f1ddddb1d7c # Note: This task is built server side without the context or tooling that
# exist in tree so we must hard code the hash
image:
mozillareleases/taskgraph:decision-mobile-6020473b1a928d8df50e234a7ca2e81ade2220a4fb5fbe16b02477dd64a49728@sha256:98d226736b7d03907114bf37938002b90e8a37cbe3a297690e349f1ddddb1d7c
maxRunTime: 1800 maxRunTime: 1800
command: command:
- /usr/local/bin/run-task - /usr/local/bin/run-task
- '--mobile-checkout=/builds/worker/checkouts/src' - '--mobile-checkout=/builds/worker/checkouts/src'
- '--taskgraph-checkout=/builds/worker/checkouts/taskgraph' - '--taskgraph-checkout=/builds/worker/checkouts/taskgraph'
- '--task-cwd=/builds/worker/checkouts/src' - '--task-cwd=/builds/worker/checkouts/src'
- '--' - '--'
- bash - bash
- -cx - -cx
- $let: - $let:
extraArgs: {$if: 'tasks_for == "cron"', then: '${cron.quoted_args}', else: ''} extraArgs: {$if: 'tasks_for == "cron"', then: '${cron.quoted_args}', else: ''}
in: in:
$if: 'tasks_for == "action"' $if: 'tasks_for == "action"'
then: > then: >
cd /builds/worker/checkouts/src && PIP_IGNORE_INSTALLED=0 pip install --user /builds/worker/checkouts/taskgraph &&
ln -s /builds/worker/artifacts artifacts && taskcluster/scripts/install-sdk.sh &&
taskgraph action-callback ln -s /builds/worker/artifacts artifacts &&
else: > ~/.local/bin/taskgraph action-callback
PIP_IGNORE_INSTALLED=0 pip install --user /builds/worker/checkouts/taskgraph && else: >
PIP_IGNORE_INSTALLED=0 pip install --user arrow taskcluster pyyaml && PIP_IGNORE_INSTALLED=0 pip install --user /builds/worker/checkouts/taskgraph &&
taskcluster/scripts/install-sdk.sh && PIP_IGNORE_INSTALLED=0 pip install --user arrow taskcluster pyyaml &&
ln -s /builds/worker/artifacts artifacts && taskcluster/scripts/install-sdk.sh &&
~/.local/bin/taskgraph decision ln -s /builds/worker/artifacts artifacts &&
--pushlog-id='0' ~/.local/bin/taskgraph decision
--pushdate='0' --pushlog-id='0'
--project='${project}' --pushdate='0'
--message="" --project='${project}'
--owner='${ownerEmail}' --message=""
--level='${level}' --owner='${ownerEmail}'
--base-repository="$MOBILE_BASE_REPOSITORY" --level='${level}'
--head-repository="$MOBILE_HEAD_REPOSITORY" --base-repository="$MOBILE_BASE_REPOSITORY"
--head-ref="$MOBILE_HEAD_REF" --head-repository="$MOBILE_HEAD_REPOSITORY"
--head-rev="$MOBILE_HEAD_REV" --head-ref="$MOBILE_HEAD_REF"
--head-tag="$MOBILE_HEAD_TAG" --head-rev="$MOBILE_HEAD_REV"
--repository-type="$MOBILE_REPOSITORY_TYPE" --head-tag="$MOBILE_HEAD_TAG"
--tasks-for='${tasks_for}' --repository-type="$MOBILE_REPOSITORY_TYPE"
${extraArgs} --tasks-for='${tasks_for}'
${extraArgs}
artifacts: artifacts:
'public': 'public':
type: 'directory' type: 'directory'
path: '/builds/worker/artifacts' path: '/builds/worker/artifacts'
expires: {$fromNow: '1 year'} expires: {$fromNow: '1 year'}
extra: extra:
$merge: $merge:
- treeherder: - treeherder:
$merge: $merge:
- machine: - machine:
platform: gecko-decision platform: gecko-decision
- $if: 'tasks_for in ["github-push", "github-pull-request"]' - $if: 'tasks_for in ["github-push", "github-pull-request"]'
then:
symbol: D
else:
$if: 'tasks_for == "github-release"'
then: then:
symbol: 'ship_fenix' symbol: D
else: else:
$if: 'tasks_for == "action"' $if: 'tasks_for == "github-release"'
then: then:
groupName: 'action-callback' symbol: 'ship_fenix'
groupSymbol: AC
symbol: "${action.symbol}"
else: else:
groupSymbol: cron $if: 'tasks_for == "action"'
symbol: "${cron.job_symbol}" then:
- $if: 'tasks_for == "action"' groupName: 'action-callback'
then: groupSymbol: AC
parent: '${action.taskGroupId}' symbol: "${action.symbol}"
action: else:
name: '${action.name}' groupSymbol: cron
context: symbol: "${cron.job_symbol}"
taskGroupId: '${action.taskGroupId}' - $if: 'tasks_for == "action"'
taskId: {$eval: 'taskId'} then:
input: {$eval: 'input'} parent: '${action.taskGroupId}'
- $if: 'tasks_for == "cron"' action:
then: name: '${action.name}'
cron: {$json: {$eval: 'cron'}} context:
- tasks_for: '${tasks_for}' taskGroupId: '${action.taskGroupId}'
taskId: {$eval: 'taskId'}
input: {$eval: 'input'}
- $if: 'tasks_for == "cron"'
then:
cron: {$json: {$eval: 'cron'}}
- tasks_for: '${tasks_for}'

Loading…
Cancel
Save