polyrun 3.2.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +234 -0
- data/CODE_OF_CONDUCT.md +26 -0
- data/CONTRIBUTING.md +23 -0
- data/LICENSE +21 -0
- data/README.md +251 -0
- data/SECURITY.md +25 -0
- data/bin/polyrun +6 -0
- data/docs/QUALITY.md +82 -0
- data/docs/QUALITY_CONFIGURATION.md +95 -0
- data/docs/SETUP_PROFILE.md +139 -0
- data/lib/polyrun/benchmark/pressure/cooker.rb +191 -0
- data/lib/polyrun/benchmark/pressure/process_sample.rb +127 -0
- data/lib/polyrun/benchmark/pressure.rb +144 -0
- data/lib/polyrun/benchmark/profile.rb +191 -0
- data/lib/polyrun/benchmark/report.rb +87 -0
- data/lib/polyrun/cli/benchmark_commands.rb +66 -0
- data/lib/polyrun/cli/ci_shard_hooks.rb +129 -0
- data/lib/polyrun/cli/ci_shard_run_command.rb +177 -0
- data/lib/polyrun/cli/ci_shard_run_parse.rb +68 -0
- data/lib/polyrun/cli/config_command.rb +42 -0
- data/lib/polyrun/cli/coverage_commands.rb +150 -0
- data/lib/polyrun/cli/coverage_merge_io.rb +150 -0
- data/lib/polyrun/cli/database_commands.rb +163 -0
- data/lib/polyrun/cli/default_run.rb +144 -0
- data/lib/polyrun/cli/doctor_command.rb +94 -0
- data/lib/polyrun/cli/env_commands.rb +43 -0
- data/lib/polyrun/cli/failure_commands.rb +99 -0
- data/lib/polyrun/cli/graph_command.rb +68 -0
- data/lib/polyrun/cli/help.rb +83 -0
- data/lib/polyrun/cli/helpers.rb +162 -0
- data/lib/polyrun/cli/hooks_command.rb +97 -0
- data/lib/polyrun/cli/init_command.rb +108 -0
- data/lib/polyrun/cli/mutation_command.rb +67 -0
- data/lib/polyrun/cli/partition_diagnostics.rb +22 -0
- data/lib/polyrun/cli/plan_command.rb +184 -0
- data/lib/polyrun/cli/prepare_command.rb +70 -0
- data/lib/polyrun/cli/prepare_recipe.rb +82 -0
- data/lib/polyrun/cli/quality_commands.rb +65 -0
- data/lib/polyrun/cli/queue_command.rb +161 -0
- data/lib/polyrun/cli/quick_command.rb +13 -0
- data/lib/polyrun/cli/report_commands.rb +108 -0
- data/lib/polyrun/cli/run_queue_command.rb +127 -0
- data/lib/polyrun/cli/run_shards_command.rb +164 -0
- data/lib/polyrun/cli/run_shards_parallel_children.rb +112 -0
- data/lib/polyrun/cli/run_shards_parallel_wait.rb +252 -0
- data/lib/polyrun/cli/run_shards_plan_boot_phases.rb +207 -0
- data/lib/polyrun/cli/run_shards_plan_options.rb +74 -0
- data/lib/polyrun/cli/run_shards_planning.rb +123 -0
- data/lib/polyrun/cli/run_shards_run.rb +171 -0
- data/lib/polyrun/cli/run_shards_worker_interrupt.rb +101 -0
- data/lib/polyrun/cli/skip_env.rb +34 -0
- data/lib/polyrun/cli/spec_quality_commands.rb +149 -0
- data/lib/polyrun/cli/start_bootstrap.rb +126 -0
- data/lib/polyrun/cli/timing_command.rb +31 -0
- data/lib/polyrun/cli/tool_options.rb +48 -0
- data/lib/polyrun/cli/validate_command.rb +26 -0
- data/lib/polyrun/cli.rb +272 -0
- data/lib/polyrun/config/dotted_path.rb +21 -0
- data/lib/polyrun/config/effective.rb +82 -0
- data/lib/polyrun/config/resolver.rb +114 -0
- data/lib/polyrun/config/schema.rb +39 -0
- data/lib/polyrun/config/suite.rb +109 -0
- data/lib/polyrun/config/tool_defaults.rb +42 -0
- data/lib/polyrun/config/tool_validation.rb +79 -0
- data/lib/polyrun/config/tools.rb +120 -0
- data/lib/polyrun/config.rb +97 -0
- data/lib/polyrun/coverage/cobertura_zero_lines.rb +32 -0
- data/lib/polyrun/coverage/collector.rb +169 -0
- data/lib/polyrun/coverage/collector_blob.rb +53 -0
- data/lib/polyrun/coverage/collector_finish.rb +98 -0
- data/lib/polyrun/coverage/collector_fragment_meta.rb +57 -0
- data/lib/polyrun/coverage/config_resolve.rb +131 -0
- data/lib/polyrun/coverage/example_diff.rb +184 -0
- data/lib/polyrun/coverage/example_diff_snapshot.rb +44 -0
- data/lib/polyrun/coverage/example_diff_track_filter.rb +51 -0
- data/lib/polyrun/coverage/file_stats_report.rb +36 -0
- data/lib/polyrun/coverage/filter.rb +22 -0
- data/lib/polyrun/coverage/formatter.rb +137 -0
- data/lib/polyrun/coverage/merge/formatters.rb +188 -0
- data/lib/polyrun/coverage/merge/formatters_html.rb +221 -0
- data/lib/polyrun/coverage/merge/html/_file_list.html.erb +21 -0
- data/lib/polyrun/coverage/merge/html/_file_section.html.erb +26 -0
- data/lib/polyrun/coverage/merge/html/_groups_table.html.erb +18 -0
- data/lib/polyrun/coverage/merge/html/_overview.html.erb +47 -0
- data/lib/polyrun/coverage/merge/html/report.css +147 -0
- data/lib/polyrun/coverage/merge/html/report.js +48 -0
- data/lib/polyrun/coverage/merge/html/template.html.erb +30 -0
- data/lib/polyrun/coverage/merge.rb +160 -0
- data/lib/polyrun/coverage/merge_fragment_meta.rb +58 -0
- data/lib/polyrun/coverage/merge_merge_two.rb +168 -0
- data/lib/polyrun/coverage/merge_native.rb +39 -0
- data/lib/polyrun/coverage/rails.rb +126 -0
- data/lib/polyrun/coverage/reporting.rb +41 -0
- data/lib/polyrun/coverage/result.rb +18 -0
- data/lib/polyrun/coverage/track_files.rb +150 -0
- data/lib/polyrun/data/cached_fixtures.rb +122 -0
- data/lib/polyrun/data/factory_counts.rb +48 -0
- data/lib/polyrun/data/factory_instrumentation.rb +50 -0
- data/lib/polyrun/data/fixtures.rb +68 -0
- data/lib/polyrun/data/parallel_provisioning.rb +93 -0
- data/lib/polyrun/data/snapshot.rb +84 -0
- data/lib/polyrun/database/clone_shards.rb +106 -0
- data/lib/polyrun/database/provision.rb +83 -0
- data/lib/polyrun/database/shard.rb +64 -0
- data/lib/polyrun/database/url_builder/connection/infer.rb +53 -0
- data/lib/polyrun/database/url_builder/connection/url_builders.rb +43 -0
- data/lib/polyrun/database/url_builder/connection.rb +191 -0
- data/lib/polyrun/database/url_builder/template_prepare.rb +21 -0
- data/lib/polyrun/database/url_builder.rb +188 -0
- data/lib/polyrun/debug.rb +81 -0
- data/lib/polyrun/env/ci.rb +65 -0
- data/lib/polyrun/error.rb +3 -0
- data/lib/polyrun/export/csv.rb +25 -0
- data/lib/polyrun/export/markdown.rb +47 -0
- data/lib/polyrun/graph/client.rb +64 -0
- data/lib/polyrun/graph/error.rb +13 -0
- data/lib/polyrun/graph/index.rb +75 -0
- data/lib/polyrun/graph/inspect.rb +58 -0
- data/lib/polyrun/graph/plan.rb +134 -0
- data/lib/polyrun/graph/planner.rb +117 -0
- data/lib/polyrun/graph/syntax.rb +114 -0
- data/lib/polyrun/graph/transaction.rb +81 -0
- data/lib/polyrun/graph/worker.rb +55 -0
- data/lib/polyrun/graph/workspace.rb +117 -0
- data/lib/polyrun/hooks/dsl.rb +128 -0
- data/lib/polyrun/hooks/shell_runner.rb +33 -0
- data/lib/polyrun/hooks/worker_runner.rb +27 -0
- data/lib/polyrun/hooks/worker_shell.rb +50 -0
- data/lib/polyrun/hooks.rb +190 -0
- data/lib/polyrun/log.rb +86 -0
- data/lib/polyrun/minitest_support.rb +60 -0
- data/lib/polyrun/mutation/candidates.rb +91 -0
- data/lib/polyrun/mutation/operators.rb +51 -0
- data/lib/polyrun/mutation/runner.rb +133 -0
- data/lib/polyrun/mutation/subjects.rb +88 -0
- data/lib/polyrun/partition/constraints.rb +80 -0
- data/lib/polyrun/partition/hrw.rb +70 -0
- data/lib/polyrun/partition/min_heap.rb +64 -0
- data/lib/polyrun/partition/paths.rb +175 -0
- data/lib/polyrun/partition/paths_build.rb +141 -0
- data/lib/polyrun/partition/plan.rb +250 -0
- data/lib/polyrun/partition/plan_lpt.rb +91 -0
- data/lib/polyrun/partition/plan_sharding.rb +56 -0
- data/lib/polyrun/partition/reports.rb +139 -0
- data/lib/polyrun/partition/stable_shuffle.rb +18 -0
- data/lib/polyrun/partition/suite.rb +120 -0
- data/lib/polyrun/partition/timing_diagnostics.rb +138 -0
- data/lib/polyrun/partition/timing_keys.rb +86 -0
- data/lib/polyrun/prepare/artifacts.rb +40 -0
- data/lib/polyrun/prepare/assets.rb +64 -0
- data/lib/polyrun/process_stdio.rb +96 -0
- data/lib/polyrun/quality/command.rb +84 -0
- data/lib/polyrun/quality/measure.rb +38 -0
- data/lib/polyrun/quality/observe.rb +53 -0
- data/lib/polyrun/quality/observe_hook.rb +103 -0
- data/lib/polyrun/quality/sandbox.rb +70 -0
- data/lib/polyrun/queue/duration.rb +30 -0
- data/lib/polyrun/queue/file_store.rb +413 -0
- data/lib/polyrun/queue/file_store_intent.rb +188 -0
- data/lib/polyrun/queue/file_store_pending.rb +48 -0
- data/lib/polyrun/queue/worker_loop.rb +73 -0
- data/lib/polyrun/quick/assertions.rb +32 -0
- data/lib/polyrun/quick/config.rb +56 -0
- data/lib/polyrun/quick/errors.rb +6 -0
- data/lib/polyrun/quick/example_group.rb +111 -0
- data/lib/polyrun/quick/example_runner.rb +129 -0
- data/lib/polyrun/quick/matchers.rb +159 -0
- data/lib/polyrun/quick/matchers_predicates.rb +122 -0
- data/lib/polyrun/quick/reporter.rb +76 -0
- data/lib/polyrun/quick/runner.rb +224 -0
- data/lib/polyrun/quick.rb +1 -0
- data/lib/polyrun/railtie.rb +7 -0
- data/lib/polyrun/reporting/failure_merge.rb +171 -0
- data/lib/polyrun/reporting/junit.rb +126 -0
- data/lib/polyrun/reporting/junit_emit.rb +58 -0
- data/lib/polyrun/reporting/junit_report.rb +87 -0
- data/lib/polyrun/reporting/rspec_failure_fragment_formatter.rb +95 -0
- data/lib/polyrun/reporting/rspec_junit.rb +39 -0
- data/lib/polyrun/rspec_support/active_record_timeout_recovery.rb +51 -0
- data/lib/polyrun/rspec_support/example_debug.rb +167 -0
- data/lib/polyrun/rspec_support/example_debug_instrumentation.rb +73 -0
- data/lib/polyrun/rspec_support/sharded_formatter_compat.rb +57 -0
- data/lib/polyrun/rspec_support.rb +110 -0
- data/lib/polyrun/spec_quality/config.rb +139 -0
- data/lib/polyrun/spec_quality/fragment.rb +39 -0
- data/lib/polyrun/spec_quality/merge.rb +78 -0
- data/lib/polyrun/spec_quality/minitest_hook.rb +42 -0
- data/lib/polyrun/spec_quality/plan_loader.rb +47 -0
- data/lib/polyrun/spec_quality/profile.rb +102 -0
- data/lib/polyrun/spec_quality/report.rb +363 -0
- data/lib/polyrun/spec_quality/rspec_hook.rb +55 -0
- data/lib/polyrun/spec_quality/sql_counter.rb +34 -0
- data/lib/polyrun/spec_quality.rb +212 -0
- data/lib/polyrun/sus_support.rb +55 -0
- data/lib/polyrun/templates/POLYRUN.md +51 -0
- data/lib/polyrun/templates/ci_matrix.polyrun.yml +22 -0
- data/lib/polyrun/templates/minimal_gem.polyrun.yml +13 -0
- data/lib/polyrun/templates/polyrun_hooks_spec_quality.rb +12 -0
- data/lib/polyrun/templates/polyrun_spec_quality.yml +20 -0
- data/lib/polyrun/templates/rails_prepare.polyrun.yml +51 -0
- data/lib/polyrun/templates/rails_prepare_task.rake +16 -0
- data/lib/polyrun/timing/merge.rb +36 -0
- data/lib/polyrun/timing/rspec_example_formatter.rb +60 -0
- data/lib/polyrun/timing/stats.rb +76 -0
- data/lib/polyrun/timing/summary.rb +78 -0
- data/lib/polyrun/timing/variance_report.rb +51 -0
- data/lib/polyrun/version.rb +3 -0
- data/lib/polyrun/worker_output.rb +181 -0
- data/lib/polyrun/worker_output_forwarders.rb +94 -0
- data/lib/polyrun/worker_ping.rb +77 -0
- data/lib/polyrun.rb +59 -0
- data/polyrun.gemspec +49 -0
- data/sig/polyrun/cli.rbs +6 -0
- data/sig/polyrun/config.rbs +20 -0
- data/sig/polyrun/debug.rbs +12 -0
- data/sig/polyrun/log.rbs +12 -0
- data/sig/polyrun/minitest_support.rbs +7 -0
- data/sig/polyrun/quick.rbs +19 -0
- data/sig/polyrun/rspec_support.rbs +21 -0
- data/sig/polyrun/sus_support.rbs +7 -0
- data/sig/polyrun/worker_output.rbs +11 -0
- data/sig/polyrun/worker_ping.rbs +10 -0
- data/sig/polyrun.rbs +11 -0
- metadata +463 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Polyrun
|
|
2
|
+
class Config
|
|
3
|
+
# Read nested keys from loaded YAML (+String+ / +Symbol+ indifferent at each step).
|
|
4
|
+
module DottedPath
|
|
5
|
+
module_function
|
|
6
|
+
|
|
7
|
+
def dig(raw, dotted)
|
|
8
|
+
segments = dotted.split(".")
|
|
9
|
+
return nil if segments.empty?
|
|
10
|
+
return nil if segments.any?(&:empty?)
|
|
11
|
+
|
|
12
|
+
segments.reduce(raw) do |m, seg|
|
|
13
|
+
break nil if m.nil?
|
|
14
|
+
break nil unless m.is_a?(Hash)
|
|
15
|
+
|
|
16
|
+
m[seg] || m[seg.to_sym]
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require_relative "dotted_path"
|
|
2
|
+
require_relative "resolver"
|
|
3
|
+
require_relative "tools"
|
|
4
|
+
|
|
5
|
+
module Polyrun
|
|
6
|
+
class Config
|
|
7
|
+
# Nested hash of values Polyrun uses: loaded YAML (string keys) with overlays for
|
|
8
|
+
# merged +prepare.env+, resolved +partition.shard_index+ / +shard_total+ / +shard_processes+ / +timing_granularity+,
|
|
9
|
+
# and top-level +workers+ (+POLYRUN_WORKERS+ default).
|
|
10
|
+
#
|
|
11
|
+
# +build+ memoizes the last (cfg, env) in-process so repeated +dig+ calls on the same load do not
|
|
12
|
+
# rebuild the tree (single-threaded CLI).
|
|
13
|
+
module Effective
|
|
14
|
+
class << self
|
|
15
|
+
# Per-thread cache avoids rebuilding the effective tree on repeated +dig+; no class ivars (RuboCop ThreadSafety).
|
|
16
|
+
def build(cfg, env: ENV)
|
|
17
|
+
key = cache_key(cfg, env)
|
|
18
|
+
per_thread = (Thread.current[:polyrun_effective_build] ||= {})
|
|
19
|
+
per_thread[key] ||= build_uncached(cfg, env: env)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def dig(cfg, dotted_path, env: ENV)
|
|
23
|
+
Polyrun::Config::DottedPath.dig(build(cfg, env: env), dotted_path)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def cache_key(cfg, env)
|
|
29
|
+
[cfg.path, cfg.object_id, env_fingerprint(env)]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def env_fingerprint(env)
|
|
33
|
+
env.to_h.keys.sort.map { |k| [k, env[k]] }.hash
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def build_uncached(cfg, env:)
|
|
37
|
+
r = Polyrun::Config::Resolver
|
|
38
|
+
base = deep_stringify_keys(cfg.raw)
|
|
39
|
+
|
|
40
|
+
prep = cfg.prepare
|
|
41
|
+
base["prepare"] = deep_stringify_keys(prep)
|
|
42
|
+
base["prepare"]["env"] = r.merged_prepare_env(prep, env)
|
|
43
|
+
|
|
44
|
+
pc = cfg.partition
|
|
45
|
+
part = deep_stringify_keys(pc).merge(
|
|
46
|
+
"shard_index" => r.resolve_shard_index(pc, env),
|
|
47
|
+
"shard_total" => r.resolve_shard_total(pc, env),
|
|
48
|
+
"shard_processes" => r.resolve_shard_processes(pc, env),
|
|
49
|
+
"timing_granularity" => r.resolve_partition_timing_granularity(pc, nil, env).to_s
|
|
50
|
+
)
|
|
51
|
+
base["partition"] = part
|
|
52
|
+
|
|
53
|
+
base["workers"] = r.parallel_worker_count(cfg, env)
|
|
54
|
+
apply_tools!(base, cfg, env)
|
|
55
|
+
base["suite"] = cfg.suite if cfg.respond_to?(:suite) && cfg.suite
|
|
56
|
+
|
|
57
|
+
base
|
|
58
|
+
rescue ArgumentError => error
|
|
59
|
+
raise Polyrun::Error, error.message
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def apply_tools!(base, cfg, env)
|
|
63
|
+
%w[graph mutation].each { |feature| base[feature] = Tools.resolve(cfg, feature, env: env) }
|
|
64
|
+
base["quality"] = (base["quality"] || {}).merge(%w[observe measure].to_h { |feature| [feature, Tools.resolve(cfg, feature, env: env)] })
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def deep_stringify_keys(obj)
|
|
68
|
+
case obj
|
|
69
|
+
when Hash
|
|
70
|
+
obj.each_with_object({}) do |(k, v), m|
|
|
71
|
+
m[k.to_s] = deep_stringify_keys(v)
|
|
72
|
+
end
|
|
73
|
+
when Array
|
|
74
|
+
obj.map { |e| deep_stringify_keys(e) }
|
|
75
|
+
else
|
|
76
|
+
obj
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
require_relative "../env/ci"
|
|
2
|
+
require_relative "../partition/timing_keys"
|
|
3
|
+
|
|
4
|
+
module Polyrun
|
|
5
|
+
class Config
|
|
6
|
+
# Single source for values derived from +polyrun.yml+, +ENV+, and CI detection.
|
|
7
|
+
# Used by {Effective}, CLI helpers, and prepare.
|
|
8
|
+
module Resolver
|
|
9
|
+
module_function
|
|
10
|
+
|
|
11
|
+
def env_int(name, fallback, env = ENV)
|
|
12
|
+
s = env[name]
|
|
13
|
+
return fallback if s.nil? || s.empty?
|
|
14
|
+
|
|
15
|
+
Integer(s, exception: false) || fallback
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def prepare_env_yaml_string_map(prep)
|
|
19
|
+
(prep["env"] || prep[:env] || {}).transform_keys(&:to_s).transform_values(&:to_s)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Same merge order as +polyrun prepare+: YAML +prepare.env+ overrides process +ENV+ for overlapping keys.
|
|
23
|
+
def merged_prepare_env(prep, env = ENV)
|
|
24
|
+
prep_env = prepare_env_yaml_string_map(prep)
|
|
25
|
+
env.to_h.merge(prep_env)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def partition_int(pc, keys, default)
|
|
29
|
+
keys.each do |k|
|
|
30
|
+
v = pc[k] || pc[k.to_sym]
|
|
31
|
+
next if v.nil? || v.to_s.empty?
|
|
32
|
+
|
|
33
|
+
i = Integer(v, exception: false)
|
|
34
|
+
return i unless i.nil?
|
|
35
|
+
end
|
|
36
|
+
default
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def resolve_shard_index(pc, env = ENV)
|
|
40
|
+
return Integer(env["POLYRUN_SHARD_INDEX"]) if env["POLYRUN_SHARD_INDEX"] && !env["POLYRUN_SHARD_INDEX"].empty?
|
|
41
|
+
|
|
42
|
+
ci = Polyrun::Env::Ci.detect_shard_index
|
|
43
|
+
return ci unless ci.nil?
|
|
44
|
+
|
|
45
|
+
partition_int(pc, %w[shard_index shard], 0)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def resolve_shard_total(pc, env = ENV)
|
|
49
|
+
return Integer(env["POLYRUN_SHARD_TOTAL"]) if env["POLYRUN_SHARD_TOTAL"] && !env["POLYRUN_SHARD_TOTAL"].empty?
|
|
50
|
+
|
|
51
|
+
ci = Polyrun::Env::Ci.detect_shard_total
|
|
52
|
+
return ci unless ci.nil?
|
|
53
|
+
|
|
54
|
+
partition_int(pc, %w[shard_total total], 1)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Processes per CI matrix job for +ci-shard-run+ / +ci-shard-rspec+ (NxM: N jobs × M processes).
|
|
58
|
+
# +POLYRUN_SHARD_PROCESSES+ or +partition.shard_processes+; CLI +--shard-processes+ / +--workers+ overrides.
|
|
59
|
+
def resolve_shard_processes(pc, env = ENV)
|
|
60
|
+
return Integer(env["POLYRUN_SHARD_PROCESSES"]) if env["POLYRUN_SHARD_PROCESSES"] && !env["POLYRUN_SHARD_PROCESSES"].empty?
|
|
61
|
+
|
|
62
|
+
partition_int(pc, %w[shard_processes shard_workers workers_per_shard], 1)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# +cli_val+ is an override (e.g. +run-shards --timing-granularity+); +nil+ uses YAML then +POLYRUN_TIMING_GRANULARITY+.
|
|
66
|
+
def resolve_partition_timing_granularity(pc, cli_val, env = ENV)
|
|
67
|
+
raw = cli_val
|
|
68
|
+
raw ||= pc && (pc["timing_granularity"] || pc[:timing_granularity])
|
|
69
|
+
raw ||= env["POLYRUN_TIMING_GRANULARITY"]
|
|
70
|
+
Polyrun::Partition::TimingKeys.normalize_granularity(raw || "file")
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def parallel_worker_count_default(env = ENV)
|
|
74
|
+
env_int("POLYRUN_WORKERS", Polyrun::Config::DEFAULT_PARALLEL_WORKERS, env)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# +POLYRUN_WORKERS+ then top-level YAML +workers:+ then {Config::DEFAULT_PARALLEL_WORKERS}.
|
|
78
|
+
def parallel_worker_count(cfg = nil, env = ENV)
|
|
79
|
+
validate_shared_tools!(cfg) if cfg
|
|
80
|
+
|
|
81
|
+
s = env["POLYRUN_WORKERS"]
|
|
82
|
+
unless s.nil? || s.empty?
|
|
83
|
+
i = Integer(s, exception: false)
|
|
84
|
+
return i unless i.nil?
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
yaml_workers = yaml_top_level_workers(cfg)
|
|
88
|
+
return yaml_workers unless yaml_workers.nil?
|
|
89
|
+
|
|
90
|
+
Polyrun::Config::DEFAULT_PARALLEL_WORKERS
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def validate_shared_tools!(cfg)
|
|
94
|
+
raw = cfg.respond_to?(:raw) ? cfg.raw : cfg
|
|
95
|
+
errors = Tools.validate(raw)
|
|
96
|
+
raise Polyrun::Error, errors.join("; ") unless errors.empty?
|
|
97
|
+
end
|
|
98
|
+
private_class_method :validate_shared_tools!
|
|
99
|
+
|
|
100
|
+
def yaml_top_level_workers(cfg)
|
|
101
|
+
return nil unless cfg
|
|
102
|
+
|
|
103
|
+
raw = cfg.respond_to?(:raw) ? cfg.raw : cfg
|
|
104
|
+
return nil unless raw.is_a?(Hash)
|
|
105
|
+
|
|
106
|
+
v = raw["workers"] || raw[:workers]
|
|
107
|
+
return nil if v.nil? || v.to_s.empty?
|
|
108
|
+
|
|
109
|
+
Integer(v, exception: false)
|
|
110
|
+
end
|
|
111
|
+
private_class_method :yaml_top_level_workers
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require_relative "tool_defaults"
|
|
2
|
+
|
|
3
|
+
module Polyrun
|
|
4
|
+
class Config
|
|
5
|
+
# Lightweight top-level key checks for +polyrun validate+.
|
|
6
|
+
module Schema
|
|
7
|
+
KNOWN_TOP_LEVEL = %w[
|
|
8
|
+
version
|
|
9
|
+
partition
|
|
10
|
+
prepare
|
|
11
|
+
coverage
|
|
12
|
+
databases
|
|
13
|
+
start
|
|
14
|
+
hooks
|
|
15
|
+
reporting
|
|
16
|
+
suites
|
|
17
|
+
graph
|
|
18
|
+
mutation
|
|
19
|
+
quality
|
|
20
|
+
].concat(ToolDefaults::SHARED.keys).freeze
|
|
21
|
+
|
|
22
|
+
module_function
|
|
23
|
+
|
|
24
|
+
def validate(cfg)
|
|
25
|
+
raw = cfg.raw
|
|
26
|
+
return {ok: true, messages: ["polyrun validate: no config file found (empty defaults)"]} if cfg.path.nil?
|
|
27
|
+
|
|
28
|
+
unless raw.is_a?(Hash)
|
|
29
|
+
return {ok: false, messages: ["polyrun validate: config root must be a mapping"]}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
unknown = raw.keys.map(&:to_s) - KNOWN_TOP_LEVEL
|
|
33
|
+
messages = unknown.sort.map { |k| "polyrun validate: unknown top-level key #{k.inspect}" }
|
|
34
|
+
messages.concat(Polyrun::Config::Tools.validate(raw).map { |message| "polyrun validate: #{message}" })
|
|
35
|
+
{ok: messages.empty?, messages: messages.uniq}
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
require_relative "tools"
|
|
2
|
+
|
|
3
|
+
module Polyrun
|
|
4
|
+
class Config
|
|
5
|
+
# Applies a named +suites:+ overlay onto a loaded polyrun.yml hash.
|
|
6
|
+
module Suite
|
|
7
|
+
PARTITION_KEYS = %w[
|
|
8
|
+
paths_file shard_total shard_index strategy seed timing_file timing_granularity
|
|
9
|
+
constraints constraints_file shard_weights suite paths_build shard_processes
|
|
10
|
+
shard_workers workers_per_shard
|
|
11
|
+
].freeze
|
|
12
|
+
|
|
13
|
+
TOP_MERGE_KEYS = (%w[prepare start hooks reporting coverage databases graph mutation quality] + ToolDefaults::SHARED.keys).freeze
|
|
14
|
+
|
|
15
|
+
module_function
|
|
16
|
+
|
|
17
|
+
def merge(raw, suite_name)
|
|
18
|
+
name = suite_name.to_s.strip
|
|
19
|
+
base = deep_stringify(raw.is_a?(Hash) ? raw : {})
|
|
20
|
+
return [base, nil] if name.empty?
|
|
21
|
+
|
|
22
|
+
suites = base["suites"]
|
|
23
|
+
unless suites.is_a?(Hash)
|
|
24
|
+
raise Polyrun::Error, "polyrun: suites: map is required when selecting suite #{name.inspect}"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
overlay = suites[name]
|
|
28
|
+
unless overlay.is_a?(Hash)
|
|
29
|
+
available = suites.keys.map(&:to_s).sort.join(", ")
|
|
30
|
+
raise Polyrun::Error, "polyrun: unknown suite #{name.inspect} (known: #{available})"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
apply_overlay!(base, deep_stringify(overlay))
|
|
34
|
+
[base, name]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def apply_overlay!(base, overlay)
|
|
38
|
+
errors = Tools.validate(overlay)
|
|
39
|
+
raise Polyrun::Error, errors.join("; ") unless errors.empty?
|
|
40
|
+
|
|
41
|
+
merge_partition_block!(base, overlay)
|
|
42
|
+
merge_partition_shortcuts!(base, overlay)
|
|
43
|
+
merge_top_keys!(base, overlay)
|
|
44
|
+
end
|
|
45
|
+
private_class_method :apply_overlay!
|
|
46
|
+
|
|
47
|
+
def merge_partition_block!(base, overlay)
|
|
48
|
+
return unless overlay["partition"].is_a?(Hash)
|
|
49
|
+
|
|
50
|
+
base["partition"] = deep_merge_hashes(base["partition"] || {}, overlay["partition"])
|
|
51
|
+
end
|
|
52
|
+
private_class_method :merge_partition_block!
|
|
53
|
+
|
|
54
|
+
def merge_partition_shortcuts!(base, overlay)
|
|
55
|
+
PARTITION_KEYS.each do |key|
|
|
56
|
+
next unless overlay.key?(key)
|
|
57
|
+
|
|
58
|
+
base["partition"] ||= {}
|
|
59
|
+
base["partition"][key] =
|
|
60
|
+
if key == "paths_build" && base["partition"][key].is_a?(Hash) && overlay[key].is_a?(Hash)
|
|
61
|
+
deep_merge_hashes(base["partition"][key], overlay[key])
|
|
62
|
+
else
|
|
63
|
+
overlay[key]
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
private_class_method :merge_partition_shortcuts!
|
|
68
|
+
|
|
69
|
+
def merge_top_keys!(base, overlay)
|
|
70
|
+
TOP_MERGE_KEYS.each do |key|
|
|
71
|
+
next unless overlay.key?(key)
|
|
72
|
+
|
|
73
|
+
base[key] =
|
|
74
|
+
if base[key].is_a?(Hash) && overlay[key].is_a?(Hash)
|
|
75
|
+
deep_merge_hashes(base[key], overlay[key])
|
|
76
|
+
else
|
|
77
|
+
overlay[key]
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
private_class_method :merge_top_keys!
|
|
82
|
+
|
|
83
|
+
def deep_stringify(obj)
|
|
84
|
+
case obj
|
|
85
|
+
when Hash
|
|
86
|
+
obj.each_with_object({}) { |(k, v), out| out[k.to_s] = deep_stringify(v) }
|
|
87
|
+
when Array
|
|
88
|
+
obj.map { |e| deep_stringify(e) }
|
|
89
|
+
else
|
|
90
|
+
obj
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
private_class_method :deep_stringify
|
|
94
|
+
|
|
95
|
+
def deep_merge_hashes(base, overlay)
|
|
96
|
+
a = base.dup
|
|
97
|
+
overlay.each do |k, v|
|
|
98
|
+
a[k] = if a[k].is_a?(Hash) && v.is_a?(Hash)
|
|
99
|
+
deep_merge_hashes(a[k], v)
|
|
100
|
+
else
|
|
101
|
+
v
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
a
|
|
105
|
+
end
|
|
106
|
+
private_class_method :deep_merge_hashes
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Polyrun
|
|
2
|
+
class Config
|
|
3
|
+
module ToolDefaults
|
|
4
|
+
STAGING = {"max_bytes" => 67_108_864, "max_files" => 10_000,
|
|
5
|
+
"exclude" => %w[vendor node_modules tmp log pkg benchmarks],
|
|
6
|
+
"exclude_paths" => %w[coverage], "include_hidden" => %w[.rspec .ruby-version]}.freeze
|
|
7
|
+
COMMON = {"enabled" => false, "root" => nil, "workers" => 1, "timeout" => 300,
|
|
8
|
+
"command" => [], "output" => nil, "max_output_bytes" => 1_048_576,
|
|
9
|
+
"max_input_bytes" => 1_048_576, "max_artifact_bytes" => 67_108_864,
|
|
10
|
+
"source_roots" => %w[lib app], "source_fallback" => true,
|
|
11
|
+
"source_exclude" => %w[spec test features examples benchmarks vendor node_modules tmp log coverage pkg],
|
|
12
|
+
"max_nodes" => 250_000, "max_source_files" => 100_000, "max_source_file_bytes" => 10_485_760,
|
|
13
|
+
"max_source_bytes" => 67_108_864, "staging" => STAGING}.freeze
|
|
14
|
+
SHARED = COMMON.except("enabled").freeze
|
|
15
|
+
GRAPH = {"timeout" => 60, "state_dir" => ".polyrun/graph", "json" => false,
|
|
16
|
+
"calls" => false, "callers" => false, "callees" => false, "control_plane" => false, "prove" => false,
|
|
17
|
+
"max_operations" => 1000, "max_diff_bytes" => 524_288,
|
|
18
|
+
"max_plan_bytes" => 1_048_576, "max_receipt_files" => 100_000}.freeze
|
|
19
|
+
MUTATION = {"max_workers" => 32, "max_mutations" => 1000, "max_subjects" => 10_000,
|
|
20
|
+
"max_report_bytes" => 16_777_216, "max_copy_bytes" => 1_073_741_824,
|
|
21
|
+
"operators" => %w[literal operator body], "subjects" => [], "subjects_file" => nil,
|
|
22
|
+
"observed" => [], "plan" => nil, "shard" => 1, "total" => 1}.freeze
|
|
23
|
+
OBSERVE = {"max_entries" => 10_000, "max_artifact_bytes" => 16_777_216}.freeze
|
|
24
|
+
MEASURE = {"label" => "command", "ceilings" => {}}.freeze
|
|
25
|
+
EXECUTION = %w[enabled root timeout command output max_output_bytes].freeze
|
|
26
|
+
FEATURES = {"graph" => GRAPH, "mutation" => MUTATION, "observe" => OBSERVE, "measure" => MEASURE}.freeze
|
|
27
|
+
|
|
28
|
+
module_function
|
|
29
|
+
|
|
30
|
+
def for(feature)
|
|
31
|
+
feature = feature.to_s
|
|
32
|
+
common = case feature
|
|
33
|
+
when "graph" then COMMON.except("workers")
|
|
34
|
+
when "observe" then COMMON.slice(*EXECUTION, "max_artifact_bytes")
|
|
35
|
+
when "measure" then COMMON.slice(*EXECUTION)
|
|
36
|
+
else COMMON
|
|
37
|
+
end
|
|
38
|
+
Marshal.load(Marshal.dump(common.merge(FEATURES.fetch(feature))))
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require_relative "tool_defaults"
|
|
2
|
+
|
|
3
|
+
module Polyrun
|
|
4
|
+
class Config
|
|
5
|
+
module ToolValidation
|
|
6
|
+
OPTIONAL_STRINGS = %w[root output subjects_file plan].freeze
|
|
7
|
+
COUNTS = %w[min_line_churn min_query_count hot_line_example_overlap minimum_unique_lines_per_example max_zero_hit_examples max_hot_line_overlap].freeze
|
|
8
|
+
|
|
9
|
+
module_function
|
|
10
|
+
|
|
11
|
+
def check(value, defaults, prefix)
|
|
12
|
+
return ["#{prefix} must be a mapping"] unless value.is_a?(Hash)
|
|
13
|
+
|
|
14
|
+
value.flat_map do |key, item|
|
|
15
|
+
path = "#{prefix}.#{key}"
|
|
16
|
+
next ["unknown setting #{path}"] unless defaults.key?(key)
|
|
17
|
+
expected = defaults[key]
|
|
18
|
+
if expected.is_a?(Hash)
|
|
19
|
+
(key == "ceilings") ? check_ceilings(item, path) : check(item, expected, path)
|
|
20
|
+
elsif valid?(key, item, expected)
|
|
21
|
+
[]
|
|
22
|
+
else
|
|
23
|
+
["invalid setting #{path}"]
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def valid?(key, value, expected)
|
|
29
|
+
return value.nil? || valid_string?(value) if OPTIONAL_STRINGS.include?(key)
|
|
30
|
+
return value.is_a?(Numeric) && value.finite? && value.positive? if key == "timeout"
|
|
31
|
+
return relative_path?(value) if key == "state_dir"
|
|
32
|
+
return valid_count?(value, expected) if COUNTS.include?(key)
|
|
33
|
+
return value.nil? || nonnegative?(value) if expected.nil?
|
|
34
|
+
return positive_integer?(value) if expected.is_a?(Integer)
|
|
35
|
+
return nonnegative?(value) && value <= 1 if key == "sample"
|
|
36
|
+
return value == true || value == false if expected == true || expected == false
|
|
37
|
+
return valid_array?(key, value) if expected.is_a?(Array)
|
|
38
|
+
|
|
39
|
+
valid_string?(value)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def positive_integer?(value)
|
|
43
|
+
value.is_a?(Integer) && value.positive?
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def valid_count?(value, expected)
|
|
47
|
+
(expected.nil? && value.nil?) || (value.is_a?(Integer) && value >= 0)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def valid_string?(value)
|
|
51
|
+
value.is_a?(String) && !value.empty? && !value.include?("\0")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def nonnegative?(value)
|
|
55
|
+
value.is_a?(Numeric) && value.finite? && value >= 0
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def valid_array?(key, value)
|
|
59
|
+
return false unless value.is_a?(Array) && value.all? { |entry| valid_string?(entry) }
|
|
60
|
+
return !value.empty? && (value - %w[literal operator body]).empty? if key == "operators"
|
|
61
|
+
return value.all? { |entry| relative_path?(entry) || entry == "." } if key == "source_roots"
|
|
62
|
+
|
|
63
|
+
true
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def relative_path?(value)
|
|
67
|
+
value.is_a?(String) && !value.empty? && !value.include?("\0") && !value.split("/", -1).any? { |part| ["", ".", ".."].include?(part) }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def check_ceilings(value, prefix)
|
|
71
|
+
return ["#{prefix} must be a mapping"] unless value.is_a?(Hash)
|
|
72
|
+
|
|
73
|
+
value.filter_map do |key, item|
|
|
74
|
+
"invalid setting #{prefix}.#{key}" unless item.is_a?(Numeric) && item.finite? && item >= 0
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
require_relative "tool_validation"
|
|
2
|
+
|
|
3
|
+
module Polyrun
|
|
4
|
+
class Config
|
|
5
|
+
module Tools
|
|
6
|
+
module_function
|
|
7
|
+
|
|
8
|
+
def merge(base, overlay)
|
|
9
|
+
base.merge(overlay) { |_, before, after| (before.is_a?(Hash) && after.is_a?(Hash)) ? merge(before, after) : after }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def runtime(feature, settings = {})
|
|
13
|
+
raise ArgumentError, "settings must be a mapping" unless settings.is_a?(Hash)
|
|
14
|
+
|
|
15
|
+
value = merge(ToolDefaults.for(feature), stringify(settings))
|
|
16
|
+
errors = ToolValidation.check(value, ToolDefaults.for(feature), feature.to_s)
|
|
17
|
+
raise ArgumentError, errors.join("; ") unless errors.empty?
|
|
18
|
+
|
|
19
|
+
value
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def resolve(cfg, feature, overrides: {}, env: ENV, root: Dir.pwd)
|
|
23
|
+
errors = validate(cfg.raw)
|
|
24
|
+
raise ArgumentError, errors.join("; ") unless errors.empty?
|
|
25
|
+
|
|
26
|
+
raw = stringify(cfg.raw)
|
|
27
|
+
defaults = ToolDefaults.for(feature)
|
|
28
|
+
shared = shared_defaults(raw).slice(*defaults.keys)
|
|
29
|
+
value = merge(merge(defaults, shared), feature_config(raw, feature))
|
|
30
|
+
value = merge(value, environment(feature, env))
|
|
31
|
+
value = runtime(feature, merge(value, stringify(overrides)))
|
|
32
|
+
normalize_paths(value, root)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def shared_defaults(raw)
|
|
36
|
+
shared = raw.slice(*ToolDefaults::SHARED.keys)
|
|
37
|
+
if shared["workers"].is_a?(String)
|
|
38
|
+
shared["workers"] = Integer(shared["workers"], exception: false) || shared["workers"]
|
|
39
|
+
end
|
|
40
|
+
shared
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def normalize_paths(value, root)
|
|
44
|
+
value["root"] = File.expand_path(value["root"] || root, root)
|
|
45
|
+
%w[output subjects_file].each { |key| value[key] = File.expand_path(value[key], value["root"]) if value[key] }
|
|
46
|
+
value
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def feature_config(raw, feature)
|
|
50
|
+
return raw.fetch(feature, {}) unless %w[observe measure].include?(feature)
|
|
51
|
+
|
|
52
|
+
quality = raw.fetch("quality", {})
|
|
53
|
+
merge(quality.slice(*ToolDefaults.for(feature).keys), quality.fetch(feature, {}))
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def environment(feature, env)
|
|
57
|
+
result = {}
|
|
58
|
+
applicable = ToolDefaults.for(feature)
|
|
59
|
+
{"workers" => "POLYRUN_WORKERS", "timeout" => "POLYRUN_TIMEOUT", "max_output_bytes" => "POLYRUN_MAX_OUTPUT_BYTES"}.each do |key, name|
|
|
60
|
+
next if !applicable.key?(key) || env[name].nil? || env[name].empty?
|
|
61
|
+
|
|
62
|
+
result[key] = (key == "timeout") ? Float(env[name]) : Integer(env[name])
|
|
63
|
+
end
|
|
64
|
+
name = "POLYRUN_#{%w[observe measure].include?(feature) ? "QUALITY" : feature.upcase}"
|
|
65
|
+
if env.key?(name)
|
|
66
|
+
raise ArgumentError, "invalid #{name}" unless %w[1 true yes on 0 false no off].include?(env[name].downcase)
|
|
67
|
+
|
|
68
|
+
result["enabled"] = %w[1 true yes on].include?(env[name].downcase)
|
|
69
|
+
end
|
|
70
|
+
result
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def validate(raw)
|
|
74
|
+
raw = stringify(raw)
|
|
75
|
+
errors = ToolValidation.check(shared_defaults(raw), ToolDefaults::SHARED, "config")
|
|
76
|
+
errors << 'unknown top-level key "global"' if raw.key?("global")
|
|
77
|
+
%w[graph mutation].each do |feature|
|
|
78
|
+
errors.concat(ToolValidation.check(raw[feature], ToolDefaults.for(feature), feature)) if raw.key?(feature)
|
|
79
|
+
end
|
|
80
|
+
errors.concat(validate_quality(raw["quality"])) if raw.key?("quality")
|
|
81
|
+
errors
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def validate_quality(quality)
|
|
85
|
+
return ["quality must be a mapping"] unless quality.is_a?(Hash)
|
|
86
|
+
|
|
87
|
+
errors = ToolValidation.check(quality.except("observe", "measure", "spec_quality"), ToolDefaults::COMMON.slice(*ToolDefaults::EXECUTION, "max_artifact_bytes"), "quality")
|
|
88
|
+
%w[observe measure].each do |feature|
|
|
89
|
+
errors.concat(ToolValidation.check(quality[feature], ToolDefaults.for(feature), "quality.#{feature}")) if quality.key?(feature)
|
|
90
|
+
end
|
|
91
|
+
if quality.key?("spec_quality")
|
|
92
|
+
require_relative "../spec_quality/config"
|
|
93
|
+
defaults = SpecQuality::Config::DEFAULTS.merge("enabled" => false)
|
|
94
|
+
errors.concat(ToolValidation.check(quality["spec_quality"], defaults, "quality.spec_quality"))
|
|
95
|
+
end
|
|
96
|
+
errors
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def spec_quality(root:, env: ENV)
|
|
100
|
+
cfg = Config.load(path: env["POLYRUN_CONFIG"], root: root, suite: env["POLYRUN_SUITE"])
|
|
101
|
+
errors = validate(cfg.raw)
|
|
102
|
+
raise ArgumentError, errors.join("; ") unless errors.empty?
|
|
103
|
+
|
|
104
|
+
raw = stringify(cfg.raw)
|
|
105
|
+
shared = shared_defaults(raw)
|
|
106
|
+
settings = {}
|
|
107
|
+
settings["track_under"] = shared["source_roots"] if shared.key?("source_roots")
|
|
108
|
+
merge(settings, raw.fetch("quality", {}).fetch("spec_quality", {}))
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def stringify(value)
|
|
112
|
+
case value
|
|
113
|
+
when Hash then value.to_h { |key, item| [key.to_s, stringify(item)] }
|
|
114
|
+
when Array then value.map { |item| stringify(item) }
|
|
115
|
+
else value
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|