Skip to content

Fix QA environment variable check

Stan Hu requested to merge sh-fix-qa-env-check into master

What does this MR do and why?

In Ruby 3.1, QA::Runtime::Env.enabled? never worked properly when a boolean default value was used:

irb(main):010> (false =~ /^(false|no|0)$/i) != 0
=> true
irb(main):011> (true =~ /^(false|no|0)$/i) != 0
=> true

In Ruby 3.2, this results in a hard failure:

irb(main):003> (false =~ /^(false|no|0)$/i) != 0
(irb):3:in `<main>': undefined method `=~' for false:FalseClass (NoMethodError)

Fix this by converting the value to a string.

This showed up in the Ruby 3.2 test failure: https://gitlab.com/gitlab-org/gitlab/-/jobs/5854231602

How to set up and validate locally

From the qa directory, run this with Ruby 3.2 (you can add ruby 3.2.2 in .tool-versions):

bundle exec rspec -O .rspec_internal spec/resource/base_spec.rb
Edited by Stan Hu

Merge request reports