Mozilla Taskgraph
mozilla-taskgraph provides Mozilla-specific transforms, utilities, and parameter definitions designed to extend and integrate with the taskcluster-taskgraph framework. It enables the configuration and automation of complex CI/CD processes within Mozilla's infrastructure. The library is actively maintained with frequent updates, currently at version 4.1.1, and follows semver principles.
Warnings
- breaking Python 3.8 support was dropped in version 4.0.0. Projects using `mozilla-taskgraph` must update to Python 3.9 or newer.
- gotcha Mozilla-taskgraph is tightly coupled with `taskcluster-taskgraph` versions. Ensure the `mozilla-taskgraph` version you use is compatible with your `taskcluster-taskgraph` version, as stated in its release notes (e.g., 'compatible with Taskgraph v18.0.0').
- gotcha This library is highly specialized for Mozilla's CI/CD infrastructure and conventions. While its underlying `taskcluster-taskgraph` framework is general, the transforms and utilities in `mozilla-taskgraph` are tailored for Mozilla's specific needs.
- breaking Changes related to the migration of 'decision' and 'image' tasks to 'd2g worker pools' were introduced in version 4.0.2. Existing task definitions for these types might require updates to align with the new worker pool configurations.
Install
-
pip install mozilla-taskgraph
Imports
- MozillaProjectConfigBuilder
from mozilla_taskgraph.project_config import MozillaProjectConfigBuilder
- transform_version_tasks
from mozilla_taskgraph.transforms.versions import transform_version_tasks
- add_platform_to_task_name
from mozilla_taskgraph.util.task_names import add_platform_to_task_name
Quickstart
from mozilla_taskgraph.util.task_names import add_platform_to_task_name
from mozilla_taskgraph.parameters import build_parameters
from mozilla_taskgraph.project_config import MozillaProjectConfigBuilder
# Demonstrating a utility function provided by mozilla-taskgraph
print("\n--- Demonstrating a utility function ---")
original_name = "build-linux"
platform_tag = "x64"
new_name = add_platform_to_task_name(original_name, platform_tag)
print(f"Original task name: '{original_name}', Platform: '{platform_tag}'")
print(f"Transformed task name: '{new_name}'")
# Accessing Mozilla-specific parameter definitions (conceptual)
print("\n--- Accessing Mozilla-specific parameter definitions ---")
# These parameters are typically consumed by other parts of the taskgraph
try:
# The exact way to access definitions might vary; this is illustrative.
print(f"Example parameter definition key: {next(iter(build_parameters.BUILD_PROPERTIES_DEFINITION.keys()))}")
except AttributeError:
print("Note: Parameter definitions are typically used internally by transforms.")
# Illustrating the main configuration builder (requires 'taskcluster-taskgraph')
print("\n--- Instantiating MozillaProjectConfigBuilder ---")
# In a real setup, 'project_dir' would point to a directory containing .taskcluster.yml
# For this quickstart, we'll instantiate it conceptually without requiring actual files.
# Note: Full functionality of the builder requires a valid taskgraph project structure.
try:
# Minimal instantiation, skipping schema validation for quickstart simplicity
builder = MozillaProjectConfigBuilder(
project_dir=".",
schema_validate=False
)
print("MozillaProjectConfigBuilder instantiated successfully.")
print("This builder extends taskgraph's ProjectConfig to include Mozilla-specific logic and defaults.")
except Exception as e:
print(f"Could not instantiate MozillaProjectConfigBuilder: {e}")
print("Ensure 'taskcluster-taskgraph' is installed and project_dir is correctly set for full functionality.")