Sha256: fe4def6386aed722b2d3ed5a049cecb7e892b4211ffe332450ec2af66dd15462

Contents?: true

Size: 1.29 KB

Versions: 44

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

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

44 entries across 44 versions & 1 rubygems

Version Path
gitlab-qa-8.14.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.13.1 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.13.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.12.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.11.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.10.2 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.10.1 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.10.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.9.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.8.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.7.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.6.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.5.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.4.2 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.4.1 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.4.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.3.2 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.3.1 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.3.0 lib/gitlab/qa/report/summary_table.rb
gitlab-qa-8.2.0 lib/gitlab/qa/report/summary_table.rb