Ruby 2.7 compatibility for `lib/gitlab/ci/config/yaml.rb`

Job #3923512593 failed for bf9bc60c:

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.

This was introduced at !113972 (diffs, comment 1311843083)

Edited by Lin Jen-Shin