Class: Fastlane::Actions::DangerAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/danger.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, lane_context, method_missing, other_action, output, return_value, sample_return_value, sh, step_text

Class Method Details

.authorsObject



83
84
85
# File 'lib/fastlane/actions/danger.rb', line 83

def self.authors
  ["KrauseFx"]
end

.available_optionsObject



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
# File 'lib/fastlane/actions/danger.rb', line 33

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :use_bundle_exec,
                                 env_name: "FL_DANGER_USE_BUNDLE_EXEC",
                                 description: "Use bundle exec when there is a Gemfile presented",
                                 is_string: false,
                                 default_value: true),
    FastlaneCore::ConfigItem.new(key: :verbose,
                                 env_name: "FL_DANGER_VERBOSE",
                                 description: "Show more debugging information",
                                 is_string: false,
                                 default_value: false),
    FastlaneCore::ConfigItem.new(key: :danger_id,
                                 env_name: "FL_DANGER_ID",
                                 description: "The identifier of this Danger instance",
                                 is_string: true,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :dangerfile,
                                 env_name: "FL_DANGER_DANGERFILE",
                                 description: "The location of your Dangerfile",
                                 is_string: true,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :github_api_token,
                                 env_name: "FL_DANGER_GITHUB_API_TOKEN",
                                 description: "GitHub API token for danger",
                                 is_string: true,
                                 optional: true)
  ]
end

.categoryObject



79
80
81
# File 'lib/fastlane/actions/danger.rb', line 79

def self.category
  :misc
end

.descriptionObject



22
23
24
# File 'lib/fastlane/actions/danger.rb', line 22

def self.description
  "Runs `danger` for the project"
end

.detailsObject



26
27
28
29
30
31
# File 'lib/fastlane/actions/danger.rb', line 26

def self.details
  [
    "Formalize your Pull Request etiquette.",
    "More information: https://github.com/danger/danger"
  ].join("\n")
end

.example_codeObject



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/fastlane/actions/danger.rb', line 67

def self.example_code
  [
    'danger',
    'danger(
      danger_id: "unit-tests",
      dangerfile: "tests/MyOtherDangerFile",
      github_api_token: ENV["GITHUB_API_TOKEN"],
      verbose: true
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/fastlane/actions/danger.rb', line 63

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fastlane/actions/danger.rb', line 4

def self.run(params)
  Actions.verify_gem!('danger')
  cmd = []

  cmd << 'bundle exec' if File.exist?('Gemfile') && params[:use_bundle_exec]
  cmd << 'danger'
  cmd << '--verbose' if params[:verbose]

  danger_id = params[:danger_id]
  dangerfile = params[:dangerfile]
  cmd << "--danger_id=#{danger_id}" if danger_id
  cmd << "--dangerfile=#{dangerfile}" if dangerfile

  ENV['DANGER_GITHUB_API_TOKEN'] = params[:github_api_token] if params[:github_api_token]

  Actions.sh(cmd.join(' '))
end