From 934592ec0aa170e81c2c6eab92b7af2c4d46bbdd Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Mon, 23 Feb 2026 17:47:04 +0200 Subject: [PATCH] Refactore create_project_package to fix Rubocop offence Signed-off-by: Kostiantyn Kostiuk --- lib/engines/hcktest/tests.rb | 45 ++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/lib/engines/hcktest/tests.rb b/lib/engines/hcktest/tests.rb index ab63e266..62b60ed4 100644 --- a/lib/engines/hcktest/tests.rb +++ b/lib/engines/hcktest/tests.rb @@ -629,27 +629,38 @@ def handle_test_running end end - def create_project_package - package_playlist = @playlist.playlist if @project.options.test.package_with_playlist + sig { params(type: String, path: T.nilable(String)).returns(T.nilable(String)) } + def upload_package_asset(type, path) + return nil unless path - driver_path = @project.options.test.driver_path - supplemental_path = @project.options.test.supplemental_path - package_with_driver = @project.options.test.package_with_driver + unless File.exist?(path) + @logger.warn("#{type} path '#{path}' specified, but does not exist, skipping including") + return nil + end - remote_driver_path = nil - remote_supplemental_path = nil + remote_path = "#{STUDIO_PACKAGE_ASSETS_PATH}\\#{type}" + @logger.info("Uploading #{type.downcase} from '#{path}' to '#{remote_path}'") + @tools.upload_to_studio(path, remote_path) + remote_path + end - if package_with_driver && driver_path && File.exist?(driver_path) - remote_driver_path = "#{STUDIO_PACKAGE_ASSETS_PATH}\\Driver" - @logger.info("Uploading driver from '#{driver_path}' to '#{remote_driver_path}'") - @tools.upload_to_studio(driver_path, remote_driver_path) - end + sig { returns(T.nilable(String)) } + def prepare_package_driver_content + return unless @project.options.test.package_with_driver - if supplemental_path && File.exist?(supplemental_path) - remote_supplemental_path = "#{STUDIO_PACKAGE_ASSETS_PATH}\\Supplemental" - @logger.info("Uploading supplemental from '#{supplemental_path}' to '#{remote_supplemental_path}'") - @tools.upload_to_studio(supplemental_path, remote_supplemental_path) - end + upload_package_asset('Driver', @project.options.test.driver_path) + end + + sig { returns(T.nilable(String)) } + def prepare_package_supplemental_content + upload_package_asset('Supplemental', @project.options.test.supplemental_path) + end + + def create_project_package + package_playlist = @playlist.playlist if @project.options.test.package_with_playlist + + remote_driver_path = prepare_package_driver_content + remote_supplemental_path = prepare_package_supplemental_content res = @tools.create_project_package(@tag, package_playlist, nil, remote_driver_path, remote_supplemental_path) @logger.info('Results package successfully created')