Sha256: 904a6131034dfc9dd7ec2e160e637733726b656f2e848b703f2fe25a799b4195

Contents?: true

Size: 1.24 KB

Versions: 57

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

require 'nokogiri'
require 'table_print'

module GitlabQuality
  module TestTooling
    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

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
gitlab_quality-test_tooling-0.8.2 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-0.8.1 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-0.8.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-0.7.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-0.6.2 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-0.6.1 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-0.6.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-0.5.1 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-0.5.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-0.4.3 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-0.4.2 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-0.4.1 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-0.4.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-0.3.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-0.2.2 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-0.2.1 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-0.2.0 lib/gitlab_quality/test_tooling/summary_table.rb