Class: Fastlane::Actions::AllureCreateLaunchAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/stream_actions/actions/allure_create_launch.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.available_optionsObject



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
# File 'lib/fastlane/plugin/stream_actions/actions/allure_create_launch.rb', line 50

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      env_name: 'ALLURE_TOKEN',
      key: :token,
      description: 'Allure API Token'
    ),
    FastlaneCore::ConfigItem.new(
      key: :url,
      description: 'Testops URL'
    ),
    FastlaneCore::ConfigItem.new(
      key: :github_run_details,
      description: 'Github run details json',
      is_string: false,
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      env_name: 'GITHUB_EVENT_NAME',
      key: :github_event_name,
      description: 'Github event name',
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      env_name: 'GITHUB_EVENT',
      key: :github_event,
      description: 'Github Actions: toJson(github.event)',
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :project_id,
      description: 'Project identifier in Allure Testops'
    ),
    FastlaneCore::ConfigItem.new(
      key: :cron,
      description: 'Is this a cron job?',
      is_string: false,
      optional: true
    )
  ]
end

.descriptionObject



46
47
48
# File 'lib/fastlane/plugin/stream_actions/actions/allure_create_launch.rb', line 46

def self.description
  'Creates launch on Allure Testops'
end

.run(params) ⇒ Object



4
5
6
7
8
9
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
# File 'lib/fastlane/plugin/stream_actions/actions/allure_create_launch.rb', line 4

def self.run(params)
  tags = []

  launch_name =
    if params[:cron]
      'Cron checks'
    elsif params[:github_run_details].nil?
      'Local checks'
    elsif params[:github_event_name] == 'pull_request'
      pull_request = JSON.parse(params[:github_event])['pull_request']
      tags = pull_request['labels'].map { |label| { name: label['name'] } }
      pull_request['title']
    elsif params[:github_run_details]['head_commit']
      params[:github_run_details]['head_commit']['message']
    else
      params[:github_run_details]['name']
    end

  body = {
    projectId: params[:project_id],
    name: launch_name,
    tags: tags,
    autoclose: false,
    closed: false
  }.to_json

  launch_id = other_action.allure_api(
    url: params[:url],
    token: params[:token],
    path: '/launch',
    http_method: 'POST',
    request_body: body
  )['id']

  UI.success("Launch with id #{launch_id} created successfully 🎉")
  launch_id
end

.supported?(_platform) ⇒ Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/fastlane/plugin/stream_actions/actions/allure_create_launch.rb', line 92

def self.supported?(_platform)
  true
end