Skip to content

Commit

Permalink
eval
Browse files Browse the repository at this point in the history
  • Loading branch information
bhearsum committed Nov 29, 2024
1 parent 9e8641b commit c2b4c0b
Showing 1 changed file with 50 additions and 46 deletions.
96 changes: 50 additions & 46 deletions .taskcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,74 +13,78 @@ tasks:
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'
'tasks_for in ["cron", "action", "pr-action"]': '${tasks_for}@noreply.mozilla.org'
'tasks_for == "github-push"': {$eval: 'event.pusher.email'}
'tasks_for[:19] == "github-pull-request"': {$eval: '{event.pull_request.user.login}@users.noreply.github.com'}

'tasks_for in ["cron", "action", "pr-action"]': {$eval: '{tasks_for}@noreply.mozilla.org'}
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}'
'tasks_for == "pr-action"': '${repository.base_url}'
'tasks_for == "github-push"': {$eval: 'event.repository.html_url'}
'tasks_for[:19] == "github-pull-request"': {$eval: 'event.pull_request.base.repo.html_url'}
'tasks_for in ["cron", "action"]': {$eval: 'repository.url'}
'tasks_for == "pr-action"': {$eval: 'repository.base_url'}
repoUrl:
$switch:
'tasks_for == "github-push"': '${event.repository.html_url}'
'tasks_for[:19] == "github-pull-request"': '${event.pull_request.head.repo.html_url}'
'tasks_for in ["cron", "action", "pr-action"]': '${repository.url}'
'tasks_for == "github-push"': {$eval: 'event.repository.html_url'}
'tasks_for[:19] == "github-pull-request"': {$eval: 'event.pull_request.head.repo.html_url'}
'tasks_for in ["cron", "action", "pr-action"]': {$eval: 'repository.url'}
project:
$switch:
'tasks_for == "github-push"': '${event.repository.name}'
'tasks_for[:19] == "github-pull-request"': '${event.pull_request.head.repo.name}'
'tasks_for in ["cron", "action", "pr-action"]': '${repository.project}'
'tasks_for == "github-push"': {$eval: 'event.repository.name'}
'tasks_for[:19] == "github-pull-request"': {$eval: 'event.pull_request.head.repo.name'}
'tasks_for in ["cron", "action", "pr-action"]': {$eval: 'repository.project'}
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}'
'tasks_for in ["action", "cron", "pr-action"]': '${push.branch}'
'tasks_for[:19] == "github-pull-request"': {$eval: 'event.pull_request.head.ref'}
'tasks_for == "github-push"': {$eval: 'event.ref'}
'tasks_for == "github-release"': {$eval: 'event.release.target_commitish'}
'tasks_for in ["action", "cron", "pr-action"]': {$eval: 'push.branch'}
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}'
'tasks_for == "pr-action"': '${push.base_branch}'
'tasks_for[:19] == "github-pull-request"': {$eval: 'event.pull_request.base.ref'}
'tasks_for == "github-push"':
$if: {$eval: 'event.base_ref'}
then: {$eval: 'event.base_ref'}
else: {$eval: 'event.ref'}
'tasks_for in ["cron", "action"]': {$eval: 'push.branch'}
'tasks_for == "pr-action"': {$eval: 'push.base_branch'}
$default: {$eval: 'tasks_for'}
head_ref:
$switch:
'tasks_for[:19] == "github-pull-request"': ${event.pull_request.head.ref}
'tasks_for == "github-push"': ${event.ref}
'tasks_for in ["cron", "action", "pr-action"]': '${push.branch}'
'tasks_for[:19] == "github-pull-request"': {$eval: 'event.pull_request.head.ref'}
'tasks_for == "github-push"': {$eval: 'event.ref'}
'tasks_for in ["cron", "action", "pr-action"]': {$eval: 'push.branch'}
base_sha:
$switch:
'tasks_for == "github-push"': '${event.before}'
'tasks_for[:19] == "github-pull-request"': '${event.pull_request.base.sha}'
'tasks_for in ["cron", "action", "pr-action"]': '${push.revision}'
'tasks_for == "github-push"': {$eval: 'event.before'}
'tasks_for[:19] == "github-pull-request"': {$eval: 'event.pull_request.base.sha'}
'tasks_for in ["cron", "action", "pr-action"]': {$eval: 'push.revision'}
head_sha:
$switch:
'tasks_for == "github-push"': '${event.after}'
'tasks_for[:19] == "github-pull-request"': '${event.pull_request.head.sha}'
'tasks_for in ["cron", "action", "pr-action"]': '${push.revision}'
'tasks_for == "github-push"': {$eval: 'event.after'}
'tasks_for[:19] == "github-pull-request"': {$eval: 'event.pull_request.head.sha'}
'tasks_for in ["cron", "action", "pr-action"]': {$eval: 'push.revision'}
ownTaskId:
$switch:
'"github" in tasks_for': {$eval: as_slugid("decision_task")}
'tasks_for in ["cron", "action"]': '${ownTaskId}'
'tasks_for in ["cron", "action"]': {$eval: 'ownTaskId'}
pullRequestAction:
$switch:
'tasks_for[:19] == "github-pull-request"': ${event.action}
'tasks_for[:19] == "github-pull-request"': {$eval: 'event.action'}
$default: 'UNDEFINED'
isPullRequest:
$eval: 'tasks_for[:19] == "github-pull-request"'
in:
$let:
short_base_ref:
$if: 'base_ref[:11] == "refs/heads/"'
$if: {$eval: 'base_ref[:11] == "refs/heads/"'}
then: {$eval: 'base_ref[11:]'}
else: ${base_ref}
else: {$eval: 'base_ref'}

