Mozilla Taskgraph

4.1.1 · active · verified Mon Apr 13

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

Install

Imports

Quickstart

This quickstart demonstrates a utility function from `mozilla-taskgraph.util`, accesses a Mozilla-specific parameter definition, and shows how to instantiate the `MozillaProjectConfigBuilder`. `mozilla-taskgraph` provides building blocks that integrate with `taskcluster-taskgraph`; therefore, a full runnable example often requires a `taskcluster-taskgraph` project setup. This example focuses on standalone components where possible.

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.")

view raw JSON →