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 bb2da96
Showing 1 changed file with 40 additions and 37 deletions.
77 changes: 40 additions & 37 deletions .taskcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,74 +13,77 @@ 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'}
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: 'base_ref'}
in:
$if: >
tasks_for in ["action", "pr-action", "cron"]
Expand Down

1 comment on commit bb2da96

@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.