short_head_ref:
$if: 'head_ref[:11] == "refs/heads/"'
$if: {$eval: 'head_ref[:11] == "refs/heads/"'}
then: {$eval: 'head_ref[11:]'}
else: ${head_ref}
else: {$eval: 'head_ref'}
in:
$if: >
tasks_for in ["action", "pr-action", "cron"]
Expand All @@ -97,7 +101,7 @@ tasks:
'${action.taskGroupId}'
else:
'${ownTaskId}' # same as taskId; this is how automation identifies a decision task
schedulerId: '${trustDomain}-level-${level}'
schedulerId: sched
created: {$fromNow: ''}
deadline: {$fromNow: '1 day'}
expires: {$fromNow: '1 year 1 second'} # 1 second so artifacts expire first
Expand All @@ -124,7 +128,7 @@ tasks:
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}"
provisionerId: prov
workerType: "decision-gcp"

tags:
Expand All @@ -146,15 +150,15 @@ tasks:
- 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"
- "index.trusty.v2.${project}.latest.taskgraph.decision"
- "index.trusty.v2.${project}.revision.${head_sha}.taskgraph.decision"
'tasks_for == "action"':
- "index.${trustDomain}.v2.${project}.revision.${head_sha}.taskgraph.actions.${ownTaskId}"
- "index.trusty.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}"
- "index.trusty.v2.${project}.latest.taskgraph.decision-${cron.job_name}"
- "index.trusty.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}'
- 'index.trusty.v2.${project}.revision.${head_sha}.cron.${ownTaskId}'
$default: []

scopes:
Expand Down Expand Up @@ -221,7 +225,7 @@ tasks:
ACTION_CALLBACK: '${action.cb_name}'

cache:
"${trustDomain}-level-${level}-checkouts-sparse-v2": /builds/worker/checkouts
"trusty-level-${level}-checkouts-sparse-v2": /builds/worker/checkouts

features:
taskclusterProxy: true
Expand Down

1 comment on commit c2b4c0b

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error!

TemplateError at template.tasks[0]["base_ref"]: $if can evaluate string expressions only

Please sign in to comment.