Blame .taskcluster.yml

Packit f0b94e
# This file is rendered via JSON-e by
Packit f0b94e
# - mozilla-taskcluster - See
Packit f0b94e
#   https://docs.taskcluster.net/reference/integrations/mozilla-taskcluster/docs/taskcluster-yml
Packit f0b94e
#   {
Packit f0b94e
#     tasks_for: 'hg-push',
Packit f0b94e
#     push: {owner, comment, pushlog_id, pushdate},
Packit f0b94e
#     repository: {url, project, level},
Packit f0b94e
#     now,
Packit f0b94e
#     as_slugid: // function
Packit f0b94e
#     ownTaskId: // taskId of the task that will be created
Packit f0b94e
#   }
Packit f0b94e
#
Packit f0b94e
# - cron tasks - See taskcluster/taskgraph/cron/decision.py
Packit f0b94e
#   {
Packit f0b94e
#     tasks_for: 'cron',
Packit f0b94e
#     push: {revision, pushlog_id, pushdate, owner}
Packit f0b94e
#     repository: {url, project, level},
Packit f0b94e
#     cron: {task_id, job_name, job_symbol, quoted_args},
Packit f0b94e
#     now,
Packit f0b94e
#     ownTaskId: // taskId of the task that will be created
Packit f0b94e
#   }
Packit f0b94e
#
Packit f0b94e
# - action tasks - See:
Packit f0b94e
#   * taskcluster/taskgraph/actions/registry.py,
Packit f0b94e
#   * https://docs.taskcluster.net/docs/manual/using/actions/spec
Packit f0b94e
#   * ci-admin:ciadmin/generate/in_tree_actions.py
Packit f0b94e
#
Packit f0b94e
#   The registry generates the hookPayload that appears in actions.json, and
Packit f0b94e
#   contains data from the decision task as well as JSON-e code to combine that
Packit f0b94e
#   with data supplied as part of the action spec.  When the hook is fired, the
Packit f0b94e
#   hookPayload is rendered with JSON-e to produce a payload for the hook task
Packit f0b94e
#   template.
Packit f0b94e
#
Packit f0b94e
#   The ci-admin code wraps the content of this file (.taskcluster.yml) with a
Packit f0b94e
#   JSON-e $let statement that produces the context described below, and
Packit f0b94e
#   installs that as the hook task template.
Packit f0b94e
#
Packit f0b94e
#   {
Packit f0b94e
#     tasks_for: 'action',
Packit f0b94e
#     push: {owner, pushlog_id, revision},
Packit f0b94e
#     repository: {url, project, level},
Packit f0b94e
#     input,
Packit f0b94e
#     parameters,
Packit f0b94e
#     taskId,      // targetted taskId
Packit f0b94e
#     taskGroupId, // targetted taskGroupId
Packit f0b94e
#     action: {name, title, description, taskGroupId, symbol, repo_scope, cb_name}
Packit f0b94e
#     ownTaskId:   // taskId of the task that will be created
Packit f0b94e
#   }
Packit f0b94e
Packit f0b94e
version: 1
Packit f0b94e
tasks:
Packit f0b94e
  # NOTE: support for actions in ci-admin requires that the `tasks` property be an array *before* JSON-e rendering
Packit f0b94e
  # takes place.
Packit f0b94e
  - $if: 'tasks_for in ["hg-push", "action", "cron"]'
Packit f0b94e
    then:
Packit f0b94e
      $let:
Packit f0b94e
        # sometimes the push user is just `ffxbld` or the like, but we want an email-like field..
Packit f0b94e
        ownerEmail: {$if: '"@" in push.owner', then: '${push.owner}', else: '${push.owner}@noreply.mozilla.org'}
Packit f0b94e
        # ensure there's no trailing `/` on the repo URL
Packit f0b94e
        repoUrl: {$if: 'repository.url[-1] == "/"', then: {$eval: 'repository.url[:-1]'}, else: {$eval: 'repository.url'}}
