Optimization Strategies#
Taskgraph provides some built-in strategies that can be used during the optimization process.
Strategies for Removing Tasks#
skip-unless-changed#
Note
This strategy is only implemented for Mercurial repositories hosted on
hg.mozilla.org
.
The skip-unless-changed
strategy will optimize the
target task away unless a specified file is modified. Glob patterns are
supported.
Example:
my-task:
optimization:
skip-unless-changed:
- some/file.txt
- docs/**
Strategies for Replacing Tasks#
index-search#
Given a list of index paths, the index-search
strategy will replace the target
task with the first one that exists.
In order for the indexed task to be considered for replacement, it must:
Exist.
Not have a
state
offailed
orexception
.Not expire before the earliest deadline of all tasks depending on it.
Example:
my-task:
optimization:
index-search:
- my.index.route
Composite Strategies#
These strategies operate on one or more substrategies. Composite strategies may contain other composite strategies.
Alias#
The Alias
strategy contains a single
substrategy and provides an alternative name for it. This can be useful for
swapping the strategy used for a particular set of tasks without needing to
modify all of their task definitions.
All#
The All
strategy will only optimize a task if
all of its substrategies say to optimize it.
Any#
The Any
strategy will optimize a task if any
of its substrategies say to optimize it.
Not#
The Not
strategy contains a single substrategy
and will negate it.