tor-browser

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

mach_commands.py (6499B)


      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 # ruff linter deprecates List, required for Python 3.8 compatibility
      6 from typing import List, Optional  # noqa UP035
      7 
      8 from mach.decorators import Command, CommandArgument, SubCommand
      9 
     10 
     11 @Command(
     12    "manifest",
     13    category="testing",
     14    description="Manifest operations",
     15    virtualenv_name="manifest",
     16 )
     17 def manifest(_command_context):
     18    """
     19    All functions implemented as subcommands.
     20    """
     21 
     22 
     23 @SubCommand(
     24    "manifest",
     25    "skip-fails",
     26    description="Update manifests to skip failing tests",
     27 )
     28 @CommandArgument("try_url", nargs=1, help="Treeherder URL for try (please use quotes)")
     29 @CommandArgument(
     30    "-b",
     31    "--bugzilla",
     32    default=None,
     33    help="Bugzilla instance [disable]",
     34 )
     35 @CommandArgument(
     36    "-C",
     37    "--clear-cache",
     38    nargs="?",
     39    const="all",
     40    default=None,
     41    help="clear cache REVISION (or all)",
     42 )
     43 @CommandArgument(
     44    "-c",
     45    "--carryover",
     46    action="store_true",
     47    help="Set carryover mode (only skip failures for platform matches)",
     48 )
     49 @CommandArgument(
     50    "-d",
     51    "--dry-run",
     52    action="store_true",
     53    help="Determine manifest changes, but do not write them",
     54 )
     55 @CommandArgument(
     56    "-F",
     57    "--use-failures",
     58    default=None,
     59    help="Use failures from file",
     60 )
     61 @CommandArgument(
     62    "-f",
     63    "--save-failures",
     64    default=None,
     65    help="Save failures to file",
     66 )
     67 @CommandArgument(
     68    "-I",
     69    "--implicit-vars",
     70    action="store_true",
     71    help="Use implicit variables in reftest manifests",
     72 )
     73 @CommandArgument(
     74    "-i",
     75    "--task-id",
     76    default=None,
     77    help="Task id to write a condition for instead of all tasks from the push",
     78 )
     79 @CommandArgument(
     80    "-k",
     81    "--known-intermittents",
     82    action="store_true",
     83    help="Set known intermittents mode (only skip failures known intermittents)",
     84 )
     85 @CommandArgument(
     86    "-M",
     87    "--max-failures",
     88    type=int,
     89    default=-1,
     90    help="Maximum number of failures to skip (-1 == no limit)",
     91 )
     92 @CommandArgument("-m", "--meta-bug-id", type=int, default=None, help="Meta Bug id")
     93 @CommandArgument(
     94    "-n",
     95    "--new-version",
     96    default=None,
     97    help="New version to use for annotations",
     98 )
     99 @CommandArgument(
    100    "-N",
    101    "--new-failures",
    102    action="store_true",
    103    help="Set new failures mode (only add conditions for new failures)",
    104 )
    105 @CommandArgument(
    106    "-r",
    107    "--failure-ratio",
    108    type=float,
    109    default=0.4,
    110    help="Ratio of test failures/total to skip [0.4]",
    111 )
    112 @CommandArgument(
    113    "-R",
    114    "--replace-tbd",
    115    action="store_true",
    116    help="Replace Bug TBD in manifests by filing new bugs",
    117 )
    118 @CommandArgument(
    119    "-s",
    120    "--turbo",
    121    action="store_true",
    122    help="Skip all secondary failures",
    123 )
    124 @CommandArgument("-T", "--use-tasks", default=None, help="Use tasks from file")
    125 @CommandArgument("-t", "--save-tasks", default=None, help="Save tasks to file")
    126 @CommandArgument(
    127    "-u",
    128    "--user-agent",
    129    default=None,
    130    help="User-Agent to use for mozci if queries are forbidden from treeherder",
    131 )
    132 @CommandArgument("-v", "--verbose", action="store_true", help="Verbose mode")
    133 def skipfails(
    134    command_context,
    135    try_url,
    136    bugzilla: Optional[str] = None,
    137    meta_bug_id: Optional[int] = None,
    138    turbo: bool = False,
    139    save_tasks: Optional[str] = None,
    140    use_tasks: Optional[str] = None,
    141    save_failures: Optional[str] = None,
    142    use_failures: Optional[str] = None,
    143    max_failures: int = -1,
    144    verbose: bool = False,
    145    dry_run: bool = False,
    146    implicit_vars: bool = False,
    147    new_version: Optional[str] = None,
    148    task_id: Optional[str] = None,
    149    user_agent: Optional[str] = None,
    150    failure_ratio: float = 0.4,
    151    clear_cache: Optional[str] = None,
    152    carryover: bool = False,
    153    known_intermittents: bool = False,
    154    new_failures: bool = False,
    155    replace_tbd: bool = False,
    156 ):
    157    from skipfails import Skipfails, SkipfailsMode
    158 
    159    mode: int = SkipfailsMode.from_flags(
    160        carryover,
    161        known_intermittents,
    162        new_failures,
    163        replace_tbd,
    164    )
    165    Skipfails(
    166        command_context,
    167        try_url,
    168        verbose,
    169        bugzilla,
    170        dry_run,
    171        turbo,
    172        implicit_vars,
    173        new_version,
    174        task_id,
    175        user_agent,
    176        clear_cache,
    177    ).run(
    178        meta_bug_id,
    179        save_tasks,
    180        use_tasks,
    181        save_failures,
    182        use_failures,
    183        max_failures,
    184        failure_ratio,
    185        mode,
    186    )
    187 
    188 
    189 @SubCommand(
    190    "manifest",
    191    "high-freq-skip-fails",
    192    description="Update manifests to skip failing tests",
    193 )
    194 @CommandArgument(
    195    "-f",
    196    "--failures",
    197    default="30",
    198    dest="failures",
    199    help="Minimum number of failures for the bug to be skipped",
    200 )
    201 @CommandArgument(
    202    "-d",
    203    "--days",
    204    default="7",
    205    dest="days",
    206    help="Number of days to look for failures since now",
    207 )
    208 def high_freq_skipfails(command_context, failures: str, days: str):
    209    from high_freq_skipfails import HighFreqSkipfails
    210 
    211    try:
    212        failures_num = int(failures)
    213    except ValueError:
    214        failures_num = 30
    215    try:
    216        days_num = int(days)
    217    except ValueError:
    218        days_num = 7
    219    HighFreqSkipfails(command_context, failures_num, days_num).run()
    220 
    221 
    222 @SubCommand(
    223    "manifest",
    224    "clean-skip-fails",
    225    description="Update manifests to remove skip-if conditions for a specific platform. Only works for TOML manifests.",
    226 )
    227 @CommandArgument(
    228    "manifest_search_path",
    229    nargs=1,
    230    help="Path to the folder containing the manifests to update, or the path to a single manifest",
    231 )
    232 @CommandArgument(
    233    "-o",
    234    "--os",
    235    default=None,
    236    dest="os_name",
    237    help="OS to remove (linux, mac, win)",
    238 )
    239 @CommandArgument(
    240    "-s",
    241    "--os_version",
    242    default=None,
    243    dest="os_version",
    244    help="Version of the OS to remove (eg: 18.04 for linux)",
    245 )
    246 @CommandArgument(
    247    "-p",
    248    "--processor",
    249    default=None,
    250    dest="processor",
    251    help="Type of processor architecture to remove (eg: x86)",
    252 )
    253 def clean_skipfails(
    254    command_context,
    255    manifest_search_path: List[str],  # noqa UP006
    256    os_name: Optional[str] = None,
    257    os_version: Optional[str] = None,
    258    processor: Optional[str] = None,
    259 ):
    260    from clean_skipfails import CleanSkipfails
    261 
    262    CleanSkipfails(
    263        command_context, manifest_search_path[0], os_name, os_version, processor
    264    ).run()