website/docs/how-it-works/action-graph.mdx
import ActionGraph from '@site/src/components/Docs/ActionGraph'; import VersionLabel from '@site/src/components/Docs/VersionLabel';
When you run a task on the command line, we generate an action graph to ensure dependencies of tasks have ran before running run the primary task.
The action graph is a representation of all tasks, derived from the project graph and task graph, and is also represented internally as a directed acyclic graph (DAG).
<ActionGraph />Unlike other task runners in the industry that represent each node in the graph as a task to run, we represent each node in the graph as an action to perform. This allows us to be more flexible and efficient with how we run tasks, and allows us to provide more functionality and automation than other runners.
The following actions compose our action graph:
This is a common action that always runs and give's moon a chance to perform operations and health checks across the entire workspace.
:::info
This action can be skipped by disabling the
pipeline.syncWorkspace setting.
:::
The most important action in the graph is the setup toolchain action, which downloads and installs a tier 3 language into the toolchain. For other tiers, this is basically a no-operation.
PATH).:::info
This action can be skipped by setting the MOON_SKIP_SETUP_TOOLCHAIN=true environment variable. The
skip can be scoped per tool by setting the value to the tool name (node), and also by version
(node:20.0.0). Supports a comma-separated list.
:::
This action runs after the toolchain has been setup, but before dependencies are installed, so that
the development environment can be setup and configured. This includes operations such as modifying
a manifest (package.json, etc), updating configuration files, initializing venv's (Python), so on
and so forth.
This action runs before all toolchain related actions and ensures that proto has been installed and is available for use. This is required for toolchains that will be downloaded and installed.
Before we run a task, we ensure that all language/toolchain dependencies (node_modules for
example) have been installed, by automatically installing them if we detect changes since the last
run. We achieve this by comparing lockfile modified timestamps, parsing manifest files, and hashing
resolved dependency versions.
:::info
This action can be skipped by disabling the
pipeline.installDependencies setting.
:::
To ensure a consistently healthy project and repository, we run a process known as syncing everytime a task is ran. This action will run sync operations for all toolchains associated with the project.
:::info
This action can be skipped by disabling the
pipeline.syncProject setting.
:::
The primary action in the graph is the run task action, which runs a project's task as a child process, derived from a target. Tasks can depend on other tasks, and they'll be effectively orchestrated and executed by running in topological order using a thread pool.
Like the base run task, but runs the task interactively with stdin capabilities. All interactive tasks are run in isolation in the graph.
Like the base run task, but runs the task in a persistent process that never exits. All persistent tasks are run in parallel as the last batch in the graph.
Without the action graph, tasks would not efficiently run, or possibly at all! The graph helps to run tasks in parallel, in the correct order, and to ensure a reliable outcome.