packages feed

heni-0.1.0.0: schemas/manifest-v1.schema.json

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/shinzui/heni/master/schemas/manifest-v1.schema.json",
  "title": "Heni manifest v1",
  "type": "object",
  "properties": {
    "schemaVersion": {
      "const": 1
    },
    "sourceRoot": {
      "type": "string",
      "minLength": 1,
      "pattern": "^(?!/)[^\\u0000]+$",
      "default": "."
    },
    "sourcePolicy": {
      "type": "object",
      "properties": {
        "includes": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "pattern": "^(?!/)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*//)(?!.*/$)(?!.*[\\\\:\\u0000]).+$"
          },
          "default": []
        },
        "excludes": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "pattern": "^(?!/)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*//)(?!.*/$)(?!.*[\\\\:\\u0000]).+$"
          },
          "default": []
        }
      },
      "required": [],
      "additionalProperties": false
    },
    "commands": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[A-Za-z0-9_.-]+$"
      },
      "additionalProperties": {
        "$ref": "#/$defs/command"
      }
    },
    "cases": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/case"
      },
      "minItems": 1
    },
    "resources": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/resource"
      },
      "default": []
    },
    "execution": {
      "type": "object",
      "properties": {
        "workers": {
          "type": "integer",
          "minimum": 1,
          "maximum": 256,
          "default": 1
        },
        "baselineReuse": {
          "anyOf": [
            {
              "type": "null"
            },
            {
              "type": "object",
              "properties": {
                "toolchain": {
                  "type": "string",
                  "pattern": "\\S"
                },
                "adapter": {
                  "anyOf": [
                    {
                      "type": "string",
                      "pattern": "\\S"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "toolchain"
              ],
              "additionalProperties": false
            }
          ]
        }
      },
      "additionalProperties": false
    }
  },
  "required": [
    "schemaVersion",
    "commands",
    "cases"
  ],
  "additionalProperties": false,
  "$defs": {
    "command": {
      "type": "object",
      "properties": {
        "executable": {
          "type": "string",
          "minLength": 1
        },
        "arguments": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "default": []
        },
        "sensitiveArguments": {
          "type": "array",
          "items": {
            "type": "integer",
            "minimum": 0
          },
          "uniqueItems": true,
          "default": []
        },
        "workingDirectory": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "pattern": "^(?!/)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*//)(?!.*/$)(?!.*[\\\\:\\u0000]).+$"
            },
            {
              "type": "null"
            }
          ]
        },
        "environment": {
          "type": "object",
          "propertyNames": {
            "pattern": "^[^=\\u0000]+$"
          },
          "additionalProperties": {
            "type": "string"
          },
          "default": {}
        },
        "timeoutSeconds": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 86400,
          "default": 30
        },
        "outputLimitBytes": {
          "type": "integer",
          "minimum": 1,
          "default": 1048576
        }
      },
      "required": [
        "executable"
      ],
      "additionalProperties": false
    },
    "edit": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "replace"
            },
            "path": {
              "type": "string",
              "minLength": 1,
              "pattern": "^(?!/)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*//)(?!.*/$)(?!.*[\\\\:\\u0000]).+$"
            },
            "old": {
              "type": "string",
              "minLength": 1
            },
            "new": {
              "type": "string"
            },
            "occurrences": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          "required": [
            "kind",
            "path",
            "old",
            "new"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "create"
            },
            "path": {
              "type": "string",
              "minLength": 1,
              "pattern": "^(?!/)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*//)(?!.*/$)(?!.*[\\\\:\\u0000]).+$"
            },
            "content": {
              "type": "string"
            }
          },
          "required": [
            "kind",
            "path",
            "content"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "delete"
            },
            "path": {
              "type": "string",
              "minLength": 1,
              "pattern": "^(?!/)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*//)(?!.*/$)(?!.*[\\\\:\\u0000]).+$"
            },
            "expected": {
              "type": "string"
            }
          },
          "required": [
            "kind",
            "path",
            "expected"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "patch"
            },
            "content": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "kind",
            "content"
          ],
          "additionalProperties": false
        }
      ]
    },
    "expectation": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "diagnostic"
            },
            "stage": {
              "enum": [
                "build",
                "test"
              ]
            },
            "exitCode": {
              "type": "integer",
              "minimum": 1
            },
            "outputContains": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "kind",
            "stage",
            "exitCode",
            "outputContains"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "build-rejection"
            },
            "exitCode": {
              "type": "integer",
              "minimum": 1
            },
            "outputContains": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "kind",
            "exitCode",
            "outputContains"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "control"
            }
          },
          "required": [
            "kind"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "named-tests"
            },
            "failures": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              },
              "uniqueItems": true,
              "minItems": 1
            },
            "replayRequired": {
              "type": "boolean",
              "default": false
            }
          },
          "required": [
            "kind",
            "failures"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "crash"
            },
            "signal": {
              "type": "integer",
              "minimum": 1
            },
            "probe": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "kind",
            "signal",
            "probe"
          ],
          "additionalProperties": false
        }
      ]
    },
    "case": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_.-]+$"
        },
        "description": {
          "type": "string",
          "pattern": "\\S"
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true,
          "default": []
        },
        "edits": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/edit"
          },
          "default": []
        },
        "build": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_.-]+$"
        },
        "test": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.-]+$"
            },
            {
              "type": "null"
            }
          ]
        },
        "selector": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "\\S"
            },
            {
              "type": "null"
            }
          ]
        },
        "expect": {
          "$ref": "#/$defs/expectation"
        },
        "adapter": {
          "enum": [
            null,
            "heni-v1"
          ]
        },
        "resources": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_]*$"
          },
          "uniqueItems": true,
          "default": []
        }
      },
      "required": [
        "id",
        "description",
        "build",
        "expect"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "expect": {
                "properties": {
                  "kind": {
                    "const": "control"
                  }
                }
              }
            }
          },
          "then": {
            "properties": {
              "edits": {
                "maxItems": 0
              },
              "test": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_.-]+$"
              }
            },
            "required": [
              "test"
            ]
          },
          "else": {
            "required": [
              "edits"
            ],
            "properties": {
              "edits": {
                "minItems": 1
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "expect": {
                "properties": {
                  "kind": {
                    "const": "diagnostic"
                  },
                  "stage": {
                    "const": "test"
                  }
                },
                "required": [
                  "stage"
                ]
              }
            }
          },
          "then": {
            "required": [
              "test"
            ],
            "properties": {
              "test": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_.-]+$"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "expect": {
                "properties": {
                  "kind": {
                    "enum": [
                      "named-tests",
                      "crash"
                    ]
                  }
                }
              }
            }
          },
          "then": {
            "required": [
              "test"
            ],
            "properties": {
              "test": {
                "type": "string"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "expect": {
                "properties": {
                  "kind": {
                    "const": "named-tests"
                  }
                }
              }
            }
          },
          "then": {
            "required": [
              "adapter"
            ],
            "properties": {
              "adapter": {
                "const": "heni-v1"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "expect": {
                "properties": {
                  "kind": {
                    "const": "crash"
                  }
                }
              }
            }
          },
          "then": {
            "properties": {
              "adapter": {
                "type": "null"
              }
            }
          }
        }
      ]
    },
    "resource": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[A-Z][A-Z0-9_]*$"
        },
        "scope": {
          "enum": [
            "campaign",
            "worker",
            "case"
          ],
          "default": "case"
        },
        "capacity": {
          "type": "integer",
          "minimum": 1,
          "default": 1
        },
        "identity": {
          "type": "string",
          "minLength": 1
        },
        "version": {
          "type": "string",
          "minLength": 1
        },
        "epoch": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "environment": {
          "type": "object",
          "propertyNames": {
            "pattern": "^HENI_RESOURCE_[A-Z][A-Z0-9_]*_[^=\\u0000]*$"
          },
          "additionalProperties": {
            "type": "string"
          },
          "default": {}
        },
        "setup": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_.-]+$"
        },
        "reset": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_.-]+$"
        },
        "teardown": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_.-]+$"
        }
      },
      "required": [
        "name",
        "identity",
        "version",
        "setup",
        "reset",
        "teardown"
      ],
      "additionalProperties": false
    }
  }
}