Class: Gitlab::QA::Report::UpdateScreenshotPath
- Inherits:
-
Object
- Object
- Gitlab::QA::Report::UpdateScreenshotPath
- Defined in:
- lib/gitlab/qa/report/update_screenshot_path.rb
Constant Summary collapse
- REGEX =
%r{(?<gitlab_qa_run>gitlab-qa-run-.*?(?=\/))\/(?<gitlab_ce_ee_qa>gitlab-(ee|ce)-qa-.*?(?=\/))}
- CONTAINER_PATH =
File.join(Docker::Volumes::QA_CONTAINER_WORKDIR, 'tmp').freeze
Instance Method Summary collapse
-
#initialize(files:) ⇒ UpdateScreenshotPath
constructor
A new instance of UpdateScreenshotPath.
- #invoke! ⇒ Object
Constructor Details
#initialize(files:) ⇒ UpdateScreenshotPath
Returns a new instance of UpdateScreenshotPath.
11 12 13 |
# File 'lib/gitlab/qa/report/update_screenshot_path.rb', line 11 def initialize(files:) @files = files end |
Instance Method Details
#invoke! ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/gitlab/qa/report/update_screenshot_path.rb', line 18 def invoke! Dir.glob(@files).each do |rspec_report_file| match_data = rspec_report_file.match(REGEX) artifact_path = "#{match_data[:gitlab_qa_run]}/#{match_data[:gitlab_ce_ee_qa]}" xml_report = rewrite_each_xml_screenshot_path(rspec_report_file, artifact_path) File.write(rspec_report_file, xml_report) puts "Saved #{rspec_report_file}" json_rspec_report_file = rspec_report_file.gsub('.xml', '.json') json_report = rewrite_each_json_screenshot_path(json_rspec_report_file, artifact_path) File.write(json_rspec_report_file, json_report) puts "Saved #{json_rspec_report_file}" end end |