Dependencies

December 3, 2025 ยท View on GitHub

Mudyla supports a powerful dependency system allowing for flexible graph construction.

Strong Dependencies

Standard dependencies are required for an action to run. If a dependency fails, the dependent action will not start.

Implicit: By using an output from another action.

echo "${action.compile.binary}"

Explicit: Using the dep command.

dep action.compile

Soft Dependencies (soft)

Soft dependencies allow an action to depend on another only if a decider action (the "retainer") explicitly signals that it should be kept. This is useful for feature flags or conditional execution based on runtime checks.

Syntax: soft action.<target> retain.action.<decider>

# In action: pipeline
soft action.extra-tests retain.action.check-feature-flag

The extra-tests action will only run if:

  1. check-feature-flag runs successfully.
  2. check-feature-flag explicitly signals retention.

Implementing a Retainer

The retainer action must signal its decision using the retain command (Bash) or mdl.retain() (Python).

Bash Retainer:

# action: check-feature-flag
# ... check logic ...
if [ "$FEATURE_ENABLED" = "true" ]; then
    retain
fi

Python Retainer:

# action: check-feature-flag
# ... check logic ...
if feature_enabled:
    mdl.retain()

If the function/command is not called, the soft dependency target (extra-tests) is dropped from the execution graph (unless it is required by some other strong dependency).

Checking Retention Status

You can check if a soft or weak dependency was retained (executed) without accessing its output.

Bash: Use ${retained.weak.<action>} or ${retained.soft.<action>} (returns "1" or "0").

if [ "${retained.soft.extra-tests}" = "1" ]; then
    echo "Tests were run!"
fi

Python: Use mdl.is_retained("action-name").

if mdl.is_retained("extra-tests"):
    print("Tests were run!")

Accessing Outputs

Since a soft dependency target might be pruned (skipped), you must use the weak expansion syntax to access its outputs safely.

  • Correct: ${action.weak.extra-tests.result} -> Returns "" (empty string) if action was skipped.
  • Incorrect: ${action.extra-tests.result} -> Crashes with an error if action was skipped.
# Safe access
RESULT="${action.weak.extra-tests.result}"
if [ -n "$RESULT" ]; then
    echo "Tests ran: $RESULT"
else
    echo "Tests skipped"
fi

Warning: Using the strong syntax ${action.extra-tests.result} implicitly creates a strong dependency, which forces the action to run regardless of the retainer's decision, effectively defeating the purpose of soft.

Weak Dependencies (weak)

Weak dependencies are "best-effort". They run only if the target action is already part of the execution graph (retained by a strong dependency elsewhere).

Syntax: weak action.<target> or implicit via ${action.weak.<target>.output}.

# In action: report
weak action.optional-metrics
echo "Metrics: ${action.weak.optional-metrics.file}"

If optional-metrics is running (because someone else needs it), report will wait for it and get the file. If not, the expansion resolves to an empty string "", and report runs without it.

Environment Dependencies

You can declare dependencies on environment variables to ensure they exist.

dep env.API_KEY