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/.
9 from mozbuild
import schedules
11 logger
= logging
.getLogger(__name__
)
14 default_optimizations
= (
15 # always run this task (default)
17 # always optimize this task
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
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 this task if unless the change files' SCHEDULES contains any of these components
33 {"skip-unless-schedules": list(schedules
.ALL_COMPONENTS
)},
34 # optimize strategy aliases for the test kind
35 {"test": list(schedules
.ALL_COMPONENTS
)},
36 {"test-inclusive": list(schedules
.ALL_COMPONENTS
)},
37 # optimize strategy alias for test-verify tasks
38 {"test-verify": list(schedules
.ALL_COMPONENTS
)},
39 # optimize strategy alias for upload-symbols tasks
40 {"upload-symbols": None},
41 # optimize strategy alias for reprocess-symbols tasks
42 {"reprocess-symbols": None},
43 # optimization strategy for mozlint tests
44 {"skip-unless-mozlint": voluptuous
.Any(str, [str])},
47 OptimizationSchema
= voluptuous
.Any(*default_optimizations
)
50 def set_optimization_schema(schema_tuple
):
51 """Sets OptimizationSchema so it can be imported by the task transform.
52 This function is called by projects that extend Firefox's taskgraph.
53 It should be called by the project's taskgraph:register function before
54 any transport or job runner code is imported.
56 :param tuple schema_tuple: Tuple of possible optimization strategies
58 global OptimizationSchema
59 if OptimizationSchema
.validators
== default_optimizations
:
60 logger
.info("OptimizationSchema updated.")
61 OptimizationSchema
= voluptuous
.Any(*schema_tuple
)
63 raise Exception("Can only call set_optimization_schema once.")