Packit f0b94e
      in:
Packit f0b94e
        taskId: {$if: 'tasks_for != "action"', then: '${ownTaskId}'}
Packit f0b94e
        taskGroupId:
Packit f0b94e
          $if: 'tasks_for == "action"'
Packit f0b94e
          then:
Packit f0b94e
            '${action.taskGroupId}'
Packit f0b94e
          else:
Packit f0b94e
            '${ownTaskId}' # same as taskId; this is how automation identifies a decision tsak
Packit f0b94e
        schedulerId: 'gecko-level-${repository.level}'
Packit f0b94e
Packit f0b94e
        created: {$fromNow: ''}
Packit f0b94e
        deadline: {$fromNow: '1 day'}
Packit f0b94e
        expires: {$fromNow: '1 year 1 second'} # 1 second so artifacts expire first, despite rounding errors
Packit f0b94e
        metadata:
Packit f0b94e
          $merge:
Packit f0b94e
            - owner: "${ownerEmail}"
Packit f0b94e
              source: "${repoUrl}/raw-file/${push.revision}/.taskcluster.yml"
Packit f0b94e
            - $if: 'tasks_for == "hg-push"'
Packit f0b94e
              then:
Packit f0b94e
                name: "Gecko Decision Task"
Packit f0b94e
                description: 'The task that creates all of the other tasks in the task graph'
Packit f0b94e
              else:
Packit f0b94e
                $if: 'tasks_for == "action"'
Packit f0b94e
                then:
Packit f0b94e
                  name: "Action: ${action.title}"
Packit f0b94e
                  description: '${action.description}'
Packit f0b94e
                else:
Packit f0b94e
                  name: "Decision Task for cron job ${cron.job_name}"
Packit f0b94e
                  description: 'Created by a [cron task](https://tools.taskcluster.net/tasks/${cron.task_id})'
Packit f0b94e
Packit f0b94e
        provisionerId: "aws-provisioner-v1"
Packit f0b94e
        workerType: "gecko-${repository.level}-decision"
Packit f0b94e
Packit f0b94e
        tags:
Packit f0b94e
          $if: 'tasks_for == "hg-push"'
Packit f0b94e
          then:
Packit f0b94e
            createdForUser: "${ownerEmail}"
Packit f0b94e
            kind: decision-task
Packit f0b94e
          else:
Packit f0b94e
            $if: 'tasks_for == "action"'
Packit f0b94e
            then:
Packit f0b94e
              createdForUser: '${ownerEmail}'
Packit f0b94e
              kind: 'action-callback'
Packit f0b94e
            else:
Packit f0b94e
              $if: 'tasks_for == "cron"'
Packit f0b94e
              then:
Packit f0b94e
                kind: cron-task
Packit f0b94e
Packit f0b94e
        routes:
Packit f0b94e
          $flatten:
Packit f0b94e
            - "tc-treeherder.v2.${repository.project}.${push.revision}.${push.pushlog_id}"
Packit f0b94e
            - $if: 'tasks_for == "hg-push"'
Packit f0b94e
              then:
Packit f0b94e
                - "index.gecko.v2.${repository.project}.latest.taskgraph.decision"
Packit f0b94e
                - "index.gecko.v2.${repository.project}.revision.${push.revision}.taskgraph.decision"
Packit f0b94e
                - "index.gecko.v2.${repository.project}.pushlog-id.${push.pushlog_id}.decision"
Packit f0b94e
                - "notify.email.${ownerEmail}.on-failed"
Packit f0b94e
                - "notify.email.${ownerEmail}.on-exception"
Packit f0b94e
                # Send a notification email if the push comes from try
Packit f0b94e
                - $if: 'repository.project == "try"'
Packit f0b94e
                  then:
Packit f0b94e
                    "notify.email.${ownerEmail}.on-completed"
