{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://totktonada.online/tarantool/ci/causes.schema.json",
 "title": "Tarantool CI statistics: why the jobs failed",
 "description": "The data of https://totktonada.online/tarantool/ci/causes: the failed jobs of tarantool/tarantool's CI by cause, by week and by day.",
 "type": "object",
 "required": [
  "$schema",
  "page",
  "crawled",
  "generated",
  "scope",
  "weeks",
  "days",
  "classifiers"
 ],
 "additionalProperties": false,
 "properties": {
  "$schema": {
   "type": "string",
   "format": "uri",
   "description": "This schema."
  },
  "page": {
   "type": "string",
   "format": "uri",
   "description": "The page this is the data of."
  },
  "crawled": {
   "anyOf": [
    {
     "$ref": "#/$defs/time"
    },
    {
     "type": "null"
    }
   ],
   "description": "When the crawl the data comes from ended."
  },
  "generated": {
   "$ref": "#/$defs/time",
   "description": "When the page was built."
  },
  "scope": {
   "type": "object",
   "required": [
    "failed_jobs",
    "counted",
    "on_master_or_release",
    "passed_on_rerun",
    "left_out"
   ],
   "additionalProperties": false,
   "properties": {
    "failed_jobs": {
     "type": "integer",
     "minimum": 0,
     "description": "Every failed job whose log the store holds."
    },
    "counted": {
     "type": "integer",
     "minimum": 0,
     "description": "The ones counted here, the next two together."
    },
    "on_master_or_release": {
     "type": "integer",
     "minimum": 0,
     "description": "Every failed job of master and the release branches."
    },
    "passed_on_rerun": {
     "type": "integer",
     "minimum": 0,
     "description": "Elsewhere, on a developer branch or a pull request, a job that failed and then passed on a re-run of the same commit."
    },
    "left_out": {
     "type": "integer",
     "minimum": 0,
     "description": "The rest: a developer branch or pull request that never went green."
    }
   },
   "description": "Which failed jobs are counted."
  },
  "weeks": {
   "$ref": "#/$defs/period",
   "description": "Spans of seven days back from the end of the last crawl, to the second, the oldest first."
  },
  "days": {
   "anyOf": [
    {
     "$ref": "#/$defs/period"
    },
    {
     "type": "null"
    }
   ],
   "description": "Spans of one day back from the end of the last crawl, to the second, the oldest first. The last seven."
  },
  "classifiers": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "cause",
     "code"
    ],
    "additionalProperties": false,
    "properties": {
     "cause": {
      "type": "string",
      "description": "The name it gives."
     },
     "code": {
      "type": "string",
      "description": "Its source, Python, as causes.py has it."
     }
    }
   },
   "description": "How a failure gets its cause: the signatures a log is matched against, then the rule for the modules' and connectors' tests."
  }
 },
 "$defs": {
  "time": {
   "type": "string",
   "format": "date-time",
   "description": "ISO 8601, in UTC+3."
  },
  "sha": {
   "type": "string",
   "pattern": "^[0-9a-f]{12}$",
   "description": "A commit of tarantool/tarantool: the first 12 digits of its hash."
  },
  "period": {
   "type": "object",
   "required": [
    "spans",
    "causes"
   ],
   "additionalProperties": false,
   "properties": {
    "spans": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/span"
     },
     "description": "The columns."
    },
    "causes": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/cause"
     },
     "description": "A row per cause, the largest share of the newest span first; each array in it has a number per span."
    }
   }
  },
  "span": {
   "type": "object",
   "required": [
    "label",
    "from",
    "to",
    "failed",
    "jobs_run"
   ],
   "additionalProperties": false,
   "properties": {
    "label": {
     "type": "string",
     "description": "The column's heading: 'Oct 19-26' for a week, 'Mon 19' for a day."
    },
    "from": {
     "$ref": "#/$defs/time",
     "description": "The start, not included."
    },
    "to": {
     "$ref": "#/$defs/time",
     "description": "The end, included."
    },
    "failed": {
     "type": "integer",
     "minimum": 0,
     "description": "The failed jobs counted in it."
    },
    "jobs_run": {
     "type": "integer",
     "minimum": 0,
     "description": "The jobs that ran in it to a verdict."
    }
   }
  },
  "cause": {
   "type": "object",
   "required": [
    "cause",
    "failed",
    "per_1000_jobs_run"
   ],
   "additionalProperties": false,
   "properties": {
    "cause": {
     "type": "string",
     "description": "A signature's name, 'module or connector tests failed', or 'unexplained'."
    },
    "failed": {
     "type": "array",
     "items": {
      "type": "integer",
      "minimum": 0
     },
     "description": "The failed jobs that show it; a job re-run and failing again counts each time."
    },
    "per_1000_jobs_run": {
     "type": "array",
     "items": {
      "type": "number",
      "minimum": 0
     },
     "description": "The same per thousand jobs that ran, to one decimal."
    }
   }
  }
 }
}
