summaryrefslogtreecommitdiff
path: root/scripts/merge-html-reports
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2019-07-18 12:47:43 +0100
committerFilipa Lacerda <filipa@gitlab.com>2019-07-18 12:47:43 +0100
commitd158efa8a2012bc2d6a80f71c765aefb677fe38e (patch)
tree59923c49efd8562af815db708308f003b80fb318 /scripts/merge-html-reports
parent0f7d462b6a16ffa40aae162be7d292ce2e00246e (diff)
parent3069cb25451cf9aad4840551b7286fee1c5aebc8 (diff)
downloadgitlab-ce-10009-ee-board.tar.gz
Merge branch 'master' into 10009-ee-board10009-ee-board
* master: (34 commits) Set correct file mode for autocomplete images Ensure visibility icons in group/project listings are grey FE remove create branch call in IDE commit Add start_sha to commits API Localize updated text on projects list page Perform more redactions in Redis performance bar traces Refactor all existing usages of .act Unquarantine object storage test Go guide: be more explicit on testing frameworks + diffing test results Doc for "Move external authorization service API management to EE" Fix unordered list spacing Refactor RedisCounter and WebIdeCommitsCounter Move boards switcher partial Add tests for when deploy token usernames are not unique Fix factory default for pages_access_level Add documentation surrounding [data-qa-selector] Mockify jquery and axios packages Add docs about auto-injected Jest mocks Add rule_type to approval_project_rules typo ...
Diffstat (limited to 'scripts/merge-html-reports')
-rwxr-xr-xscripts/merge-html-reports84
1 files changed, 84 insertions, 0 deletions
diff --git a/scripts/merge-html-reports b/scripts/merge-html-reports
new file mode 100755
index 00000000000..7d1e15186c8
--- /dev/null
+++ b/scripts/merge-html-reports
@@ -0,0 +1,84 @@
+#!/usr/bin/env ruby
+
+require 'nokogiri'
+
+main_report_file = ARGV.shift
+unless main_report_file
+ puts 'usage: merge-html-reports <main-report> <base-artifact-url> [parallel reports...]'
+ exit 1
+end
+
+base_artifact_url = ARGV.shift
+unless base_artifact_url
+ puts 'usage: merge-html-reports <main-report> <base-artifact-url> [parallel reports...]'
+ exit 1
+end
+
+# Create the base report with empty body tag
+new_report = Nokogiri::HTML.parse(File.read(ARGV[0]))
+new_report.at_css('body').remove
+empty_body = Nokogiri::XML::Node.new('body', new_report)
+new_report.at_css('head').add_next_sibling(empty_body)
+
+ARGV.each do |report_file|
+ report = Nokogiri::HTML.parse(File.read(report_file))
+
+ report.css('a').each do |link|
+ link_suffix = link['href'].slice(19..-1)
+ link['href'] = base_artifact_url + link_suffix
+ end
+
+ header = report.css('div #rspec-header')
+ tests = report.css('dt[id^="example_group_"]')
+
+ tests.each do |test|
+ title = test.parent
+ group = title.parent
+ script = title.css('script')
+
+ if script.inner_html.include? 'makeYellow'
+ test.remove_class('passed')
+ test.add_class('not_implemented')
+
+ group.remove_class('passed')
+ group.add_class('not_implemented')
+ header.add_class('not_implemented')
+
+ script.remove
+ test.next_sibling.remove
+ test.next_sibling.remove
+
+ elsif script.inner_html.include? 'makeRed'
+ test.remove_class('passed')
+ test.add_class('failed')
+
+ group.remove_class('passed')
+ group.add_class('failed')
+ header.add_class('failed')
+
+ script.remove
+ test.next_sibling.remove
+ test.next_sibling.remove
+ end
+ end
+
+ duration = report.at_css('p#duration')
+ totals = report.at_css('p#totals')
+
+ duration_script = report.css('div.results script')[-2]
+ totals_script = report.css('div.results script')[-1]
+
+ duration_text = duration_script.text.slice(49..-3)
+ totals_text = totals_script.text.slice(47..-3)
+
+ duration.inner_html = duration_text
+ totals.inner_html = totals_text
+
+ duration_script.remove
+ totals_script.remove
+
+ # Add the new result after the last one to keep the test order
+ new_report.css('body')[-1].add_next_sibling(report.at_css('body'))
+end
+
+File.write(main_report_file, new_report)