Packit f0b94e
                # These are the old index routes for the decision task.
Packit f0b94e
                # They are still here so external tools that referenced them continue to work.
Packit f0b94e
                - "index.gecko.v2.${repository.project}.latest.firefox.decision"
Packit f0b94e
                - "index.gecko.v2.${repository.project}.revision.${push.revision}.firefox.decision"
Packit f0b94e
              else:
Packit f0b94e
                $if: 'tasks_for == "action"'
Packit f0b94e
                then:
Packit f0b94e
                - "notify.email.taskcluster-notifications+action-task@mozilla.com.on-failed"
Packit f0b94e
                - "notify.email.taskcluster-notifications+action-task@mozilla.com.on-exception"
Packit f0b94e
                - "index.gecko.v2.${repository.project}.pushlog-id.${push.pushlog_id}.actions.${ownTaskId}"
Packit f0b94e
                else:  # cron
Packit f0b94e
                - "index.gecko.v2.${repository.project}.latest.taskgraph.decision-${cron.job_name}"
Packit f0b94e
                - "index.gecko.v2.${repository.project}.revision.${push.revision}.taskgraph.decision-${cron.job_name}"
Packit f0b94e
                - "index.gecko.v2.${repository.project}.pushlog-id.${push.pushlog_id}.decision-${cron.job_name}"
Packit f0b94e
                # list each cron task on this revision, so actions can find them
Packit f0b94e
                - 'index.gecko.v2.${repository.project}.revision.${push.revision}.cron.${ownTaskId}'
Packit f0b94e
                # BUG 1500166 Notify ciduty by email if a nightly hook fails
Packit f0b94e
                - "notify.email.ciduty+failedcron@mozilla.com.on-failed"
Packit f0b94e
                - "notify.email.ciduty+exceptioncron@mozilla.com.on-exception"
Packit f0b94e
                - "notify.email.sheriffs+failedcron@mozilla.org.on-failed"
Packit f0b94e
                - "notify.email.sheriffs+exceptioncron@mozilla.org.on-exception"
Packit f0b94e
                # These are the old index routes for the decision task.
Packit f0b94e
                - "index.gecko.v2.${repository.project}.latest.firefox.decision-${cron.job_name}"
Packit f0b94e
Packit f0b94e
        scopes:
Packit f0b94e
          $if: 'tasks_for == "hg-push"'
Packit f0b94e
          then:
Packit f0b94e
            - 'assume:repo:${repoUrl[8:]}:branch:default'
Packit f0b94e
            - 'queue:route:notify.email.${ownerEmail}.*'
Packit f0b94e
            - 'in-tree:hook-action:project-gecko/in-tree-action-${repository.level}-*'
Packit f0b94e
          else:
Packit f0b94e
            $if: 'tasks_for == "action"'
Packit f0b94e
            then:
Packit f0b94e
              # when all actions are hooks, we can calculate this directly rather than using a variable
Packit f0b94e
              - '${action.repo_scope}'
Packit f0b94e
            else:
Packit f0b94e
              - 'assume:repo:${repoUrl[8:]}:cron:${cron.job_name}'
Packit f0b94e
Packit f0b94e
        dependencies: []
Packit f0b94e
        requires: all-completed
Packit f0b94e
Packit f0b94e
        priority:
Packit f0b94e
          # Most times, there is plenty of worker capacity so everything runs
Packit f0b94e
          # quickly, but sometimes a storm of action tasks lands.  Then we
Packit f0b94e
          # want, from highest to lowest:
Packit f0b94e
          # - cron tasks (time-sensitive) (low)
Packit f0b94e
          # - action tasks (avoid interfering with the other two) (very-low)
Packit f0b94e
          # - decision tasks (minimize user-visible delay) (lowest)
Packit f0b94e
          # SCM levels all use different workerTypes, so there is no need for priority
