Fix yaml load compatible issue
This MR is trying to resolve #396337 (closed), which cause both upstream and JH qa pipeline failed.
The error was:
DEPRECATION WARNING: /builds/gitlab-org/gitlab/lib/gitlab/ci/config/yaml.rb:33: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/builds/gitlab-org/gitlab/lib/gitlab/ci/config/yaml/result.rb:10: warning: The called method `initialize' is defined here
(called from new at /builds/gitlab-org/gitlab/lib/gitlab/ci/config/yaml.rb:33)
An error occurred while loading ./spec/lib/gitlab/usage_data_counters/ci_template_unique_counter_spec.rb.
Failure/Error:
def initialize(config = nil, error: nil)
@config = Array.wrap(config)
@error = error
ArgumentError:
unknown keywords: :image, :variables, :stages, :workflow, :include, :".auto-deploy", :dast_environment_deploy
Why this happened can be demonstrated with this script:
def f a = nil, b: nil
[a, b]
end
p f({})
In Ruby 3, this gives [{}, nil]
as expected, however in Ruby 2.7, this gives [nil, nil]
because it somehow treats the hash argument as the keyword argument.
According to #396337 (comment 1312077110), upstream can resolve this issue by using ruby 3 in gitlab, however in JH, we still need sometime to upgrade ruby 3, so JH need this fix to enable CI feature.
cc: @daveliu
Edited by MAO Chao