tor-browser

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

update_verify_config.py (5314B)


      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 Transform the beetmover task into an actual task description.
      6 """
      7 
      8 from urllib.parse import urlsplit
      9 
     10 from taskgraph.transforms.base import TransformSequence
     11 from taskgraph.util.schema import resolve_keyed_by
     12 
     13 from gecko_taskgraph.transforms.task import get_branch_repo, get_branch_rev
     14 from gecko_taskgraph.util.attributes import release_level
     15 from gecko_taskgraph.util.scriptworker import get_release_config
     16 
     17 transforms = TransformSequence()
     18 
     19 
     20 # The beta regexes do not match point releases.
     21 # In the rare event that we do ship a point
     22 # release to beta, we need to either:
     23 # 1) update these regexes to match that specific version
     24 # 2) pass a second include version that matches that specific version
     25 INCLUDE_VERSION_REGEXES = {
     26    "beta": r"'^(\d+\.\d+(b\d+)?)$'",
     27    "nonbeta": r"'^\d+\.\d+(\.\d+)?$'",
     28    # Same as nonbeta, except for the esr suffix
     29    "esr": r"'^\d+\.\d+(\.\d+)?esr$'",
     30    # Previous esr versions, for update testing before we update users to esr140
     31    "esr140-next": r"'^(52|60|68|78|91|102|115|128)+\.\d+(\.\d+)?esr$'",
     32 }
     33 
     34 MAR_CHANNEL_ID_OVERRIDE_REGEXES = {
     35    "beta": r"'^\d+\.\d+(\.\d+)?$$,firefox-mozilla-beta,firefox-mozilla-release'",
     36 }
     37 
     38 
     39 def ensure_wrapped_singlequote(regexes):
     40    """Ensure that a regex (from INCLUDE_VERSION_REGEXES or MAR_CHANNEL_ID_OVERRIDE_REGEXES)
     41    is wrapper in single quotes.
     42    """
     43    for name, regex in regexes.items():
     44        if regex[0] != "'" or regex[-1] != "'":
     45            raise Exception(
     46                f"Regex {name} is invalid: not wrapped with single quotes.\n{regex}"
     47            )
     48 
     49 
     50 ensure_wrapped_singlequote(INCLUDE_VERSION_REGEXES)
     51 ensure_wrapped_singlequote(MAR_CHANNEL_ID_OVERRIDE_REGEXES)
     52 
     53 
     54 @transforms.add
     55 def add_command(config, tasks):
     56    keyed_by_args = [
     57        "channel",
     58        "archive-prefix",
     59        "previous-archive-prefix",
     60        "aus-server",
     61        "override-certs",
     62        "include-version",
     63        "mar-channel-id-override",
     64        "last-watershed",
     65    ]
     66    optional_args = [
     67        "updater-platform",
     68    ]
     69 
     70    release_config = get_release_config(config)
     71 
     72    for task in tasks:
     73        task["description"] = "generate update verify config for {}".format(
     74            task["attributes"]["build_platform"]
     75        )
     76 
     77        llbv_arg = ()
     78        if last_linux_bz2_version := task["extra"].get("last-linux-bz2-version", None):
     79            llbv_arg = ("--last-linux-bz2-version", last_linux_bz2_version)
     80 
     81        command = [
     82            "python",
     83            "testing/mozharness/scripts/release/update-verify-config-creator.py",
     84            "--product",
     85            task["extra"]["product"],
     86            "--stage-product",
     87            task["shipping-product"],
     88            "--app-name",
     89            task["extra"]["app-name"],
     90            "--branch-prefix",
     91            task["extra"]["branch-prefix"],
     92            "--platform",
     93            task["extra"]["platform"],
     94            "--to-version",
     95            release_config["version"],
     96            "--to-app-version",
     97            release_config["appVersion"],
     98            "--to-build-number",
     99            str(release_config["build_number"]),
    100            "--to-buildid",
    101            config.params["moz_build_date"],
    102            "--to-revision",
    103            get_branch_rev(config),
    104            *llbv_arg,
    105            "--output-file",
    106            "update-verify.cfg",
    107            "--local-repo",
    108            ".",
    109        ]
    110 
    111        repo_path = urlsplit(get_branch_repo(config)).path.lstrip("/")
    112        command.extend(["--repo-path", repo_path])
    113 
    114        if release_config.get("partial_versions"):
    115            for partial in release_config["partial_versions"].split(","):
    116                command.extend(["--partial-version", partial.split("build")[0]])
    117 
    118        for arg in optional_args:
    119            if task["extra"].get(arg):
    120                command.append(f"--{arg}")
    121                command.append(task["extra"][arg])
    122 
    123        for arg in keyed_by_args:
    124            thing = f"extra.{arg}"
    125            resolve_keyed_by(
    126                task,
    127                thing,
    128                item_name=task["name"],
    129                platform=task["attributes"]["build_platform"],
    130                **{
    131                    "release-type": config.params["release_type"],
    132                    "release-level": release_level(config.params),
    133                },
    134            )
    135            # ignore things that resolved to null
    136            if not task["extra"].get(arg):
    137                continue
    138            if arg == "include-version":
    139                task["extra"][arg] = INCLUDE_VERSION_REGEXES[task["extra"][arg]]
    140            if arg == "mar-channel-id-override":
    141                task["extra"][arg] = MAR_CHANNEL_ID_OVERRIDE_REGEXES[task["extra"][arg]]
    142 
    143            command.append(f"--{arg}")
    144            command.append(task["extra"][arg])
    145 
    146        task["run"].update({
    147            "using": "mach",
    148            "mach": " ".join(command),
    149        })
    150 
    151        if task.get("index"):
    152            task["index"].setdefault(
    153                "job-name",
    154                f"update-verify-config-{task['name']}-{task['extra']['channel']}",
    155            )
    156 
    157        yield task