Skip to content

Workflow schema

The Workflow schema describes workflows as received by the Receptionist service.

They can be provided as JSON or YAML files.

{
    "$schema": "https://json-schema.org/draft/2019-09/schema#",
    "title": "JSON SCHEMA for Workflow manifests",
    "description": "An Orchestrator Workflow.  Must have a name and at least one job.",
    "type": "object",
    "properties": {
        "apiVersion": {
            "enum": "opentestfactory.org/v1beta1"
        },
        "kind": {
            "const": "Workflow"
        },
        "metadata": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                },
                "namespace": {
                    "type": "string",
                    "pattern": "^[a-z0-9][a-z0-9-]*$"
                },
                "labels": {
                    "type": "object",
                    "patternProperties": {
                        "^([a-zA-Z0-9-.]+/)?[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$": {
                            "type": "string"
                        }
                    },
                    "minProperties": 1,
                    "additionalProperties": false
                }
            },
            "additionalProperties": true,
            "required": [
                "name"
            ]
        },
        "defaults": {
            "$ref": "#/definitions/defaults"
        },
        "variables": {
            "$ref": "#/definitions/variables"
        },
        "secrets": {
            "$ref": "#/definitions/secrets"
        },
        "hooks": {
            "type": "array",
            "minItems": 1,
            "items": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "if": {
                        "type": "string"
                    },
                    "events": {
                        "type": "array",
                        "minItems": 1
                    },
                    "before": {
                        "type": "array",
                        "minItems": 1
                    },
                    "after": {
                        "type": "array",
                        "minItems": 1
                    }
                },
                "anyOf": [
                    {
                        "required": [
                            "name",
                            "events",
                            "before"
                        ]
                    },
                    {
                        "required": [
                            "name",
                            "events",
                            "after",
                            "before"
                        ]
                    },
                    {
                        "required": [
                            "name",
                            "events",
                            "after"
                        ]
                    }
                ],
                "additionalProperties": false
            }
        },
        "resources": {
            "type": "object",
            "properties": {
                "testmanagers": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "testmanager": {
                                "type": "string"
                            },
                            "type": {
                                "type": "string"
                            },
                            "name": {
                                "type": "string"
                            },
                            "endpoint": {
                                "type": "string"
                            }
                        },
                        "required": [
                            "testmanager",
                            "type",
                            "name",
                            "endpoint"
                        ]
                    }
                },
                "repositories": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "repository": {
                                "type": "string"
                            },
                            "type": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9]*$"
                            },
                            "name": {
                                "type": "string"
                            },
                            "endpoint": {
                                "type": "string"
                            }
                        },
                        "required": [
                            "repository",
                            "type",
                            "name",
                            "endpoint"
                        ]
                    }
                },
                "files": {
                    "type": "array",
                    "items": {
                        "anyOf": [
                            {
                                "type": "string"
                            },
                            {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    },
                                    "url": {
                                        "type": "string"
                                    }
                                }
                            }
                        ]
                    }
                }
            }
        },
        "jobs": {
            "type": "object",
            "patternProperties": {
                "^[a-zA-Z_][a-zA-Z0-9_-]*$": {
                    "oneOf": [
                        {
                            "$ref": "#/definitions/job_generator"
                        },
                        {
                            "$ref": "#/definitions/job_steps"
                        }
                    ]
                }
            },
            "minProperties": 1
        }
    },
    "required": [
        "metadata",
        "jobs"
    ],
    "additionalProperties": false,
    "definitions": {
        "defaults": {
            "type": "object",
            "propertyNames": {
                "pattern": "^[a-zA-Z][a-zA-Z0-9-]*$"
            }
        },
        "job_generator": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                },
                "if": {
                    "type": "string"
                },
                "needs": {
                    "$ref": "#/definitions/needs"
                },
                "variables": {
                    "$ref": "#/definitions/variables"
                },
                "defaults": {
                    "$ref": "#/definitions/defaults"
                },
                "runs-on": {
                    "$ref": "#/definitions/runs-on"
                },
                "strategy": {
                    "type": "object"
                },
                "outputs": {
                    "type": "object"
                },
                "timeout-minutes": {
                    "type": "number"
                },
                "continue-on-error": {
                    "$ref": "#/definitions/continue-on-error"
                },
                "generator": {
                    "type": "string"
                },
                "with": {
                    "type": "object"
                }
            },
            "required": [
                "generator"
            ],
            "additionalProperties": false
        },
        "job_steps": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                },
                "if": {
                    "type": "string"
                },
                "needs": {
                    "$ref": "#/definitions/needs"
                },
                "variables": {
                    "$ref": "#/definitions/variables"
                },
                "defaults": {
                    "$ref": "#/definitions/defaults"
                },
                "runs-on": {
                    "$ref": "#/definitions/runs-on"
                },
                "strategy": {
                    "type": "object"
                },
                "outputs": {
                    "type": "object"
                },
                "timeout-minutes": {
                    "type": "number"
                },
                "continue-on-error": {
                    "$ref": "#/definitions/continue-on-error"
                },
                "steps": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                        "anyOf": [
                            {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    },
                                    "id": {
                                        "type": "string"
                                    },
                                    "if": {
                                        "type": "string"
                                    },
                                    "uses": {
                                        "type": "string"
                                    },
                                    "with": {
                                        "type": "object"
                                    },
                                    "variables": {
                                        "$ref": "#/definitions/variables"
                                    },
                                    "timeout-minutes": {
                                        "type": "number"
                                    },
                                    "continue-on-error": {
                                        "$ref": "#/definitions/continue-on-error"
                                    },
                                    "working-directory": {
                                        "type": "string"
                                    }
                                },
                                "required": [
                                    "uses"
                                ],
                                "additionalProperties": false
                            },
                            {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    },
                                    "id": {
                                        "type": "string"
                                    },
                                    "if": {
                                        "type": "string"
                                    },
                                    "run": {
                                        "type": "string"
                                    },
                                    "shell": {
                                        "type": "string"
                                    },
                                    "variables": {
                                        "$ref": "#/definitions/variables"
                                    },
                                    "timeout-minutes": {
                                        "type": "number"
                                    },
                                    "continue-on-error": {
                                        "$ref": "#/definitions/continue-on-error"
                                    },
                                    "working-directory": {
                                        "type": "string"
                                    }
                                },
                                "required": [
                                    "run"
                                ],
                                "additionalProperties": false
                            }
                        ]
                    }
                }
            },
            "required": [
                "steps"
            ],
            "additionalProperties": false
        },
        "needs": {
            "anyOf": [
                {
                    "type": "string",
                    "pattern": "^[a-zA-Z_][a-zA-Z0-9_-]*$"
                },
                {
                    "type": "array",
                    "items": {
                        "type": "string",
                        "pattern": "^[a-zA-Z_][a-zA-Z0-9_-]*$"
                    }
                }
            ]
        },
        "continue-on-error": {
            "anyOf": [
                {
                    "type": "boolean"
                },
                {
                    "type": "string",
                    "pattern": "^${{.*}}$"
                }
            ]
        },
        "runs-on": {
            "anyOf": [
                {
                    "type": "string",
                    "pattern": "^[a-zA-Z][a-zA-Z0-9-]*$"
                },
                {
                    "type": "array",
                    "items": {
                        "type": "string",
                        "pattern": "^[a-zA-Z][a-zA-Z0-9-]*$"
                    },
                    "minItems": 1
                },
                {
                    "type": "object"
                }
            ]
        },
        "variables": {
            "type": "object",
            "patternProperties": {
                "^[a-zA-Z0-9_]+$": {
                    "oneOf": [
                        {
                            "type": "string"
                        },
                        {
                            "type": "object",
                            "properties": {
                                "value": {
                                    "type": "string"
                                },
                                "verbatim": {
                                    "type": "boolean"
                                }
                            },
                            "required": [
                                "value"
                            ],
                            "additionalProperties": false
                        }
                    ]
                }
            },
            "minProperties": 1
        },
        "secrets": {
            "type": "object",
            "patternProperties": {
                "^[a-zA-Z0-9_]+$": {
                    "type": "string"
                }
            },
            "minProperties": 1
        }
    }
}