# Example: Required validation for unit tests
# Mirrors the workflow example in docs/specification.md (Example 1, Step 1).

name: local/unit-tests
description: Unit tests
source: custom
mode: required
code: |
  import subprocess

  def run(input_data):
      result = subprocess.run(["pytest", "tests/"], capture_output=True, text=True)
      passed = result.returncode == 0
      return {
          "passed": passed,
          "message": "Unit tests passed" if passed else "Unit tests failed",
          "data": {
              "stdout": result.stdout,
              "stderr": result.stderr,
              "returncode": result.returncode,
          },
      }

timeout: 300
