How to use the taskcluster.slugId function in taskcluster

To help you get started, we’ve selected a few taskcluster examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github web-platform-tests / wpt / tools / ci / decision.py View on Github external
def create_tc_task(event, task, required_task_ids):
    command = build_full_command(event, task)
    worker_type = ("wpt-docker-worker"
                   if event["repository"]["full_name"] == 'web-platform-tests/wpt'
                   else "github-worker")
    task_id = taskcluster.slugId()
    task_data = {
        "taskGroupId": "", # TODO
        "created": taskcluster.fromNowJSON(""),
        "deadline": taskcluster.fromNowJSON(task["deadline"]),
        "provisionerId": task["provisionerId"],
        "workerType": worker_type,
        "metadata": {
            "name": task["name"],
            "description": task.get("description", ""),
            "owner": "%s@users.noreply.github.com" % event["sender"]["login"],
            "source": event["repository"]["url"]
        },
        "payload": {
            "artifacts": task.get("artifacts"),
            "command": command,
            "image": task.get("image"),
github web-platform-tests / wpt / tools / ci / tc / decision.py View on Github external
def build_task_graph(event, all_tasks, tasks):
    task_id_map = OrderedDict()
    taskgroup_id = os.environ.get("TASK_ID", taskcluster.slugId())

    def add_task(task_name, task):
        depends_on_ids = []
        if "depends-on" in task:
            for depends_name in task["depends-on"]:
                if depends_name not in task_id_map:
                    add_task(depends_name,
                             all_tasks[depends_name])
                depends_on_ids.append(task_id_map[depends_name][0])
        task_id, task_data = create_tc_task(event, task, taskgroup_id, depends_on_ids)
        task_id_map[task_name] = (task_id, task_data)

    for task_name, task in iteritems(tasks):
        add_task(task_name, task)

    return task_id_map
github mozilla / mozilla_ci_tools / mozci / taskcluster / tc.py View on Github external
:type update_timestamps: bool
        :param dry_run: It allows overwriting the dry_run mode at creation of the manager.
        :type dry_run: bool
        :returns: Task Status Structure (see link to createTask documentation)
        :rtype: dict

        """
        LOG.debug("We want to schedule a TC task")

        if update_timestamps:
            task = refresh_timestamps(task)

        # http://schemas.taskcluster.net/queue/v1/create-task-request.json#
        if not (dry_run or self.dry_run):
            # https://github.com/taskcluster/taskcluster-client.py#create-new-task
            task_id = taskcluster_client.slugId()
            result = self.queue.createTask(taskId=task_id, payload=task)
            LOG.info("Inspect the task in {}".format(get_task_inspector_url(task_id)))
            return result
        else:
            LOG.info("We did not schedule anything because we're running on dry run mode.")
github mozilla / mozilla_ci_tools / mozci / sources / tc.py View on Github external
returns - 0 for dry_run case, -1 for any failure or the task id (int)
              of a succesful retriggered task.

    http://docs.taskcluster.net/queue/api-docs/#createTask
    """
    one_year = 365
    new_task_id = 0

    try:
        queue = taskcluster_client.Queue()
        task = queue.task(task_id)

        LOG.debug("Original task: (Limit 1024 char)")
        LOG.debug(str(json.dumps(task))[:1024])
        new_task_id = taskcluster_client.slugId()

        artifacts = task['payload'].get('artifacts', {})
        for artifact, definition in artifacts.iteritems():
            definition['expires'] = taskcluster_client.fromNow('%s days' % one_year)

        # The task group will be identified by the ID of the only
        # task in the group
        task['taskGroupId'] = new_task_id
        # https://bugzilla.mozilla.org/show_bug.cgi?id=1190660
        # TC workers create public logs which are 365 days; if the task expiration
        # date is the same or less than that we won't have logs for the task
        task['expires'] = taskcluster_client.fromNow('%s days' % (one_year + 1))
        now = datetime.datetime.utcnow()
        tomorrow = now + datetime.timedelta(hours=24)
        task['created'] = taskcluster_client.stringDate(now)
        task['deadline'] = taskcluster_client.stringDate(tomorrow)
github mozilla / mozilla_ci_tools / mozci / taskcluster / tc.py View on Github external
def schedule_graph(task_graph, task_graph_id=None, dry_run=False, *args, **kwargs):
    """ It schedules a TaskCluster graph and returns its id.

    :param task_graph: It is a TaskCluster graph as defined in here:
        http://docs.taskcluster.net/scheduler/api-docs/#createTaskGraph
    :type task_graph: json
    :param task_graph_id: TC graph id to which this task belongs to
    :type task_graph_id: str
    :param dry_run: It does not schedule the graph
    :type dry_run: bool
    :returns: task graph id.
    :rtype: int

    """
    if not task_graph_id:
        task_graph_id = taskcluster_client.slugId()
    scheduler = taskcluster_client.Scheduler()

    LOG.info("Outputting the graph (graph id: %s):" % task_graph_id)
    # We print to stdout instead of using the standard logging with dates and info levels
    # XXX: Use a different formatter for other tools to work better with this code
    print(json.dumps(task_graph, indent=4))
    if dry_run:
        LOG.info("DRY-RUN: We have not scheduled the graph.")
    else:
        if not credentials_available():
            return None

        try:
            # https://github.com/taskcluster/taskcluster-client.py#create-new-task-graph
            result = scheduler.createTaskGraph(task_graph_id, task_graph)
            LOG.info("See the graph in %s%s" % (TC_TASK_GRAPH_INSPECTOR, task_graph_id))
github mozilla-mobile / firefox-tv / tools / taskcluster / decision_task.py View on Github external
def release(builder, tag):
    build_task_id = taskcluster.slugId()
    sign_task_id = taskcluster.slugId()
    push_task_id = taskcluster.slugId()
    return (
        (build_task_id, builder.craft_release_build_task(tag)),
        (sign_task_id, builder.craft_sign_for_github_task(build_task_id)),
        (push_task_id, builder.craft_amazon_task(build_task_id)),
        (taskcluster.slugId(), builder.craft_email_task(sign_task_id, push_task_id, tag)),
    )
github mozilla-mobile / firefox-tv / tools / taskcluster / decision_task.py View on Github external
def release(builder, tag):
    build_task_id = taskcluster.slugId()
    sign_task_id = taskcluster.slugId()
    push_task_id = taskcluster.slugId()
    return (
        (build_task_id, builder.craft_release_build_task(tag)),
        (sign_task_id, builder.craft_sign_for_github_task(build_task_id)),
        (push_task_id, builder.craft_amazon_task(build_task_id)),
        (taskcluster.slugId(), builder.craft_email_task(sign_task_id, push_task_id, tag)),
    )
github mozilla-mobile / fenix / automation / taskcluster / decision_task_nightly.py View on Github external
def generate_push_task(signing_task_id, apks, commit, is_staging):
    artifacts = ["public/{}".format(os.path.basename(apk)) for apk in apks]

    return taskcluster.slugId(), BUILDER.craft_push_task(
        signing_task_id,
        name="(Fenix) Push task",
        description="Upload signed release builds of Fenix to Google Play",
        apks=artifacts,
        scopes=[
            "project:mobile:fenix:releng:googleplay:product:fenix{}".format(':dep' if is_staging else '')
        ],
        commit=commit,
        is_staging=is_staging
    )
github mozilla-mobile / firefox-tv / tools / taskcluster / decision_task.py View on Github external
def release(builder, tag):
    build_task_id = taskcluster.slugId()
    sign_task_id = taskcluster.slugId()
    push_task_id = taskcluster.slugId()
    return (
        (build_task_id, builder.craft_release_build_task(tag)),
        (sign_task_id, builder.craft_sign_for_github_task(build_task_id)),
        (push_task_id, builder.craft_amazon_task(build_task_id)),
        (taskcluster.slugId(), builder.craft_email_task(sign_task_id, push_task_id, tag)),
    )
github mozilla-mobile / firefox-tv / tools / taskcluster / decision_task.py View on Github external
def master(builder):
    return (taskcluster.slugId(), builder.craft_master_task()),