{
  "lexicon": 1,
  "id": "sh.tangled.ci.defs",
  "defs": {
    "pipeline": {
      "type": "object",
      "required": ["id", "trigger", "commit", "workflows"],
      "properties": {
        "id": {
          "type": "string",
          "description": "Spindle-local pipeline id"
        },
        "repo": {
          "type": "string",
          "format": "did",
          "description": "Repository DID"
        },
        "trigger": {
          "type": "union",
          "refs": [
            "sh.tangled.ci.trigger#push",
            "sh.tangled.ci.trigger#pullRequest",
            "sh.tangled.ci.trigger#manual"
          ],
          "description": "Trigger event metadata"
        },
        "commit": {
          "type": "string",
          "description": "Commit Id this pipeline is running on"
        },
        "createdAt": {
          "type": "string",
          "format": "datetime"
        },
        "workflows": {
          "type": "array",
          "description": "Triggered workflows",
          "minLength": 1,
          "maxLength": 50,
          "items": {
            "type": "ref",
            "ref": "#workflow"
          }
        }
      }
    },
    "workflow": {
      "type": "object",
      "required": ["id", "name", "status"],
      "properties": {
        "id": {
          "type": "string",
          "description": "Spindle-local workflow id. Unique per pipeline, usually same as name."
        },
        "name": {
          "type": "string",
          "description": "Name of the workflow",
          "minGraphemes": 1,
          "maxGraphemes": 40
        },
        "status": {
          "type": "string",
          "description": "Workflow status",
          "enum": [
            "pending",
            "running",
            "failed",
            "timeout",
            "cancelled",
            "success"
          ]
        },
        "startedAt": {
          "type": "string",
          "format": "datetime"
        },
        "finishedAt": {
          "type": "string",
          "format": "datetime"
        }
      }
    }
  }
}