Packit f0b94e
          # between levels; "low" is the highest priority available at all levels, and
Packit f0b94e
          # nothing runs at any higher priority on these workerTypes.
Packit f0b94e
          $if: "tasks_for == 'cron'"
Packit f0b94e
          then: low
Packit f0b94e
          else:
Packit f0b94e
            $if: "tasks_for == 'action'"
Packit f0b94e
            then: very-low
Packit f0b94e
            else: lowest  # tasks_for == 'hg-push'
Packit f0b94e
        retries: 5
Packit f0b94e
Packit f0b94e
        payload:
Packit f0b94e
          env:
Packit f0b94e
            # checkout-gecko uses these to check out the source; the inputs
Packit f0b94e
            # to `mach taskgraph decision` are all on the command line.
Packit f0b94e
            $merge:
Packit f0b94e
              - GECKO_BASE_REPOSITORY: 'https://hg.mozilla.org/mozilla-unified'
Packit f0b94e
                GECKO_HEAD_REPOSITORY: '${repoUrl}'
Packit f0b94e
                GECKO_HEAD_REF: '${push.revision}'
Packit f0b94e
                GECKO_HEAD_REV: '${push.revision}'
Packit f0b94e
                HG_STORE_PATH: /builds/worker/checkouts/hg-store
Packit f0b94e
                TASKCLUSTER_CACHES: /builds/worker/checkouts
Packit f0b94e
                # someday, these will be provided by the worker - Bug 1492664
Packit f0b94e
                TASKCLUSTER_ROOT_URL: https://taskcluster.net
Packit f0b94e
                TASKCLUSTER_PROXY_URL: http://taskcluster
Packit f0b94e
              - $if: 'tasks_for == "action"'
Packit f0b94e
                then:
Packit f0b94e
                  ACTION_TASK_GROUP_ID: '${action.taskGroupId}'     # taskGroupId of the target task
Packit f0b94e
                  ACTION_TASK_ID: {$json: {$eval: 'taskId'}} # taskId of the target task (JSON-encoded)
Packit f0b94e
                  ACTION_INPUT: {$json: {$eval: 'input'}}
Packit f0b94e
                  ACTION_CALLBACK: '${action.cb_name}'
Packit f0b94e
                  ACTION_PARAMETERS: {$json: {$eval: 'parameters'}}
Packit f0b94e
Packit f0b94e
          cache:
Packit f0b94e
            level-${repository.level}-checkouts-sparse-v2: /builds/worker/checkouts
Packit f0b94e
Packit f0b94e
          features:
Packit f0b94e
            taskclusterProxy: true
Packit f0b94e
            chainOfTrust: true
Packit f0b94e
Packit f0b94e
          # Note: This task is built server side without the context or tooling that
Packit f0b94e
          # exist in tree so we must hard code the hash
Packit f0b94e
          image: 'taskcluster/decision:2.1.0@sha256:6db3b697d7a3c7aba440d72f04199331b872111cefff57206b8b8b1d53230360'
Packit f0b94e
Packit f0b94e
          maxRunTime: 1800
Packit f0b94e
Packit f0b94e
          command:
Packit f0b94e
            - /builds/worker/bin/run-task
Packit f0b94e
            - '--vcs-checkout=/builds/worker/checkouts/gecko'
Packit f0b94e
            - '--sparse-profile=build/sparse-profiles/taskgraph'
Packit f0b94e
            - '--'
Packit f0b94e
            - bash
Packit f0b94e
            - -cx
Packit f0b94e
            - $let:
Packit f0b94e
                extraArgs: {$if: 'tasks_for == "cron"', then: '${cron.quoted_args}', else: ''}
Packit f0b94e
              in:
Packit f0b94e
                $if: 'tasks_for == "action"'
Packit f0b94e
                then: >
Packit f0b94e
                  cd /builds/worker/checkouts/gecko &&
Packit f0b94e
                  ln -s /builds/worker/artifacts artifacts &&
