class Fastlane::Actions::SummarizeXcresultReportAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/xcresult_actions/actions/summarize_xcresult_report_action.rb, line 73
def self.authors
  ["yutailang0119"]
end
available_options() click to toggle source
# File lib/fastlane/plugin/xcresult_actions/actions/summarize_xcresult_report_action.rb, line 49
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :file,
                                 env_name: "FL_SUMMARIZE_XCRESULT_REPORT_FILE",
                                 description: "`.xcresult` file to operate on",
                                 type: String,
                                 optional: false,
                                 verify_block: proc do |value|
                                   UI.user_error!("Please specify an extension of .xcresult") unless File.extname(value) == '.xcresult'
                                 end)
  ]
end
description() click to toggle source

@!group Documentation

# File lib/fastlane/plugin/xcresult_actions/actions/summarize_xcresult_report_action.rb, line 41
def self.description
  "Summarize about test coverage rate from `.xcresult` file"
end
details() click to toggle source
# File lib/fastlane/plugin/xcresult_actions/actions/summarize_xcresult_report_action.rb, line 45
def self.details
  "Summarize about test coverage rate from `.xcresult` file"
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/xcresult_actions/actions/summarize_xcresult_report_action.rb, line 77
def self.is_supported?(platform)
  [:ios, :mac].include?(platform)
end
output() click to toggle source
# File lib/fastlane/plugin/xcresult_actions/actions/summarize_xcresult_report_action.rb, line 62
def self.output
  [
    ['SUMMARIZE_XCRESULT_REPORT_JSON', 'The report summarizing from generated JSON by xccov'],
    ['RAW_XCRESULT_REPORT_JSON', 'The report as raw JSON generated by xccov']
  ]
end
return_value() click to toggle source
# File lib/fastlane/plugin/xcresult_actions/actions/summarize_xcresult_report_action.rb, line 69
def self.return_value
  "An array including the Target name (:target) and the Line Coverage Rate (:lineCoverage)."
end
run(params) click to toggle source
# File lib/fastlane/plugin/xcresult_actions/actions/summarize_xcresult_report_action.rb, line 12
def self.run(params)
  report_json = Helper::SummarizeXcresultReportHelper.xcresult_report_json(params[:file])

  summarized_report = report_json["targets"].map do |target|
    {
      'target' => target["name"],
      'lineCoverage' => target["lineCoverage"]
    }
  end

  if summarized_report.count > 1
    summarized_report.unshift(
      {
        'target' => 'Total',
        'lineCoverage' => report_json["lineCoverage"]
      }
    )
  end

  Actions.lane_context[SharedValues::RAW_XCRESULT_REPORT_JSON] = report_json
  Actions.lane_context[SharedValues::SUMMARIZE_XCRESULT_REPORT_JSON] = summarized_report

  summarized_report
end