<commit_before>(ns runbld.schema
  (:require [schema.core :as s]
            [runbld.scheduler :refer [Scheduler]]
            [runbld.schema.mapping :as m])
  (:import (elasticsearch.connection Connection)))

(def DocType :t)

(def VersionInfo
  {:string s/Str
   :hash   s/Str})

(def Env
  {s/Keyword s/Str})

(def JavaProperties
  {:home     s/Str
   :vendor   s/Str
   :version  s/Str
   :class
   {:path    s/Str}
   :runtime
   {:name    s/Str
    :version s/Str}
   :vm
   {:info    s/Str
    :name    s/Str
    :vendor  s/Str
    :version s/Str}})

(def OptsEmail
  {:from               s/Str
   :host               s/Str
   :max-failure-notify s/Num
   :pass               s/Str
   :port               (s/cond-pre s/Num s/Str)
   :template-html      (s/cond-pre s/Str java.io.File)
   :template-txt       (s/cond-pre s/Str java.io.File)
   :text-only          s/Bool
   :tls                s/Bool
   :to                 (s/cond-pre s/Str [s/Str])
   :user               s/Str
   :disable            s/Bool})

(def OptsSlack
  ;; hook is optional because the other values have defaults
  {(s/optional-key :hook) (s/cond-pre s/Str [s/Str])
   :first-success      s/Bool
   :success            s/Bool
   :failure            s/Bool
   :template           (s/cond-pre s/Str java.io.File)
   :disable            s/Bool})

(def OptsProcess
  {:program           s/Str
   :args              [s/Str]
   :cwd               s/Str
   :scriptfile        s/Str
   :inherit-exit-code s/Bool
   :inherit-env       s/Bool
   :stdout            s/Str
   :stderr            s/Str
   :output            s/Str
   :env               Env})

(def OptsElasticsearch
  {:build-index          s/Str
   :build-index-search   s/Str
   :build-index-write    s/Str
   :failure-index        s/Str
   :failure-index-search s/Str
   :failure-index-write  s/Str
   :log-index            s/Str
   :log-index-search     s/Str
   :log-index-write      s/Str
   :max-index-bytes      s/Num
   :bulk-timeout-ms      s/Num
   :bulk-size            s/Num
   :conn                 Connection
   (s/optional-key :http-opts) {s/Keyword s/Any}
   (s/optional-key :url)       s/Str})

(def OptsS3
  {:access-key s/Str
   :secret-key s/Str
   :bucket     s/Str
   :prefix     s/Str})

(def OptsScm
  {:clone s/Bool
   :url s/Str
   :reference-repo s/Str})

(def Opts
  {:job-name   s/Str
   (s/optional-key :last-good-commit) s/Str
   (s/optional-key :scm) OptsScm
   :version    VersionInfo
   :configfile (s/maybe s/Str)
   :email      OptsEmail
   (s/optional-key :slack) OptsSlack
   :es         OptsElasticsearch
   :process    OptsProcess
   :s3         OptsS3
   :java       JavaProperties
   :env        Env})

(def BuildSystem<commit_msg>Make `reference-repo` an optional setting.<commit_after>(ns runbld.schema
  (:require [schema.core :as s]
            [runbld.scheduler :refer [Scheduler]]
            [runbld.schema.mapping :as m])
  (:import (elasticsearch.connection Connection)))

(def DocType :t)

(def VersionInfo
  {:string s/Str
   :hash   s/Str})

(def Env
  {s/Keyword s/Str})

(def JavaProperties
  {:home     s/Str
   :vendor   s/Str
   :version  s/Str
   :class
   {:path    s/Str}
   :runtime
   {:name    s/Str
    :version s/Str}
   :vm
   {:info    s/Str
    :name    s/Str
    :vendor  s/Str
    :version s/Str}})

(def OptsEmail
  {:from               s/Str
   :host               s/Str
   :max-failure-notify s/Num
   :pass               s/Str
   :port               (s/cond-pre s/Num s/Str)
   :template-html      (s/cond-pre s/Str java.io.File)
   :template-txt       (s/cond-pre s/Str java.io.File)
   :text-only          s/Bool
   :tls                s/Bool
   :to                 (s/cond-pre s/Str [s/Str])
   :user               s/Str
   :disable            s/Bool})

(def OptsSlack
  ;; hook is optional because the other values have defaults
  {(s/optional-key :hook) (s/cond-pre s/Str [s/Str])
   :first-success      s/Bool
   :success            s/Bool
   :failure            s/Bool
   :template           (s/cond-pre s/Str java.io.File)
   :disable            s/Bool})

(def OptsProcess
  {:program           s/Str
   :args              [s/Str]
   :cwd               s/Str
   :scriptfile        s/Str
   :inherit-exit-code s/Bool
   :inherit-env       s/Bool
   :stdout            s/Str
   :stderr            s/Str
   :output            s/Str
   :env               Env})

(def OptsElasticsearch
  {:build-index          s/Str
   :build-index-search   s/Str
   :build-index-write    s/Str
   :failure-index        s/Str
   :failure-index-search s/Str
   :failure-index-write  s/Str
   :log-index            s/Str
   :log-index-search     s/Str
   :log-index-write      s/Str
   :max-index-bytes      s/Num
   :bulk-timeout-ms      s/Num
   :bulk-size            s/Num
   :conn                 Connection
   (s/optional-key :http-opts) {s/Keyword s/Any}
   (s/optional-key :url)       s/Str})

(def OptsS3
  {:access-key s/Str
   :secret-key s/Str
   :bucket     s/Str
   :prefix     s/Str})

(def OptsScm
  {:clone s/Bool
   :url s/Str
   (s/optional-key :reference-repo) s/Str

(def Opts
  {:job-name   s/Str
   (s/optional-key :last-good-commit) s/Str
   (s/optional-key :scm) OptsScm
   :version    VersionInfo
   :configfile (s/maybe s/Str)
   :email      OptsEmail
   (s/optional-key :slack) OptsSlack
   :es         OptsElasticsearch
   :process    OptsProcess
   :s3         OptsS3
   :java       JavaProperties
   :env        Env})

(def BuildSystem
{'fraction_non_alphanumeric': 0.12156719150494324, 'fraction_numerical': 0.0010984987184181618, 'mean_word_length': 1.5456663560111836, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4119271', 'n_tokens_mistral': 1981, 'n_tokens_neox': 1982, 'n_words': 448}