Packit f0b94e
                  ./mach --log-no-times taskgraph action-callback
Packit f0b94e
                else: >
Packit f0b94e
                  cd /builds/worker/checkouts/gecko &&
Packit f0b94e
                  ln -s /builds/worker/artifacts artifacts &&
Packit f0b94e
                  ./mach --log-no-times taskgraph decision
Packit f0b94e
                  --pushlog-id='${push.pushlog_id}'
Packit f0b94e
                  --pushdate='${push.pushdate}'
Packit f0b94e
                  --project='${repository.project}'
Packit f0b94e
                  --owner='${ownerEmail}'
Packit f0b94e
                  --level='${repository.level}'
Packit f0b94e
                  --tasks-for='${tasks_for}'
Packit f0b94e
                  --base-repository="$GECKO_BASE_REPOSITORY"
Packit f0b94e
                  --head-repository="$GECKO_HEAD_REPOSITORY"
Packit f0b94e
                  --head-ref="$GECKO_HEAD_REF"
Packit f0b94e
                  --head-rev="$GECKO_HEAD_REV"
Packit f0b94e
                  ${extraArgs}
Packit f0b94e
Packit f0b94e
          artifacts:
Packit f0b94e
            'public':
Packit f0b94e
              type: 'directory'
Packit f0b94e
              path: '/builds/worker/artifacts'
Packit f0b94e
              expires: {$fromNow: '1 year'}
Packit f0b94e
Packit f0b94e
        extra:
Packit f0b94e
          $merge:
Packit f0b94e
            - treeherder:
Packit f0b94e
                $merge:
Packit f0b94e
                  - machine:
Packit f0b94e
                      platform: gecko-decision
Packit f0b94e
                  - $if: 'tasks_for == "hg-push"'
Packit f0b94e
                    then:
Packit f0b94e
                      symbol: D
Packit f0b94e
                    else:
Packit f0b94e
                      $if: 'tasks_for == "action"'
Packit f0b94e
                      then:
Packit f0b94e
                        groupName: 'action-callback'
Packit f0b94e
                        groupSymbol: AC
Packit f0b94e
                        symbol: "${action.symbol}"
Packit f0b94e
                      else:
Packit f0b94e
                        groupSymbol: cron
Packit f0b94e
                        symbol: "${cron.job_symbol}"
Packit f0b94e
            - $if: 'tasks_for == "action"'
Packit f0b94e
              then:
Packit f0b94e
                parent: '${action.taskGroupId}'
Packit f0b94e
                action:
Packit f0b94e
                  name: '${action.name}'
Packit f0b94e
                  context:
Packit f0b94e
                    taskGroupId: '${action.taskGroupId}'
Packit f0b94e
                    taskId: {$eval: 'taskId'}
Packit f0b94e
                    input: {$eval: 'input'}
Packit f0b94e
                    parameters: {$eval: 'parameters'}
Packit f0b94e
            - $if: 'tasks_for == "cron"'
Packit f0b94e
              then:
Packit f0b94e
                cron: {$json: {$eval: 'cron'}}
Packit f0b94e
            - tasks_for: '${tasks_for}'
Packit f0b94e
            # Email format for try pushes
Packit f0b94e
            - $if: 'tasks_for == "hg-push" && repository.project == "try"'
Packit f0b94e
              then:
Packit f0b94e
                notify:
Packit f0b94e
                  email:
Packit f0b94e
                    subject: "Thank you for your try submission of ${push.revision}. It's the best!"
Packit f0b94e
                    content: "Your try push has been submitted. It's the best! Use the link to view the status of your jobs."
Packit f0b94e
                    link:
Packit f0b94e
                      text: "Treeherder Jobs"
Packit f0b94e
                      href: "https://treeherder.mozilla.org/#/jobs?repo=${repository.project}&revision=${push.revision}"
Packit f0b94e