tor-browser

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

backstop.py (1838B)


      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 from taskgraph.optimize.base import All, OptimizationStrategy, register_strategy
      7 
      8 from gecko_taskgraph.util.backstop import BACKSTOP_PUSH_INTERVAL
      9 
     10 
     11 @register_strategy("skip-unless-android-perftest-backstop")
     12 class SkipUnlessAndroidPerftestBackstop(OptimizationStrategy):
     13    """Always removes tasks except on backstop pushes."""
     14 
     15    def should_remove_task(self, task, params, _):
     16        return not params["android_perftest_backstop"]
     17 
     18 
     19 @register_strategy("skip-unless-backstop")
     20 class SkipUnlessBackstop(OptimizationStrategy):
     21    """Always removes tasks except on backstop pushes."""
     22 
     23    def should_remove_task(self, task, params, _):
     24        return not params["backstop"]
     25 
     26 
     27 class SkipUnlessPushInterval(OptimizationStrategy):
     28    """Always removes tasks except every N pushes.
     29 
     30    Args:
     31        push_interval (int): Number of pushes
     32    """
     33 
     34    def __init__(self, push_interval, remove_on_projects=None):
     35        self.push_interval = push_interval
     36 
     37    @property
     38    def description(self):
     39        return f"skip-unless-push-interval-{self.push_interval}"
     40 
     41    def should_remove_task(self, task, params, _):
     42        # On every Nth push, want to run all tasks.
     43        return int(params["pushlog_id"]) % self.push_interval != 0
     44 
     45 
     46 # Strategy to run tasks on "expanded" pushes, currently defined as pushes that
     47 # are half the backstop interval. The 'All' composite strategy means that the
     48 # "backstop" strategy will prevent "expanded" from applying on backstop pushes.
     49 register_strategy(
     50    "skip-unless-expanded",
     51    args=(
     52        "skip-unless-backstop",
     53        SkipUnlessPushInterval(BACKSTOP_PUSH_INTERVAL / 2),
     54    ),
     55 )(All)