Module: Henitai::ConfigurationValidator::Rules
- Defined in:
- lib/henitai/configuration_validator/rules.rb,
sig/configuration_validator.rbs
Overview
Class Method Summary collapse
- .configuration_error(message) ⇒ Object
- .ensure_hash!(value, path) ⇒ Object
- .key_path(path, key) ⇒ Object
- .validate_all_logs(raw) ⇒ Object
- .validate_coverage_criteria(raw) ⇒ Object
- .validate_dashboard(raw) ⇒ Object
- .validate_excludes(raw) ⇒ Object
- .validate_includes(raw) ⇒ Object
- .validate_integration(raw) ⇒ Object
- .validate_jobs(raw) ⇒ Object
- .validate_mutation(raw) ⇒ Object
- .validate_mutation_filters(value) ⇒ Object
- .validate_mutation_limits(value) ⇒ Object
- .validate_reporters(raw) ⇒ Object
- .validate_reports(raw) ⇒ Object
- .validate_reports_dir(raw) ⇒ Object
- .validate_sampling(value) ⇒ Object
- .validate_test_excludes(raw) ⇒ Object
- .validate_thresholds(raw) ⇒ Object
- .validate_top_level_keys(raw) ⇒ Object
- .warn_unknown_keys(raw, allowed_keys, path = nil) ⇒ Object
Instance Method Summary collapse
- #self?.configuration_error ⇒ void
- #self?.ensure_hash! ⇒ void
- #self?.key_path ⇒ String
- #self?.validate_all_logs ⇒ void
- #self?.validate_coverage_criteria ⇒ void
- #self?.validate_dashboard ⇒ void
- #self?.validate_excludes ⇒ void
- #self?.validate_includes ⇒ void
- #self?.validate_integration ⇒ void
- #self?.validate_jobs ⇒ void
- #self?.validate_mutation ⇒ void
- #self?.validate_mutation_filters ⇒ void
- #self?.validate_mutation_limits ⇒ void
- #self?.validate_reporters ⇒ void
- #self?.validate_reports_dir ⇒ void
- #self?.validate_sampling ⇒ void
- #self?.validate_thresholds ⇒ void
- #self?.validate_top_level_keys ⇒ void
- #self?.warn_unknown_keys ⇒ void
Class Method Details
.configuration_error(message) ⇒ Object
156 157 158 |
# File 'lib/henitai/configuration_validator/rules.rb', line 156 def configuration_error() raise Henitai::ConfigurationError, end |
.ensure_hash!(value, path) ⇒ Object
150 151 152 153 154 |
# File 'lib/henitai/configuration_validator/rules.rb', line 150 def ensure_hash!(value, path) return if value.is_a?(Hash) configuration_error("Invalid configuration value for #{path}: expected Hash, got #{value.class}") end |
.key_path(path, key) ⇒ Object
146 147 148 |
# File 'lib/henitai/configuration_validator/rules.rb', line 146 def key_path(path, key) path ? "#{path}.#{key}" : key.to_s end |
.validate_all_logs(raw) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/henitai/configuration_validator/rules.rb', line 68 def validate_all_logs(raw) value = raw[:all_logs] return if value.nil? Scalars.validate_boolean(value, "all_logs") end |
.validate_coverage_criteria(raw) ⇒ Object
110 111 112 113 114 115 116 117 |
# File 'lib/henitai/configuration_validator/rules.rb', line 110 def validate_coverage_criteria(raw) value = raw[:coverage_criteria] return if value.nil? ensure_hash!(value, "coverage_criteria") warn_unknown_keys(value, VALID_COVERAGE_CRITERIA_KEYS, "coverage_criteria") value.each { |key, flag| Scalars.validate_boolean(flag, "coverage_criteria.#{key}") } end |
.validate_dashboard(raw) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/henitai/configuration_validator/rules.rb', line 75 def validate_dashboard(raw) value = raw[:dashboard] return if value.nil? ensure_hash!(value, "dashboard") warn_unknown_keys(value, VALID_DASHBOARD_KEYS, "dashboard") Scalars.validate_optional_string(value[:project], "dashboard.project") Scalars.validate_optional_string(value[:base_url], "dashboard.base_url") end |
.validate_excludes(raw) ⇒ Object
33 34 35 |
# File 'lib/henitai/configuration_validator/rules.rb', line 33 def validate_excludes(raw) Scalars.validate_string_array(raw[:excludes], "excludes") end |
.validate_includes(raw) ⇒ Object
29 30 31 |
# File 'lib/henitai/configuration_validator/rules.rb', line 29 def validate_includes(raw) Scalars.validate_string_array(raw[:includes], "includes") end |
.validate_integration(raw) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/henitai/configuration_validator/rules.rb', line 19 def validate_integration(raw) value = raw[:integration] return if value.nil? return if value.is_a?(String) ensure_hash!(value, "integration") warn_unknown_keys(value, VALID_INTEGRATION_KEYS, "integration") Scalars.validate_optional_string(value[:name], "integration.name") end |
.validate_jobs(raw) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/henitai/configuration_validator/rules.rb', line 41 def validate_jobs(raw) value = raw[:jobs] return if value.nil? return if value.is_a?(Integer) configuration_error("Invalid configuration value for jobs: expected Integer, got #{value.class}") end |
.validate_mutation(raw) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/henitai/configuration_validator/rules.rb', line 85 def validate_mutation(raw) value = raw[:mutation] return if value.nil? ensure_hash!(value, "mutation") warn_unknown_keys(value, VALID_MUTATION_KEYS, "mutation") Scalars.validate_operator(value[:operators]) validate_mutation_limits(value) validate_mutation_filters(value) validate_sampling(value[:sampling]) end |
.validate_mutation_filters(value) ⇒ Object
105 106 107 108 |
# File 'lib/henitai/configuration_validator/rules.rb', line 105 def validate_mutation_filters(value) Scalars.validate_string_array(value[:ignore_patterns], "mutation.ignore_patterns") Scalars.validate_ignore_patterns(value[:ignore_patterns]) end |
.validate_mutation_limits(value) ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/henitai/configuration_validator/rules.rb', line 97 def validate_mutation_limits(value) Scalars.validate_timeout(value[:timeout]) Scalars.validate_timeout_multiplier(value[:timeout_multiplier]) Scalars.validate_max_flaky_retries(value[:max_flaky_retries]) Scalars.validate_max_log_bytes(value[:max_log_bytes]) Scalars.validate_max_timeout(value[:max_timeout]) end |
.validate_reporters(raw) ⇒ Object
49 50 51 |
# File 'lib/henitai/configuration_validator/rules.rb', line 49 def validate_reporters(raw) Scalars.validate_string_array(raw[:reporters], "reporters") end |
.validate_reports(raw) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/henitai/configuration_validator/rules.rb', line 57 def validate_reports(raw) value = raw[:reports] return if value.nil? ensure_hash!(value, "reports") warn_unknown_keys(value, VALID_REPORTS_KEYS, "reports") Scalars.validate_boolean(value[:checkpoint], "reports.checkpoint") unless value[:checkpoint].nil? Scalars.validate_checkpoint_every(value[:checkpoint_every]) Scalars.validate_checkpoint_interval(value[:checkpoint_interval]) end |
.validate_reports_dir(raw) ⇒ Object
53 54 55 |
# File 'lib/henitai/configuration_validator/rules.rb', line 53 def validate_reports_dir(raw) Scalars.validate_optional_string(raw[:reports_dir], "reports_dir") end |
.validate_sampling(value) ⇒ Object
128 129 130 131 132 133 134 135 136 |
# File 'lib/henitai/configuration_validator/rules.rb', line 128 def validate_sampling(value) return if value.nil? ensure_hash!(value, "mutation.sampling") warn_unknown_keys(value, VALID_SAMPLING_KEYS, "mutation.sampling") Scalars.validate_sampling_completeness(value) Scalars.validate_sampling_ratio(value[:ratio]) Scalars.validate_sampling_strategy(value[:strategy]) end |
.validate_test_excludes(raw) ⇒ Object
37 38 39 |
# File 'lib/henitai/configuration_validator/rules.rb', line 37 def validate_test_excludes(raw) Scalars.validate_string_array(raw[:test_excludes], "test_excludes") end |
.validate_thresholds(raw) ⇒ Object
119 120 121 122 123 124 125 126 |
# File 'lib/henitai/configuration_validator/rules.rb', line 119 def validate_thresholds(raw) value = raw[:thresholds] return if value.nil? ensure_hash!(value, "thresholds") warn_unknown_keys(value, VALID_THRESHOLDS_KEYS, "thresholds") value.each { |key, threshold| Scalars.validate_threshold(threshold, "thresholds.#{key}") } end |
.validate_top_level_keys(raw) ⇒ Object
15 16 17 |
# File 'lib/henitai/configuration_validator/rules.rb', line 15 def validate_top_level_keys(raw) warn_unknown_keys(raw, VALID_TOP_LEVEL_KEYS) end |
.warn_unknown_keys(raw, allowed_keys, path = nil) ⇒ Object
138 139 140 141 142 143 144 |
# File 'lib/henitai/configuration_validator/rules.rb', line 138 def warn_unknown_keys(raw, allowed_keys, path = nil) raw.each_key do |key| next if allowed_keys.include?(key) ConfigurationValidator.warn "Unknown configuration key: #{key_path(path, key)}" end end |
Instance Method Details
#self?.configuration_error ⇒ void
This method returns an undefined value.
35 |
# File 'sig/configuration_validator.rbs', line 35
def self?.configuration_error: (String) -> void
|
#self?.ensure_hash! ⇒ void
This method returns an undefined value.
34 |
# File 'sig/configuration_validator.rbs', line 34
def self?.ensure_hash!: (untyped, String) -> void
|
#self?.key_path ⇒ String
33 |
# File 'sig/configuration_validator.rbs', line 33
def self?.key_path: (String?, Symbol) -> String
|
#self?.validate_all_logs ⇒ void
This method returns an undefined value.
24 |
# File 'sig/configuration_validator.rbs', line 24
def self?.validate_all_logs: (Hash[Symbol, untyped]) -> void
|
#self?.validate_coverage_criteria ⇒ void
This method returns an undefined value.
29 |
# File 'sig/configuration_validator.rbs', line 29
def self?.validate_coverage_criteria: (Hash[Symbol, untyped]) -> void
|
#self?.validate_dashboard ⇒ void
This method returns an undefined value.
25 |
# File 'sig/configuration_validator.rbs', line 25
def self?.validate_dashboard: (Hash[Symbol, untyped]) -> void
|
#self?.validate_excludes ⇒ void
This method returns an undefined value.
20 |
# File 'sig/configuration_validator.rbs', line 20
def self?.validate_excludes: (Hash[Symbol, untyped]) -> void
|
#self?.validate_includes ⇒ void
This method returns an undefined value.
19 |
# File 'sig/configuration_validator.rbs', line 19
def self?.validate_includes: (Hash[Symbol, untyped]) -> void
|
#self?.validate_integration ⇒ void
This method returns an undefined value.
18 |
# File 'sig/configuration_validator.rbs', line 18
def self?.validate_integration: (Hash[Symbol, untyped]) -> void
|
#self?.validate_jobs ⇒ void
This method returns an undefined value.
21 |
# File 'sig/configuration_validator.rbs', line 21
def self?.validate_jobs: (Hash[Symbol, untyped]) -> void
|
#self?.validate_mutation ⇒ void
This method returns an undefined value.
26 |
# File 'sig/configuration_validator.rbs', line 26
def self?.validate_mutation: (Hash[Symbol, untyped]) -> void
|
#self?.validate_mutation_filters ⇒ void
This method returns an undefined value.
28 |
# File 'sig/configuration_validator.rbs', line 28
def self?.validate_mutation_filters: (Hash[Symbol, untyped]) -> void
|
#self?.validate_mutation_limits ⇒ void
This method returns an undefined value.
27 |
# File 'sig/configuration_validator.rbs', line 27
def self?.validate_mutation_limits: (Hash[Symbol, untyped]) -> void
|
#self?.validate_reporters ⇒ void
This method returns an undefined value.
22 |
# File 'sig/configuration_validator.rbs', line 22
def self?.validate_reporters: (Hash[Symbol, untyped]) -> void
|
#self?.validate_reports_dir ⇒ void
This method returns an undefined value.
23 |
# File 'sig/configuration_validator.rbs', line 23
def self?.validate_reports_dir: (Hash[Symbol, untyped]) -> void
|
#self?.validate_sampling ⇒ void
This method returns an undefined value.
31 |
# File 'sig/configuration_validator.rbs', line 31
def self?.validate_sampling: (untyped) -> void
|
#self?.validate_thresholds ⇒ void
This method returns an undefined value.
30 |
# File 'sig/configuration_validator.rbs', line 30
def self?.validate_thresholds: (Hash[Symbol, untyped]) -> void
|
#self?.validate_top_level_keys ⇒ void
This method returns an undefined value.
17 |
# File 'sig/configuration_validator.rbs', line 17
def self?.validate_top_level_keys: (Hash[Symbol, untyped]) -> void
|
#self?.warn_unknown_keys ⇒ void
This method returns an undefined value.
32 |
# File 'sig/configuration_validator.rbs', line 32
def self?.warn_unknown_keys: (Hash[Symbol, untyped], Array[Symbol], ?String?) -> void
|