tor-browser

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

schema.py (2539B)


      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 
      6 import logging
      7 
      8 import voluptuous
      9 from mozbuild import schedules
     10 
     11 logger = logging.getLogger(__name__)
     12 
     13 
     14 default_optimizations = (
     15    # always run this task (default)
     16    None,
     17    # always optimize this task
     18    {"always": None},
     19    # optimize strategy aliases for build kind
     20    {"build": list(schedules.ALL_COMPONENTS)},
     21    # search the index for the given index namespaces, and replace this task if found
     22    # the search occurs in order, with the first match winning
     23    {"index-search": [str]},
     24    # never optimize this task
     25    {"never": None},
     26    # skip the task except for every Nth push
     27    {"skip-unless-expanded": None},
     28    {"skip-unless-backstop": None},
     29    {"skip-unless-android-perftest-backstop": None},
     30    # skip this task if none of the given file patterns match
     31    {"skip-unless-changed": [str]},
     32    {"skip-unless-missing-or-changed": [voluptuous.Any(str, [str])]},
     33    # skip this task if unless the change files' SCHEDULES contains any of these components
     34    {"skip-unless-schedules": list(schedules.ALL_COMPONENTS)},
     35    # optimize strategy aliases for the test kind
     36    {"test": list(schedules.ALL_COMPONENTS)},
     37    {"test-inclusive": list(schedules.ALL_COMPONENTS)},
     38    # optimize strategy alias for test-verify tasks
     39    {"test-verify": list(schedules.ALL_COMPONENTS)},
     40    # optimize strategy alias for upload-symbols tasks
     41    {"upload-symbols": None},
     42    # optimize strategy alias for reprocess-symbols tasks
     43    {"reprocess-symbols": None},
     44    # optimization strategy for mozlint tests
     45    {"skip-unless-mozlint": voluptuous.Any(str, [str])},
     46 )
     47 
     48 OptimizationSchema = voluptuous.Any(*default_optimizations)
     49 
     50 
     51 def set_optimization_schema(schema_tuple):
     52    """Sets OptimizationSchema so it can be imported by the task transform.
     53    This function is called by projects that extend Firefox's taskgraph.
     54    It should be called by the project's taskgraph:register function before
     55    any transport or job runner code is imported.
     56 
     57    :param tuple schema_tuple: Tuple of possible optimization strategies
     58    """
     59    global OptimizationSchema
     60    if OptimizationSchema.validators == default_optimizations:
     61        logger.info("OptimizationSchema updated.")
     62        OptimizationSchema = voluptuous.Any(*schema_tuple)
     63    else:
     64        raise Exception("Can only call set_optimization_schema once.")