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-1.28.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.24.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.23.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.22.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.21.1 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.21.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.20.1 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.20.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.19.1 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.19.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.18.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.17.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.15.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.14.2 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.14.1 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.14.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.13.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.12.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.11.0 lib/gitlab_quality/test_tooling/summary_table.rb
gitlab_quality-test_tooling-1.10.1 lib/gitlab_quality/test_tooling/summary_table.rb