File: partials_zucchini.py

package info (click to toggle)
firefox 147.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,484 kB
  • sloc: cpp: 7,607,246; javascript: 6,533,185; ansic: 3,775,227; python: 1,415,393; xml: 634,561; asm: 438,951; java: 186,241; sh: 62,752; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (101 lines) | stat: -rw-r--r-- 3,782 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# 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/.
"""
Transform the partials task into an actual task description.
"""
from taskgraph.transforms.base import TransformSequence
from taskgraph.util.dependencies import get_primary_dependency
from taskgraph.util.treeherder import inherit_treeherder_from_dep

from gecko_taskgraph.util.partials import get_builds
from gecko_taskgraph.util.platforms import architecture

transforms = TransformSequence()


# TODO: Add cert verify
# def identify_desired_signing_keys(project, product):
#     if project in ["mozilla-central", "comm-central", "larch", "pine", "maple"]:
#         return "nightly"
#     if project == "mozilla-beta":
#         if product == "devedition":
#             return "nightly"
#         return "release"
#     if (
#         project in ["mozilla-release", "comm-release", "comm-beta"]
#         or project.startswith("mozilla-esr")
#         or project.startswith("comm-esr")
#     ):
#         return "release"
#     return "dep1"


@transforms.add
def make_task_description(config, tasks):
    # If no balrog release history, then don't generate partials
    if not config.params.get("release_history"):
        return
    for task in tasks:
        dep_task = get_primary_dependency(config, task)
        assert dep_task

        # attributes = copy_attributes_from_dependent_job(dep_job)
        locale = task["attributes"].get("locale")

        build_locale = locale or "en-US"

        build_platform = task["attributes"]["build_platform"]
        builds = get_builds(
            config.params["release_history"], build_platform, build_locale
        )

        # If the list is empty there's no available history for this platform
        # and locale combination, so we can't build any partials.
        if not builds:
            continue

        locale_suffix = ""
        if locale:
            locale_suffix = f"{locale}/"
        artifact_path = f"{locale_suffix}target.complete.mar"

        # Fetches from upstream repackage task
        task["fetches"][dep_task.kind] = [artifact_path]

        extra_params = [f"--target=/builds/worker/artifacts/{locale_suffix}"]

        for build in sorted(builds):
            url = builds[build]["mar_url"]
            extra_params.append(f"--from_url={url}")

        to_mar_path = None
        for artifact in dep_task.attributes["release_artifacts"]:
            if artifact.endswith(".complete.mar"):
                to_mar_path = artifact
                break

        task["worker"]["env"]["TO_MAR_TASK_ID"] = {
            "task-reference": f"<{dep_task.kind}>"
        }
        extra_params.extend(
            [
                f"--arch={architecture(build_platform)}",
                f"--locale={build_locale}",
                # This isn't a great approach to resolving the source URL of to_mar, but it's the same as
                # It's only being used to fill manifest.json information, the actual file is downloaded via run-task
                f"--to_mar_url=https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/$TO_MAR_TASK_ID/artifacts/{to_mar_path}",
            ]
        )
        # Add a space from the last command + list of extra_params
        task["run"]["command"] += " " + " ".join(extra_params)

        task["description"] = (
            f"Partials task for locale '{build_locale}' for build '{build_platform}'"
        )

        task["treeherder"] = inherit_treeherder_from_dep(task, dep_task)
        task["treeherder"]["symbol"] = f"pz({locale or 'N'})"

        task["worker"]["env"]["MAR_CHANNEL_ID"] = task["attributes"]["mar-channel-id"]
        yield task