author Aki Sasaki <asasaki@mozilla.com>
Tue, 23 Oct 2018 21:12:51 +0000
changeset 491030 2eea4d6c1597ce9a997eca8bc5fdb78119d7aced
parent 459456 00b9d353a6b721a87db3e23bb5f5a904f9e8d424
child 491242 859742f773aac7807f85894071d47ae6fb6d37bf
permissions -rw-r--r--
Bug 1499254 - add primary-dependency support. r=tomprince,Callek Depends on D9194 Differential Revision: https://phabricator.services.mozilla.com/D9196

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
Generate labels for tasks without names, consistently.
Uses attributes from `dependent-task` or `primary-dependency`.

from __future__ import absolute_import, print_function, unicode_literals

from taskgraph.transforms.base import TransformSequence

transforms = TransformSequence()

def make_label(config, jobs):
    """ Generate a sane label for a new task constructed from a dependency
    Using attributes from the dependent job and the current task kind"""
    for job in jobs:
        if 'primary-dependency' in job:
            dep_job = job['primary-dependency']
            dep_job = job['dependent-task']
        attr = dep_job.attributes.get

        if attr('locale', job.get('locale')):
            template = "{kind}-{locale}-{build_platform}/{build_type}"
        elif attr('l10n_chunk'):
            template = "{kind}-{build_platform}-{l10n_chunk}/{build_type}"
        elif config.kind.startswith("release-eme-free") or \
            repack_id = job.get("extra", {}).get("repack_id", None)
            template = "{kind}-{build_platform}"
            if repack_id:
                template += "-{}".format(repack_id.replace('/', '-'))
            template = "{kind}-{build_platform}/{build_type}"
        job['label'] = template.format(
            locale=attr('locale', job.get('locale', '')),  # Locale can be absent
            l10n_chunk=attr('l10n_chunk', '')  # Can be empty

        yield job