Tasks
Terrabuild aims at scheduling tasks to complete goals (which are targets). For this, Terrabuild creates a graph with all automatically discovered projects, targets and project dependencies. For each tasks (which are nodes of this graph), Terrabuild has to decide what to do.
For that, Terrabuild relies on a cache (either local or remote). A cache is driven by a key: this key (which is the unique identifier of the task) is built using:
- hash of files of the project
- project dependencies
- variables used for task
terrabuild.head_commit or terrabuild.branch_or_tag variables), this key is unique across branches. This is a really major concept since this enables important build optimizations.Once the key has been computed, Terrabuild uses the target configuration and following decision tree to decide what to do:
flowchart LR
classDef start fill:black
classDef build stroke-width:4px,stroke:black,fill:white
classDef restore stroke-width:4px,stroke:black,fill:white
classDef decision stroke:black
start((" "))
force(Force ?)
cache(In cache ?)
dependency(Dependency rebuilt ?)
retry(Retry ?)
failed(Failed ?)
restore((Restore))
build((Build))
start --> force
force -- yes --> build
force -- no --> cache
cache -- yes --> dependency
cache -- no --> build
dependency -- yes --> build
dependency -- no --> retry
retry -- no --> restore
retry -- yes --> failed
failed -- no --> restore
failed -- yes --> build
class start start
class build build
class restore restore
class force,cache,dependency,retry,failed decision| Condition | Description |
|---|---|
Force | either --force or rebuild (target) enabled |
In cache | target is available in cache |
Dependency rebuilt | a dependency must rebuild |
Retry | --retry enabled |
Failed | previous build has failed |
Decision is either Build or Restore leading to a new state for the task. Note that if task is built (or built again), this triggers, in turn, build of dependent nodes.
In all cases, new state is stored in local cache. If connected to a backend, task state is uploaded and can be used in further executions.