Sha256: f94f4a00cfc1dbf95bedea68628e0f50e5ced6f042c906edcde20d3cc1beec87

Contents?: true

Size: 1.26 KB

Versions: 147

Compression:

Stored size: 1.26 KB

Contents

require 'nokogiri'
require 'table_print'

module Gitlab
  module QA
    module Report
      class SummaryTable
        def self.create(input_files:)
          "```\n#{TablePrint::Printer.table_print(collect_results(input_files))}```\n"
        end

        # rubocop:disable Metrics/AbcSize
        def self.collect_results(input_files)
          stage_wise_results = []

          Dir.glob(input_files).each do |report_file|
            stage_hash = {}
            stage_hash["Dev Stage"] = File.basename(report_file, ".*").capitalize

            report_stats = Nokogiri::XML(File.open(report_file)).children[0].attributes

            stage_hash["Total"] = report_stats["tests"].value
            stage_hash["Failures"] = report_stats["failures"].value
            stage_hash["Errors"] = report_stats["errors"].value
            stage_hash["Skipped"] = report_stats["skipped"].value
            stage_hash["Result"] = result_emoji(report_stats)

            stage_wise_results << stage_hash
          end

          stage_wise_results
        end
        # rubocop:enable Metrics/AbcSize

        def self.result_emoji(report_stats)
          report_stats["failures"].value.to_i.positive? || report_stats["errors"].value.to_i.positive? ? "❌" : "✅"
        end
      end
    end
  end
end

Version data entries

147 entries across 147 versions & 1 rubygems

Version Path
gitlab-qa-7.34.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.33.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.32.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.31.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.30.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.29.1 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.29.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.27.2 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.27.1 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.27.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.26.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.25.1 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.25.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.24.6 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.24.5 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.24.4 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.24.3 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.24.2 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.24.1 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-7.24.0 lib/gitlab/qa/report/summary_table.rb