forked from mirrors/gecko-dev
		
	These files were omitted from the original patch because reformatting them required some manual intervention in order to avoid breaking unit tests. Generally the `noqa` lines were already there and just needed to be moved from one line to another (due to the reformatting by `black`), but sometimes `black` saw fit to move a bunch of stuff all onto one line, requiring me to introduce new `noqa` lines. Besides the autoformat by `black` and some manual fixups, this patch contains no other changes. # ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D94052 Depends on D94045
		
			
				
	
	
		
			107 lines
		
	
	
	
		
			3.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			107 lines
		
	
	
	
		
			3.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
# 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/.
 | 
						|
"""
 | 
						|
Add from parameters.yml into bouncer submission tasks.
 | 
						|
"""
 | 
						|
 | 
						|
from __future__ import absolute_import, print_function, unicode_literals
 | 
						|
 | 
						|
import logging
 | 
						|
 | 
						|
from taskgraph.transforms.base import TransformSequence
 | 
						|
from taskgraph.transforms.bouncer_submission import craft_bouncer_product_name
 | 
						|
from taskgraph.transforms.bouncer_submission_partners import (
 | 
						|
    craft_partner_bouncer_product_name,
 | 
						|
)
 | 
						|
from taskgraph.util.partners import get_partners_to_be_published
 | 
						|
from taskgraph.util.schema import resolve_keyed_by
 | 
						|
from taskgraph.util.scriptworker import get_release_config
 | 
						|
 | 
						|
logger = logging.getLogger(__name__)
 | 
						|
 | 
						|
transforms = TransformSequence()
 | 
						|
 | 
						|
 | 
						|
@transforms.add
 | 
						|
def make_task_worker(config, jobs):
 | 
						|
    for job in jobs:
 | 
						|
        resolve_keyed_by(
 | 
						|
            job,
 | 
						|
            "worker-type",
 | 
						|
            item_name=job["name"],
 | 
						|
            **{"release-level": config.params.release_level()}
 | 
						|
        )
 | 
						|
        resolve_keyed_by(
 | 
						|
            job,
 | 
						|
            "scopes",
 | 
						|
            item_name=job["name"],
 | 
						|
            **{"release-level": config.params.release_level()}
 | 
						|
        )
 | 
						|
        resolve_keyed_by(
 | 
						|
            job,
 | 
						|
            "bouncer-products-per-alias",
 | 
						|
            item_name=job["name"],
 | 
						|
            project=config.params["project"],
 | 
						|
        )
 | 
						|
        if "partner-bouncer-products-per-alias" in job:
 | 
						|
            resolve_keyed_by(
 | 
						|
                job,
 | 
						|
                "partner-bouncer-products-per-alias",
 | 
						|
                item_name=job["name"],
 | 
						|
                project=config.params["project"],
 | 
						|
            )
 | 
						|
 | 
						|
        job["worker"]["entries"] = craft_bouncer_entries(config, job)
 | 
						|
 | 
						|
        del job["bouncer-products-per-alias"]
 | 
						|
        if "partner-bouncer-products-per-alias" in job:
 | 
						|
            del job["partner-bouncer-products-per-alias"]
 | 
						|
 | 
						|
        if job["worker"]["entries"]:
 | 
						|
            yield job
 | 
						|
        else:
 | 
						|
            logger.warn(
 | 
						|
                'No bouncer entries defined in bouncer submission task for "{}". \
 | 
						|
Job deleted.'.format(
 | 
						|
                    job["name"]
 | 
						|
                )
 | 
						|
            )
 | 
						|
 | 
						|
 | 
						|
def craft_bouncer_entries(config, job):
 | 
						|
    release_config = get_release_config(config)
 | 
						|
 | 
						|
    product = job["shipping-product"]
 | 
						|
    current_version = release_config["version"]
 | 
						|
    bouncer_products_per_alias = job["bouncer-products-per-alias"]
 | 
						|
 | 
						|
    entries = {
 | 
						|
        bouncer_alias: craft_bouncer_product_name(
 | 
						|
            product,
 | 
						|
            bouncer_product,
 | 
						|
            current_version,
 | 
						|
        )
 | 
						|
        for bouncer_alias, bouncer_product in bouncer_products_per_alias.items()
 | 
						|
    }
 | 
						|
 | 
						|
    partner_bouncer_products_per_alias = job.get("partner-bouncer-products-per-alias")
 | 
						|
    if partner_bouncer_products_per_alias:
 | 
						|
        partners = get_partners_to_be_published(config)
 | 
						|
        for partner, sub_config_name, _ in partners:
 | 
						|
            entries.update(
 | 
						|
                {
 | 
						|
                    bouncer_alias.replace(
 | 
						|
                        "PARTNER", "{}-{}".format(partner, sub_config_name)
 | 
						|
                    ): craft_partner_bouncer_product_name(
 | 
						|
                        product,
 | 
						|
                        bouncer_product,
 | 
						|
                        current_version,
 | 
						|
                        partner,
 | 
						|
                        sub_config_name,
 | 
						|
                    )
 | 
						|
                    for bouncer_alias, bouncer_product in partner_bouncer_products_per_alias.items()  # NOQA: E501
 | 
						|
                }
 | 
						|
            )
 | 
						|
 | 
						|
    return entries
 |