From 9d7439fd87f1eba38b00b932f3fa3f7da68deb7c Mon Sep 17 00:00:00 2001 From: John McDonnell Date: Mon, 7 Apr 2025 10:54:51 +0100 Subject: [PATCH 1/6] Fix Layout/LineLength for specs --- spec/gitlab/qa/component/license_ops_spec.rb | 3 ++- spec/gitlab/qa/component/pipeline_ops_spec.rb | 11 +++++++++-- spec/gitlab/qa/component/runner_ops_spec.rb | 12 ++++++++++-- spec/gitlab/qa/support/gitlab_upgrade_path_spec.rb | 12 +++++++++--- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/spec/gitlab/qa/component/license_ops_spec.rb b/spec/gitlab/qa/component/license_ops_spec.rb index 9e3a73fe..236d4cd9 100644 --- a/spec/gitlab/qa/component/license_ops_spec.rb +++ b/spec/gitlab/qa/component/license_ops_spec.rb @@ -98,7 +98,8 @@ module Gitlab STDERR.puts "Failed to apply license" end RUBY - expected_command = "EE_LICENSE='test-key' gitlab-rails runner $'#{script.gsub("'", "\\\\'").gsub("\n", '\\n')}'" + expected_command = "EE_LICENSE='test-key' gitlab-rails runner " \ + "$'#{script.gsub("'", "\\\\'").gsub("\n", '\\n')}'" expect(license_ops.send(:build_license_command, 'test-key')).to eq(expected_command) end diff --git a/spec/gitlab/qa/component/pipeline_ops_spec.rb b/spec/gitlab/qa/component/pipeline_ops_spec.rb index 0fe580cf..9c4a8800 100644 --- a/spec/gitlab/qa/component/pipeline_ops_spec.rb +++ b/spec/gitlab/qa/component/pipeline_ops_spec.rb @@ -25,8 +25,15 @@ module Gitlab describe '#start' do it 'executes pipeline command with correct parameters' do - expect(docker).to receive(:exec).with('gitlab-container', /PROJECT_NAME='test-project' gitlab-rails runner/) - expect(docker).to receive(:copy).with('gitlab-container', File.join(Dir.pwd, 'support', 'pipeline'), '/tmp/setup-scripts') + expect(docker).to receive(:exec).with( + 'gitlab-container', + /PROJECT_NAME='test-project' gitlab-rails runner/ + ) + expect(docker).to receive(:copy).with( + 'gitlab-container', + File.join(Dir.pwd, 'support', 'pipeline'), + '/tmp/setup-scripts' + ) pipeline_ops.start(gitlab, project_name) end end diff --git a/spec/gitlab/qa/component/runner_ops_spec.rb b/spec/gitlab/qa/component/runner_ops_spec.rb index ac7f3d68..3e17eb22 100644 --- a/spec/gitlab/qa/component/runner_ops_spec.rb +++ b/spec/gitlab/qa/component/runner_ops_spec.rb @@ -17,7 +17,12 @@ module Gitlab address: "http://gitlab.example.com", class: Struct.new(:name).new("Gitlab::QA::Component::Gitlab") ).tap do |gitlab| - allow(gitlab).to receive_messages(docker: docker, name: 'gitlab-instance', network: 'test-network', address: 'http://gitlab.example.com') + allow(gitlab).to receive_messages( + docker: docker, + name: 'gitlab-instance', + network: 'test-network', + address: 'http://gitlab.example.com' + ) end end @@ -140,7 +145,10 @@ module Gitlab expect(command).to include('gitlab-runner register') expect(command).to include('gitlab-runner run') - expect(command).to include("printf 'concurrent = 1\\ncheck_interval = 0\\n\\n[session_server]\\n session_timeout = 1800' > /etc/gitlab-runner/config.toml") + expect(command).to include( + "printf 'concurrent = 1\\ncheck_interval = 0\\n\\n" \ + "[session_server]\\n session_timeout = 1800' > /etc/gitlab-runner/config.toml" + ) end end end diff --git a/spec/gitlab/qa/support/gitlab_upgrade_path_spec.rb b/spec/gitlab/qa/support/gitlab_upgrade_path_spec.rb index e3d88475..09fe21b4 100644 --- a/spec/gitlab/qa/support/gitlab_upgrade_path_spec.rb +++ b/spec/gitlab/qa/support/gitlab_upgrade_path_spec.rb @@ -101,7 +101,9 @@ describe Gitlab::QA::Support::GitlabUpgradePath do allow(Gitlab::QA::Runtime::Logger).to receive(:logger).and_return(logger_double) allow(logger_double).to receive(:error) - expect(logger_double).to receive(:error).with("Invalid 'current_version' format: 17.8-ee. Expected format: MAJOR.MINOR.PATCH (e.g., 17.8.2)") + expect(logger_double).to receive(:error).with( + "Invalid 'current_version' format: 17.8-ee. Expected format: MAJOR.MINOR.PATCH (e.g., 17.8.2)" + ) expect { described_class.new(current_version, semver, "ee") }.to raise_error(SystemExit) end end @@ -139,7 +141,9 @@ describe Gitlab::QA::Support::GitlabUpgradePath do allow(Gitlab::QA::Runtime::Logger).to receive(:logger).and_return(logger_double) allow(logger_double).to receive(:info) - expect(logger_double).to receive(:info).with("Skipping upgrade test as next version after 18.0.3 is not yet available") + expect(logger_double).to receive(:info).with( + "Skipping upgrade test as next version after 18.0.3 is not yet available" + ) expect { upgrade_path }.to raise_error(SystemExit) end end @@ -197,7 +201,9 @@ describe Gitlab::QA::Support::GitlabUpgradePath do end it "logs an error and exits" do - expect(logger_double).to receive(:error).with("Skipping upgrade test as internal patch upgrades are not supported without dev access token") + expect(logger_double).to receive(:error).with( + "Skipping upgrade test as internal patch upgrades are not supported without dev access token" + ) expect { upgrade_path }.to raise_error(SystemExit) end end -- GitLab From 37bfe1a0a953b26792d8f6fbe53c33b419e222e8 Mon Sep 17 00:00:00 2001 From: John McDonnell Date: Mon, 7 Apr 2025 10:55:08 +0100 Subject: [PATCH 2/6] Fix Layout/LineLength for lib files --- lib/gitlab/qa/component/base.rb | 8 ++++++-- lib/gitlab/qa/component/gitlab.rb | 12 ++++++++---- lib/gitlab/qa/component/project_importer.rb | 5 ++++- .../decomposition_multiple_db.rb | 4 ++-- lib/gitlab/qa/scenario/cli_commands.rb | 4 +++- .../test/integration/ai_gateway_base.rb | 3 ++- .../continuous_vulnerability_scanning.rb | 17 ++++++++++++++--- lib/gitlab/qa/scenario/test/integration/geo.rb | 6 ++++-- .../qa/scenario/test/integration/import.rb | 16 +++++++++++++--- .../qa/scenario/test/integration/opensearch.rb | 3 ++- .../test/omnibus/update_from_previous.rb | 8 ++++++-- lib/gitlab/qa/support/gitlab_upgrade_path.rb | 11 ++++++++--- lib/gitlab/qa/support/http_request.rb | 13 +++++++++++-- lib/gitlab/qa/support/shell_command.rb | 5 ++++- 14 files changed, 87 insertions(+), 28 deletions(-) diff --git a/lib/gitlab/qa/component/base.rb b/lib/gitlab/qa/component/base.rb index d7afd33c..ce1778d4 100644 --- a/lib/gitlab/qa/component/base.rb +++ b/lib/gitlab/qa/component/base.rb @@ -210,7 +210,9 @@ module Gitlab "for debugging the test failure locally.") # Tailing the reconfigure logs after retries are over and before raising exception - Runtime::Logger.info("Tail of the reconfigure log file, see artifacts for full log: #{reconfigure_log_file}") + Runtime::Logger.info( + "Tail of the reconfigure log file, see artifacts for full log: #{reconfigure_log_file}" + ) Support::ShellCommand.new("tail -n 100 #{reconfigure_log_file}", stream_output: true).execute! end @@ -225,7 +227,9 @@ module Gitlab if !reconfigure_log_file.nil? && retries == 3 # Tailing the reconfigure logs after retries are over and before raising exception - Runtime::Logger.info("Tail of the reconfigure log file, see artifacts for full log: #{reconfigure_log_file}") + Runtime::Logger.info( + "Tail of the reconfigure log file, see artifacts for full log: #{reconfigure_log_file}" + ) Support::ShellCommand.new("tail -n 100 #{reconfigure_log_file}", stream_output: true).execute! end diff --git a/lib/gitlab/qa/component/gitlab.rb b/lib/gitlab/qa/component/gitlab.rb index f9890cef..1187f356 100644 --- a/lib/gitlab/qa/component/gitlab.rb +++ b/lib/gitlab/qa/component/gitlab.rb @@ -214,8 +214,7 @@ module Gitlab end def get_reconfigure_log_file_from_artefact - all_reconfigure_log_file = Dir["#{Runtime::Env.host_artifacts_dir}/*reconfigure.log"].sort_by { |f| File.mtime(f) } - all_reconfigure_log_file.last + Dir["#{Runtime::Env.host_artifacts_dir}/*reconfigure.log"].max_by { |f| File.mtime(f) } end private :log_file @@ -229,7 +228,8 @@ module Gitlab if line.include?('There was an error running gitlab-ctl reconfigure') Runtime::Logger.error( - "Failure while running gitlab-ctl reconfigure command. Please check the #{log_file_path} in the artefact for more info" + "Failure while running gitlab-ctl reconfigure command." \ + "Please check the #{log_file_path} in the artefact for more info" ) end @@ -368,7 +368,11 @@ module Gitlab File.open("#{Runtime::Env.host_artifacts_dir}/pg_stats.log", 'a') do |file| file << "#{Time.now.strftime('%Y-%m-%d %H:%M:%S')} -- #{name} -- Postgres statistics after test run:\n" file << "Live and dead row counts:\n" - file << @docker.exec(name, %(gitlab-psql -c 'select n_live_tup, n_dead_tup, relname from pg_stat_all_tables order by n_live_tup DESC, n_dead_tup DESC;')) + file << @docker.exec( + name, + "gitlab-psql -c 'select n_live_tup, n_dead_tup, relname from pg_stat_all_tables " \ + "order by n_live_tup DESC, n_dead_tup DESC;'" + ) file << "Cumulative user table statistics:\n" file << @docker.exec(name, %(gitlab-psql -c 'select * from pg_stat_user_tables;')) end diff --git a/lib/gitlab/qa/component/project_importer.rb b/lib/gitlab/qa/component/project_importer.rb index 63a2c2bb..613da340 100644 --- a/lib/gitlab/qa/component/project_importer.rb +++ b/lib/gitlab/qa/component/project_importer.rb @@ -55,7 +55,10 @@ module Gitlab def build_import_command(script, project_url, project_name, project_path) escaped_script = script.gsub("'", "\\\\'").gsub("\n", "\\n") - "PROJECT_URL='#{project_url}' PROJECT_NAME='#{project_name}' PROJECT_PATH='#{project_path}' gitlab-rails runner $'#{escaped_script}'" + "PROJECT_URL='#{project_url}' " \ + "PROJECT_NAME='#{project_name}' " \ + "PROJECT_PATH='#{project_path}' " \ + "gitlab-rails runner $'#{escaped_script}'" end end end diff --git a/lib/gitlab/qa/runtime/omnibus_configurations/decomposition_multiple_db.rb b/lib/gitlab/qa/runtime/omnibus_configurations/decomposition_multiple_db.rb index a93636a2..fcba5a49 100644 --- a/lib/gitlab/qa/runtime/omnibus_configurations/decomposition_multiple_db.rb +++ b/lib/gitlab/qa/runtime/omnibus_configurations/decomposition_multiple_db.rb @@ -5,7 +5,7 @@ module Gitlab module Runtime module OmnibusConfigurations class DecompositionMultipleDb < Default - DATABASE_EXISTENCE_CHECK_COMMAND = <<~CMD.chomp + DB_EXISTENCE_CHECK_CMD = <<~CMD.chomp gitlab-psql -d gitlabhq_production_ci -c 'select 1' 2>1 > /dev/null CMD @@ -28,7 +28,7 @@ module Gitlab "sed -i 's/#gitlab_rails/gitlab_rails/g' /etc/gitlab/gitlab.rb", "gitlab-ctl reconfigure", # Create database only if it does not exist. - "#{DATABASE_EXISTENCE_CHECK_COMMAND} || gitlab-psql -c 'create database gitlabhq_production_ci owner gitlab'", + "#{DB_EXISTENCE_CHECK_CMD} || gitlab-psql -c 'create database gitlabhq_production_ci owner gitlab'", "gitlab-psql -d gitlabhq_production_ci -c 'create extension if not exists btree_gist'", "gitlab-psql -d gitlabhq_production_ci -c 'create extension if not exists pg_trgm'", # Load schema only if it does not exist. diff --git a/lib/gitlab/qa/scenario/cli_commands.rb b/lib/gitlab/qa/scenario/cli_commands.rb index 9e6afe05..b2c73929 100644 --- a/lib/gitlab/qa/scenario/cli_commands.rb +++ b/lib/gitlab/qa/scenario/cli_commands.rb @@ -7,8 +7,10 @@ module Gitlab GIT_LFS_VERSION = '2.8.0' def self.git_lfs_install_commands + base_url = 'https://github.com/git-lfs/git-lfs/releases/download' + download_path = "#{base_url}/v#{GIT_LFS_VERSION}/git-lfs-linux-amd64-v#{GIT_LFS_VERSION}.tar.gz" [ - "cd /tmp ; curl -qsL https://github.com/git-lfs/git-lfs/releases/download/v#{GIT_LFS_VERSION}/git-lfs-linux-amd64-v#{GIT_LFS_VERSION}.tar.gz | tar xzvf -", + "cd /tmp ; curl -qsL #{download_path} | tar xzvf -", 'cp /tmp/git-lfs /usr/local/bin' ].freeze end diff --git a/lib/gitlab/qa/scenario/test/integration/ai_gateway_base.rb b/lib/gitlab/qa/scenario/test/integration/ai_gateway_base.rb index 3a889a9a..ed41022f 100644 --- a/lib/gitlab/qa/scenario/test/integration/ai_gateway_base.rb +++ b/lib/gitlab/qa/scenario/test/integration/ai_gateway_base.rb @@ -62,7 +62,8 @@ module Gitlab gitlab.docker.exec( gitlab.name, - "ASSIGN_SEATS=#{@assign_seats} HAS_ADD_ON=#{@has_add_on} gitlab-rails runner #{SETUP_DEST_PATH}/gitlab_duo_setup.rb", + "ASSIGN_SEATS=#{@assign_seats} HAS_ADD_ON=#{@has_add_on}" \ + "gitlab-rails runner #{SETUP_DEST_PATH}/gitlab_duo_setup.rb", mask_secrets: gitlab.secrets ) end diff --git a/lib/gitlab/qa/scenario/test/integration/continuous_vulnerability_scanning.rb b/lib/gitlab/qa/scenario/test/integration/continuous_vulnerability_scanning.rb index 514c50fe..2b5ca221 100644 --- a/lib/gitlab/qa/scenario/test/integration/continuous_vulnerability_scanning.rb +++ b/lib/gitlab/qa/scenario/test/integration/continuous_vulnerability_scanning.rb @@ -43,13 +43,17 @@ module Gitlab end def generate_vulnerabilities - template = File.read(File.expand_path('../../../../../../fixtures/cvs/vulnerabilities_template.erb', __dir__)) + template = File.read( + File.expand_path('../../../../../../fixtures/cvs/vulnerabilities_template.erb', __dir__) + ) ERB.new(template).result(binding) end def generate_filepath File.join( - "/opt/gitlab/embedded/service/gitlab-rails/vendor/package_metadata/advisories/v2/rubygem/#{Time.now.to_i}", + "/opt/gitlab/embedded/service/gitlab-rails", + "vendor/package_metadata/advisories/v2/rubygem", + Time.now.to_i.to_s, '000000000.ndjson' ) end @@ -60,7 +64,14 @@ module Gitlab end def start_advisory_sync_worker(gitlab) - gitlab.docker.exec(gitlab.name, "PM_SYNC_IN_DEV=true gitlab-rails runner 'loop do PackageMetadata::AdvisoriesSyncWorker.new.perform; sleep 30; end' &") + gitlab.docker.exec( + gitlab.name, + "PM_SYNC_IN_DEV=true gitlab-rails runner " \ + "'loop do " \ + "PackageMetadata::AdvisoriesSyncWorker.new.perform; " \ + "sleep 30; " \ + "end' &" + ) end def run_specs(gitlab, *rspec_args) diff --git a/lib/gitlab/qa/scenario/test/integration/geo.rb b/lib/gitlab/qa/scenario/test/integration/geo.rb index 6ce61ae2..ffac6605 100644 --- a/lib/gitlab/qa/scenario/test/integration/geo.rb +++ b/lib/gitlab/qa/scenario/test/integration/geo.rb @@ -35,7 +35,8 @@ module Gitlab sidekiq['concurrency'] = 2; puma['worker_processes'] = 2; OMNIBUS - primary.exec_commands = fast_ssh_key_lookup_commands + QA::Scenario::CLICommands.git_lfs_install_commands + primary.exec_commands = + fast_ssh_key_lookup_commands + QA::Scenario::CLICommands.git_lfs_install_commands primary.instance do Component::Gitlab.perform do |secondary| @@ -57,7 +58,8 @@ module Gitlab sidekiq['concurrency'] = 2; puma['worker_processes'] = 2; OMNIBUS - secondary.exec_commands += fast_ssh_key_lookup_commands + QA::Scenario::CLICommands.git_lfs_install_commands + secondary.exec_commands += + fast_ssh_key_lookup_commands + QA::Scenario::CLICommands.git_lfs_install_commands secondary.act do # TODO, we do not wait for secondary to start because of diff --git a/lib/gitlab/qa/scenario/test/integration/import.rb b/lib/gitlab/qa/scenario/test/integration/import.rb index d950dc43..39bccd7b 100644 --- a/lib/gitlab/qa/scenario/test/integration/import.rb +++ b/lib/gitlab/qa/scenario/test/integration/import.rb @@ -36,7 +36,7 @@ module Gitlab # => will perform import from gitlab-ee:17.4.0-ee.0 to gitlab-ee # # @param [String] target_release target gitlab instance version release docker image(default) - # @param [String] source_release source gitlab instance version, if its not passed takes the target release as default + # @param [String] source_release source gitlab instance version (defaults to target_release) # @param [Array] *rspec_args rspec arguments # @return [void] def perform(target_release, source_release = nil, *rspec_args) @@ -145,8 +145,18 @@ module Gitlab # @return [Array] def build_gitlab_instances(source_release, target_release) [ - { instance: source_gitlab, name: "import-source", additional_hosts: [], release: source_release }, - { instance: target_gitlab, name: "import-target", additional_hosts: mocked_hosts, release: target_release } + { + instance: source_gitlab, + name: "import-source", + additional_hosts: [], + release: source_release + }, + { + instance: target_gitlab, + name: "import-target", + additional_hosts: mocked_hosts, + release: target_release + } ] end diff --git a/lib/gitlab/qa/scenario/test/integration/opensearch.rb b/lib/gitlab/qa/scenario/test/integration/opensearch.rb index 5c0ccb37..45a0f584 100644 --- a/lib/gitlab/qa/scenario/test/integration/opensearch.rb +++ b/lib/gitlab/qa/scenario/test/integration/opensearch.rb @@ -10,7 +10,8 @@ module Gitlab def initialize @gitlab_name = 'gitlab-opensearch' - # Currently the test suite that tests Advanced Search features is called 'Elasticsearch' which we hope to abstract to 'Advancedsearch' in the future + # Currently the test suite that tests Advanced Search features is called 'Elasticsearch' + # which we hope to abstract to 'Advancedsearch' in the future @spec_suite = 'QA::EE::Scenario::Test::Integration::Elasticsearch' end diff --git a/lib/gitlab/qa/scenario/test/omnibus/update_from_previous.rb b/lib/gitlab/qa/scenario/test/omnibus/update_from_previous.rb index 1faddbd9..6ac647c5 100644 --- a/lib/gitlab/qa/scenario/test/omnibus/update_from_previous.rb +++ b/lib/gitlab/qa/scenario/test/omnibus/update_from_previous.rb @@ -11,7 +11,8 @@ module Gitlab attr_reader :rspec_args # Test update from N - 1 (major|minor|patch) version to current release - # Run health check (or smoke if below 17.1.0) test suite on previous release to populate some data in database before update + # Run health check (or smoke if below 17.1.0) test suite on previous release + # to populate some data in database before update # # @example # perform(gitlab-ee:dev-tag, 15.3.0-pre, major) @@ -131,7 +132,10 @@ module Gitlab # @param [Array] rspec_args # @return [void] def run_specs(gitlab, release, rspec_args) # rubocop:disable Metrics/AbcSize - Runtime::Logger.info("Running test suite to verify update and seed data in environment") unless upgrade_path.first != release + unless upgrade_path.first != release + Runtime::Logger.info("Running test suite to verify update and seed data in environment") + end + Runtime::Logger.info("Running test suite to verify update") unless current_release != release Component::Specs.perform do |specs| diff --git a/lib/gitlab/qa/support/gitlab_upgrade_path.rb b/lib/gitlab/qa/support/gitlab_upgrade_path.rb index 1da990ea..7463e10f 100644 --- a/lib/gitlab/qa/support/gitlab_upgrade_path.rb +++ b/lib/gitlab/qa/support/gitlab_upgrade_path.rb @@ -16,12 +16,15 @@ module Gitlab @logger = Runtime::Logger.logger unless current_version.match?(GitlabVersionInfo::VERSION_PATTERN) - logger.error("Invalid 'current_version' format: #{current_version}. Expected format: MAJOR.MINOR.PATCH (e.g., 17.8.2)") + logger.error( + "Invalid 'current_version' format: #{current_version}. Expected format: MAJOR.MINOR.PATCH (e.g., 17.8.2)" + ) exit 1 end @version_info = GitlabVersionInfo.new(current_version, edition) - @current_version = Gem::Version.new(current_version.match(GitlabVersionInfo::VERSION_PATTERN)[:version]) # Extract version without postfixes like pre or ee + # Extract version without postfixes like pre or ee + @current_version = Gem::Version.new(current_version.match(GitlabVersionInfo::VERSION_PATTERN)[:version]) @semver_component = semver_component @edition = edition end @@ -147,7 +150,9 @@ module Gitlab def find_latest_internal_tag(gitlab_int_reg_repo, docker) # Try to find the highest internal release tag, starting from 10 latest_internal_tag = nil - logger.info("Start searching for the latest released internal image for gitlab version: #{current_version}...") + logger.info( + "Start searching for the latest released internal image for gitlab version: #{current_version}..." + ) # Release team note: no more than 10 internal releases expected for version 10.downto(0) do |internal_num| diff --git a/lib/gitlab/qa/support/http_request.rb b/lib/gitlab/qa/support/http_request.rb index 6fa1aab6..4f5a72b2 100644 --- a/lib/gitlab/qa/support/http_request.rb +++ b/lib/gitlab/qa/support/http_request.rb @@ -8,7 +8,14 @@ module Gitlab module Support class HttpRequest # rubocop:disable Metrics/AbcSize - def self.make_http_request(method: 'get', url: nil, params: nil, headers: {}, show_response: false, fail_on_error: true) + def self.make_http_request( + method: 'get', + url: nil, + params: nil, + headers: {}, + show_response: false, + fail_on_error: true + ) raise "URL not defined for making request. Exiting..." unless url res = HTTP.follow.method(method).call(url, json: params, headers: headers) @@ -23,7 +30,9 @@ module Gitlab end end - raise "#{method.upcase} request failed!\nCode: #{res.code}\nResponse: #{res.body}\n" if fail_on_error && !res.status.success? + if fail_on_error && !res.status.success? + raise "#{method.upcase} request failed!\nCode: #{res.code}\nResponse: #{res.body}\n" + end res end diff --git a/lib/gitlab/qa/support/shell_command.rb b/lib/gitlab/qa/support/shell_command.rb index d21db8a6..f00c3fe3 100644 --- a/lib/gitlab/qa/support/shell_command.rb +++ b/lib/gitlab/qa/support/shell_command.rb @@ -68,7 +68,10 @@ module Gitlab # # @return [void] def fail! - logger.error("Shell command output:\n#{string_output}") unless @command.include?("docker attach") || stream_output + unless @command.include?("docker attach") || stream_output + logger.error("Shell command output:\n#{string_output}") + end + raise StatusError, "Command `#{mask_secrets(command).truncate(100)}` failed! " + "✘".red end -- GitLab From cc8819f108e04549fe4f4089c7139e72adec2add Mon Sep 17 00:00:00 2001 From: John McDonnell Date: Mon, 7 Apr 2025 10:55:43 +0100 Subject: [PATCH 3/6] Fix Layout/LineLength for all oustanding files --- rubocop/cop/gitlab/dangerous_interpolation.rb | 7 +++++-- support/data/admin_access_token_seed.rb | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/rubocop/cop/gitlab/dangerous_interpolation.rb b/rubocop/cop/gitlab/dangerous_interpolation.rb index 772ad04e..26be036f 100644 --- a/rubocop/cop/gitlab/dangerous_interpolation.rb +++ b/rubocop/cop/gitlab/dangerous_interpolation.rb @@ -17,7 +17,8 @@ module RuboCop class DangerousInterpolation < Base MSG = 'Sensitive variables should not be logged. ' \ - 'Please ensure that the interpolated variable is not sensitive. If not, add it to `ENV_VARIABLES` in the cop class.' + 'Please ensure that the interpolated variable is not sensitive.' \ + 'If not, add it to `ENV_VARIABLES` in the cop class.' # These values are taken from /lib/gitlab/qa/runtime/env.rb. Sensitive variables have been removed. ENV_VARIABLES = { @@ -144,7 +145,9 @@ module RuboCop PATTERN def on_send(node) - return unless heredoc_interpolation?(node) && node.parent.parent.dstr_type? && !ENV_VARIABLES.value?(node.source.split(".")[1].to_sym) + return unless heredoc_interpolation?(node) && + node.parent.parent.dstr_type? && + !ENV_VARIABLES.value?(node.source.split(".")[1].to_sym) add_offense(node) end diff --git a/support/data/admin_access_token_seed.rb b/support/data/admin_access_token_seed.rb index e2fcd6ef..5e247465 100644 --- a/support/data/admin_access_token_seed.rb +++ b/support/data/admin_access_token_seed.rb @@ -18,7 +18,8 @@ class AdminAccessTokenSeed admin_user.personal_access_tokens.build(token_params).tap do |pat| pat.set_token(TOKEN_VALUE) - pat.organization = Organizations::Organization.default_organization if Gitlab.version_info >= Gitlab::VersionInfo.new(17, 4) + version_check = Gitlab.version_info >= Gitlab::VersionInfo.new(17, 4) + pat.organization = Organizations::Organization.default_organization if version_check pat.save! end -- GitLab From d2552c93a2e5d962fff91cef3d728b9b2fa7a232 Mon Sep 17 00:00:00 2001 From: John McDonnell Date: Mon, 7 Apr 2025 11:04:20 +0100 Subject: [PATCH 4/6] Fixes Lint/MixedRegexpCaptureTypes for release tags --- lib/gitlab/qa/release.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/gitlab/qa/release.rb b/lib/gitlab/qa/release.rb index 027dbf10..5e452c3b 100644 --- a/lib/gitlab/qa/release.rb +++ b/lib/gitlab/qa/release.rb @@ -8,20 +8,20 @@ module Gitlab CANONICAL_REGEX = / \A (?ce|ee|jh) - (-qa)? - (:(?.+))? + (?:-qa)? + (?::(?.+))? \z /xi CUSTOM_GITLAB_IMAGE_REGEX = %r{ \A (? - (?[^/:]+(:(?\d+))?) + (?[^/:]+(?::(?\d+))?) (?.+) gitlab- (?ce|ee|jh) ) - (-qa)? - (:(?.+))? + (?:-qa)? + (?::(?.+))? \z }xi @@ -51,7 +51,7 @@ module Gitlab # version DEV_TAG_REGEX = / \A - (?\d+\.\d+(.\d+)?)\.(?\d+)-(?[A-Za-z0-9]+)\.(?[A-Za-z0-9]+) + (?\d+\.\d+(?:.\d+)?)\.(?\d+)-(?[A-Za-z0-9]+)\.(?[A-Za-z0-9]+) \z /xi -- GitLab From c1bb43d0190baed364e8a1e356cc957f52e5be9d Mon Sep 17 00:00:00 2001 From: John McDonnell Date: Mon, 7 Apr 2025 11:12:08 +0100 Subject: [PATCH 5/6] Fixes some Style/IfUnlessModifier rubocop failures --- lib/gitlab/qa/scenario/test/omnibus/update_from_previous.rb | 4 +++- lib/gitlab/qa/support/http_request.rb | 4 +++- lib/gitlab/qa/support/shell_command.rb | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/gitlab/qa/scenario/test/omnibus/update_from_previous.rb b/lib/gitlab/qa/scenario/test/omnibus/update_from_previous.rb index 6ac647c5..e884c2a0 100644 --- a/lib/gitlab/qa/scenario/test/omnibus/update_from_previous.rb +++ b/lib/gitlab/qa/scenario/test/omnibus/update_from_previous.rb @@ -133,7 +133,9 @@ module Gitlab # @return [void] def run_specs(gitlab, release, rspec_args) # rubocop:disable Metrics/AbcSize unless upgrade_path.first != release - Runtime::Logger.info("Running test suite to verify update and seed data in environment") + Runtime::Logger.info( + "Running test suite to verify update and seed data in environment" + ) end Runtime::Logger.info("Running test suite to verify update") unless current_release != release diff --git a/lib/gitlab/qa/support/http_request.rb b/lib/gitlab/qa/support/http_request.rb index 4f5a72b2..ebaf058f 100644 --- a/lib/gitlab/qa/support/http_request.rb +++ b/lib/gitlab/qa/support/http_request.rb @@ -31,7 +31,9 @@ module Gitlab end if fail_on_error && !res.status.success? - raise "#{method.upcase} request failed!\nCode: #{res.code}\nResponse: #{res.body}\n" + raise( + "#{method.upcase} request failed!\nCode: #{res.code}\nResponse: #{res.body}\n" + ) end res diff --git a/lib/gitlab/qa/support/shell_command.rb b/lib/gitlab/qa/support/shell_command.rb index f00c3fe3..85870bdc 100644 --- a/lib/gitlab/qa/support/shell_command.rb +++ b/lib/gitlab/qa/support/shell_command.rb @@ -69,7 +69,9 @@ module Gitlab # @return [void] def fail! unless @command.include?("docker attach") || stream_output - logger.error("Shell command output:\n#{string_output}") + logger.error( + "Shell command output:\n#{string_output}" + ) end raise StatusError, "Command `#{mask_secrets(command).truncate(100)}` failed! " + "✘".red -- GitLab From 260c4a58439c8f18c4403385915440efb934105e Mon Sep 17 00:00:00 2001 From: John McDonnell Date: Mon, 7 Apr 2025 11:17:33 +0100 Subject: [PATCH 6/6] Add a respond_to_missing? to compliment method_missing --- lib/gitlab/qa/runtime/scenario.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/gitlab/qa/runtime/scenario.rb b/lib/gitlab/qa/runtime/scenario.rb index 3f7cecfe..22795799 100644 --- a/lib/gitlab/qa/runtime/scenario.rb +++ b/lib/gitlab/qa/runtime/scenario.rb @@ -26,6 +26,12 @@ module Gitlab def method_missing(name, *) raise ArgumentError, "Scenario attribute `#{name}` not defined!" end + + def respond_to_missing?(_name, _include_private = false) + # Since method_missing raises an error for undefined attributes, + # we should return false to indicate we don't actually handle them + false + end end end end -- GitLab