tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

release_deps.py (2731B)


      1 # This Source Code Form is subject to the terms of the Mozilla Public
      2 # License, v. 2.0. If a copy of the MPL was not distributed with this
      3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 """
      5 Add dependencies to release tasks.
      6 """
      7 
      8 from taskgraph.transforms.base import TransformSequence
      9 
     10 PHASES = ["build", "promote", "push", "ship"]
     11 
     12 transforms = TransformSequence()
     13 
     14 
     15 @transforms.add
     16 def add_dependencies(config, jobs):
     17    for job in jobs:
     18        dependencies = {}
     19        # Add any kind_dependencies_tasks with matching product as dependencies
     20        product = job.get("shipping-product")
     21        phase = job.get("shipping-phase")
     22        if product is None:
     23            continue
     24 
     25        required_signoffs = set(
     26            job.setdefault("attributes", {}).get("required_signoffs", [])
     27        )
     28        for dep_task in config.kind_dependencies_tasks.values():
     29            # Weed out unwanted tasks.
     30            # XXX we have run-on-projects which specifies the on-push behavior;
     31            # we need another attribute that specifies release promotion,
     32            # possibly which action(s) each task belongs in.
     33 
     34            # We can only depend on tasks in the current or previous phases
     35            dep_phase = dep_task.attributes.get("shipping_phase")
     36            if dep_phase and PHASES.index(dep_phase) > PHASES.index(phase):
     37                continue
     38 
     39            if dep_task.attributes.get("build_platform") and job.get(
     40                "attributes", {}
     41            ).get("build_platform"):
     42                if (
     43                    dep_task.attributes["build_platform"]
     44                    != job["attributes"]["build_platform"]
     45                ):
     46                    continue
     47 
     48            # TODO get rid of the release-type match
     49            if product == "firefox-android":
     50                # exclude beta tasks from release graph and vice versa
     51                from android_taskgraph.release_type import does_task_match_release_type
     52 
     53                if not does_task_match_release_type(
     54                    dep_task, config.params["release_type"]
     55                ):
     56                    continue
     57 
     58            # Add matching product tasks to deps
     59            if (
     60                dep_task.task.get("shipping-product") == product
     61                or dep_task.attributes.get("shipping_product") == product
     62            ):
     63                dependencies[dep_task.label] = dep_task.label
     64                required_signoffs.update(
     65                    dep_task.attributes.get("required_signoffs", [])
     66                )
     67 
     68        job.setdefault("dependencies", {}).update(dependencies)
     69        if required_signoffs:
     70            job["attributes"]["required_signoffs"] = sorted(required_signoffs)
     71 
     72        yield job