diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-10 18:16:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-10 18:16:42 +0300 |
commit | e1d966e6543433479a932e1e29ad538cd587699a (patch) | |
tree | 8553431489849d866639ddc17ba873a98df0186d /scripts | |
parent | 8731c2348e508e52cad156bd819b0accbf88d495 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/setup/generate-as-if-foss-env.rb | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/scripts/setup/generate-as-if-foss-env.rb b/scripts/setup/generate-as-if-foss-env.rb index 9e93b470558..21f1822503c 100755 --- a/scripts/setup/generate-as-if-foss-env.rb +++ b/scripts/setup/generate-as-if-foss-env.rb @@ -6,10 +6,26 @@ require 'gitlab' unless Object.const_defined?(:Gitlab) require 'set' # rubocop:disable Lint/RedundantRequireStatement -- Ruby 3.1 and earlier needs this. Drop this line after Ruby 3.2+ is only supported. class GenerateAsIfFossEnv + FOSS_JOBS = Set.new(%w[ + build-assets-image + build-qa-image + compile-production-assets + compile-storybook + compile-test-assets + eslint + generate-apollo-graphql-schema + graphql-schema-dump + jest + jest-integration + qa:internal + qa:selectors + static-analysis + ]).freeze + def initialize @client = Gitlab.client(endpoint: ENV['CI_API_V4_URL'], private_token: '') @rspec_jobs = Set.new - @jest_jobs = Set.new + @other_jobs = Set.new end def variables @@ -24,7 +40,7 @@ class GenerateAsIfFossEnv private - attr_reader :client, :rspec_jobs, :jest_jobs + attr_reader :client, :rspec_jobs, :other_jobs def generate_variables scan_jobs @@ -32,12 +48,12 @@ class GenerateAsIfFossEnv { START_AS_IF_FOSS: 'true', RUBY_VERSION: ENV['RUBY_VERSION'] - }.merge(rspec_variables).merge(jest_variables) + }.merge(rspec_variables).merge(other_jobs_variables) end def scan_jobs each_job do |job| - detect_rspec(job) || detect_jest(job) + detect_rspec(job) || detect_other_jobs(job) end end @@ -48,32 +64,32 @@ class GenerateAsIfFossEnv end def detect_rspec(job) - rspec_type = job.name[/^rspec ([\w\-]+)/, 1] + rspec_type = job.name[/^rspec(?:-all)? ([\w\-]+)/, 1] rspec_jobs << rspec_type if rspec_type end - def detect_jest(job) - jest_type = job.name[/^jest([\w\-]*)/, 1] - - jest_jobs << jest_type if jest_type + def detect_other_jobs(job) + other_jobs << job.name if FOSS_JOBS.member?(job.name) end def rspec_variables return {} if rspec_jobs.empty? rspec_jobs.inject({ ENABLE_RSPEC: 'true' }) do |result, rspec| - result.merge("ENABLE_RSPEC_#{rspec.upcase.tr('-', '_')}": 'true') + result.merge("ENABLE_RSPEC_#{job_name_to_variable_name(rspec)}": 'true') end end - def jest_variables - return {} if jest_jobs.empty? - - jest_jobs.inject({ ENABLE_JEST: 'true' }) do |result, jest| - result.merge("ENABLE_JEST#{jest.upcase.tr('-', '_')}": 'true') + def other_jobs_variables + other_jobs.inject({}) do |result, job_name| + result.merge("ENABLE_#{job_name_to_variable_name(job_name)}": 'true') end end + + def job_name_to_variable_name(name) + name.upcase.tr('-: ', '_') + end end GenerateAsIfFossEnv.new.display if $PROGRAM_NAME == __FILE__ |