Class: Gitlab::QA::Reporter
- Inherits:
-
Object
- Object
- Gitlab::QA::Reporter
- Defined in:
- lib/gitlab/qa/reporter.rb
Class Method Summary collapse
-
.invoke(args) ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/PerceivedComplexity.
Class Method Details
.invoke(args) ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/PerceivedComplexity
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/gitlab/qa/reporter.rb', line 10 def self.invoke(args) = {} = {} = OptionParser.new do |opts| opts. = 'Usage: gitlab-qa-reporter [options]' opts.on('--prepare-stage-reports FILES', 'Prepare separate reports for each Stage from the provided JUnit XML files') do |files| [:prepare_stage_reports] = true [:input_files] = files if files end opts.on('--report-results FILES', String, 'Report test results from JUnit XML files in GitLab test cases and results issues') do |files| [:report_results] = true [:input_files] = files if files end opts.on('--relate-failure-issue FILES', String, 'Relate test failures to failure issues from RSpec JSON files') do |files| [:relate_failure_issue] = true [:input_files] = files if files end opts.on('--max-diff-ratio DIFF_RATO', Float, 'Max stacktrace diff ratio for QA failure issues detection. Used by with --relate-failure-issue') do |value| [:max_diff_ratio] = value end opts.on('-p', '--project PROJECT_ID', String, 'A valid project ID. Can be an integer or a group/project string. Required by --relate-failure-issue') do |value| [:project] = value end opts.on('--results-issue-project RESULTS_ISSUE_PROJECT_ID', String, 'A valid project ID. Can be an integer or a group/project string. Required by --report-results') do |value| [:results_issue_project] = value end opts.on('--test-case-project TEST_CASE_PROJECT_ID', String, 'A valid project ID. Can be an integer or a group/project string. Required by --report-results') do |value| [:test_case_project] = value end opts.on('--generate-test-session FILES', String, 'Generate test session report') do |files| [:generate_test_session] = true [:input_files] = files if files end opts.on('-t', '--token ACCESS_TOKEN', String, 'A valid access token. Required by --report-results and --relate-failure-issue') do |value| [:token] = value end opts.on('--post-to-slack MSG', 'Post message to slack') do |msg| [:post_to_slack] = true [:message] = msg end opts.on('--include-summary-table FILES', 'Create a results summary table to post to slack. To be used with --post-to-slack.') do |files| raise 'This option should be used with --post-to-slack.' unless [:post_to_slack] [:message] = [:message] + "\n\n" + Gitlab::QA::Report::SummaryTable.create(input_files: files) end opts.on('--update-screenshot-path FILES', "Update the path to screenshots to container's host") do |files| [:update_screenshot_path] = true [:files] = files end opts.on('--dry-run', "Perform a dry-run (don't create or update issues or test cases)") do |files| [:dry_run] = true end opts.on_tail('-v', '--version', 'Show the version') do require 'gitlab/qa/version' puts "#{$PROGRAM_NAME} : #{VERSION}" exit end opts.on_tail('-h', '--help', 'Show the usage') do puts opts exit end opts.parse(args) end if args.any? if .delete(:prepare_stage_reports) Gitlab::QA::Report::PrepareStageReports.new(**).invoke! elsif .delete(:relate_failure_issue) [:token] = Runtime::TokenFinder.find_token!([:token]) Gitlab::QA::Report::RelateFailureIssue.new(**).invoke! elsif .delete(:report_results) [:token] = Runtime::TokenFinder.find_token!([:token]) Gitlab::QA::Report::ReportResults.new(**).invoke! elsif .delete(:generate_test_session) [:token] = Runtime::TokenFinder.find_token!([:token]) Gitlab::QA::Report::GenerateTestSession.new(**).invoke! elsif .delete(:post_to_slack) Gitlab::QA::Slack::PostToSlack.new(**).invoke! elsif .delete(:update_screenshot_path) Gitlab::QA::Report::UpdateScreenshotPath.new(**).invoke! end else puts exit 1 end end |