[PATCH lkp-tests 1/2] lib/job.rb: load config from lab yaml

[why] my_uuid is per-lab account, so it will load my_uuid from ~/.config/compass-ci/include/lab/$lab.yaml and $lab is from ~/.config/compass-ci/defaults/*.yaml or /etc/compass-ci/defaults/*.yaml Signed-off-by: Wei Jihui <weijihuiall@163.com> --- lib/job.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/job.rb b/lib/job.rb index b41d55a7..9eac4001 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -414,6 +414,17 @@ class Job true end + def load_self_config + self_config_path = "#{ENV['HOME']}/.config/compass-ci" + Dir.glob(['/etc/compass-ci/defaults/*.yaml', + "#{self_config_path}/defaults/*.yaml"]).each do |file| + load_one_defaults(file, @job) + end + + lab_yaml = File.join(self_config_path, 'include/lab', "#{@defaults['lab']}.yaml") + load_one_defaults(lab_yaml, @job) + end + def load_defaults(first_time = true) if @job.include? :no_defaults merge_defaults first_time @@ -426,11 +437,7 @@ class Job @file_loaded ||= {} end - Dir.glob(["/etc/compass-ci/defaults/*.yaml", - "#{ENV['HOME']}/.config/compass-ci/defaults/*.yaml"]).each do |file| - load_one_defaults(file, @job) - end - + load_self_config i = include_files job = deepcopy(@job) job['___'] = nil -- 2.23.0

On Mon, Dec 14, 2020 at 11:34:53AM +0800, Wei Jihui wrote:
[why] my_uuid is per-lab account, so it will load my_uuid from ~/.config/compass-ci/include/lab/$lab.yaml and $lab is from ~/.config/compass-ci/defaults/*.yaml or /etc/compass-ci/defaults/*.yaml
Signed-off-by: Wei Jihui <weijihuiall@163.com> --- lib/job.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/lib/job.rb b/lib/job.rb index b41d55a7..9eac4001 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -414,6 +414,17 @@ class Job true end
+ def load_self_config + self_config_path = "#{ENV['HOME']}/.config/compass-ci" + Dir.glob(['/etc/compass-ci/defaults/*.yaml', + "#{self_config_path}/defaults/*.yaml"]).each do |file| + load_one_defaults(file, @job) + end
That can go into one function.
+ lab_yaml = File.join(self_config_path, 'include/lab', "#{@defaults['lab']}.yaml") + load_one_defaults(lab_yaml, @job)
That can be made more general, by supporting personal include/** layout like this one (that is, not only support single lab file): wfg@crystal /c/lkp-tests% tree include include ├── analyze-suspend ├── blktests ├── category │ ├── benchmark │ ├── benchmark~ │ ├── functional │ └── noise-benchmark ├── cgroup2 ├── disk │ ├── nr_brd
participants (2)
-
Wei Jihui
-
Wu Fengguang