routes.py 1.87 KB
Newer Older
Johan Lorenzo's avatar
Johan Lorenzo committed
1
2
3
4
5
6
7
8
9
10
# 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/.

from __future__ import absolute_import, print_function, unicode_literals

import time

from taskgraph.transforms.task import index_builder

11
12
13
# Please ping the performance testing team (whawkins at the moment) if these routes change.
# In the future, notifying consumers may be easier (https://bugzilla.mozilla.org/show_bug.cgi?id=1548810), but
# we need to remember to tell users for the time being
Johan Lorenzo's avatar
Johan Lorenzo committed
14
SIGNING_ROUTE_TEMPLATES = [
15
16
17
18
19
20
    "index.{trust-domain}.v2.{project}.{variant}.latest.{abi}",
    "index.{trust-domain}.v2.{project}.{variant}.{build_date}.revision.{head_rev}.{abi}",
    "index.{trust-domain}.v2.{project}.{variant}.{build_date}.latest.{abi}",
    "index.{trust-domain}.v2.{project}.{variant}.revision.{head_rev}.{abi}",

    # TODO Bug 1631839: Remove the following scopes once all consumers have migrated
21
22
23
    "index.project.{trust-domain}.{project}.v2.{variant}.{build_date}.revision.{head_rev}",
    "index.project.{trust-domain}.{project}.v2.{variant}.{build_date}.latest",
    "index.project.{trust-domain}.{project}.v2.{variant}.latest",
Johan Lorenzo's avatar
Johan Lorenzo committed
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
]


@index_builder("signing")
def add_signing_indexes(config, task):
    if config.params["level"] != "3":
        return task

    subs = config.params.copy()
    subs["build_date"] = time.strftime(
        "%Y.%m.%d", time.gmtime(config.params["build_date"])
    )
    subs["trust-domain"] = config.graph_config["trust-domain"]
    subs["variant"] = task["attributes"]["build-type"]

39
    unique_routes = set()
Johan Lorenzo's avatar
Johan Lorenzo committed
40
    for tpl in SIGNING_ROUTE_TEMPLATES:
41
42
43
44
45
        for abi in task["attributes"]["apks"].keys():
            subs["abi"] = abi
            unique_routes.add(tpl.format(**subs))

    task.setdefault("routes", sorted(list(unique_routes)))
Johan Lorenzo's avatar
Johan Lorenzo committed
46
    return task