Class: Fastlane::Actions::MaestroAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



48
49
50
# File 'lib/fastlane/plugin/maestro/actions/maestro.rb', line 48

def self.authors
  ['Marc Bormeth']
end

.available_optionsObject



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

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :command,
                                 env_name: 'FL_MAESTRO_COMMAND',
                                 description: 'Command to be executed (`download_samples`, `install`, or `test`)',
                                 type: String,
                                 default_value: 'test',
                                 verify_block: proc do |value|
                                   unless ["download_samples", "install", "test"].include?(value)
                                     UI.user_error!("Unsupported value '#{value}' for parameter ':command'! \nAvailable options: `download_samples`, `install`, `test`")
                                   end
                                 end),
    FastlaneCore::ConfigItem.new(key: :report_type,
                                 env_name: 'FL_MAESTRO_FORMAT',
                                 description: 'Format of the generated report (`junit`)',
                                 optional: true,
                                 type: String,
                                 default_value: '',
                                 verify_block: proc do |value|
                                   unless ["", "junit"].include?(value)
                                     UI.user_error!("Unsupported value '#{value}' for parameter ':format'! Available options: `junit`")
                                   end
                                 end),
    FastlaneCore::ConfigItem.new(key: :output,
                                 env_name: 'FL_MAESTRO_OUTPUT',
                                 description: 'Allows to override the report filename. Requires parameter :format to be set as well',
                                 optional: true,
                                 type: String,
                                 default_value: ''),
    FastlaneCore::ConfigItem.new(key: :device,
                                 env_name: 'FL_MAESTRO_DEVICE',
                                 description: 'iOS UDID or Android device name to be used for running the tests ',
                                 optional: true,
                                 type: String,
                                 default_value: ''),
    FastlaneCore::ConfigItem.new(key: :tests,
                                 env_name: 'FL_MAESTRO_TESTS',
                                 description: 'Maestro flow (or folder containing flows) to be executed',
                                 optional: true,
                                 type: String,
                                 verify_block: proc do |value|
                                   v = File.expand_path(value.to_s)
                                   UI.user_error!("No file or directory found with path '#{v}'") unless File.exist?(v)
                                 end),
    FastlaneCore::ConfigItem.new(key: :env_vars,
                                 env_name: 'FL_MAESTRO_ENV_VARIABLES',
                                 description: 'Allows to pass variables that the flow(s) might be using',
                                 optional: true,
                                 type: Hash)
  ]
end

.categoryObject



119
120
121
# File 'lib/fastlane/plugin/maestro/actions/maestro.rb', line 119

def self.category
  :testing
end

.check_ios_dependencies!Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fastlane/plugin/maestro/actions/maestro.rb', line 28

def self.check_ios_dependencies!
  UI.message("Making sure you installed the dependencies to run Maestro…")

  return if Maestro::Runner.command?("idb_companion")

  UI.error("You have to install idb companion to use `maestro` with iOS simulators")
  UI.error("")
  UI.error("Install it via brew:")
  UI.command("brew tap facebook/fb")
  UI.command("brew install idb-companion")

  UI.error("If you don't have homebrew, visit https://github.com/facebook/idb")

  UI.user_error!("Please install idb companion and start your lane again.")
end

.descriptionObject



44
45
46
# File 'lib/fastlane/plugin/maestro/actions/maestro.rb', line 44

def self.description
  'Runs Maestro test'
end

.detailsObject



55
56
57
# File 'lib/fastlane/plugin/maestro/actions/maestro.rb', line 55

def self.details
  'Installs / updates Maestro or runs maestro test depending on the parameter `:command`'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


111
112
113
114
115
116
117
# File 'lib/fastlane/plugin/maestro/actions/maestro.rb', line 111

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  [:ios, :android].include?(platform)

end

.return_valueObject



52
53
# File 'lib/fastlane/plugin/maestro/actions/maestro.rb', line 52

def self.return_value
end

.run(params) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fastlane/plugin/maestro/actions/maestro.rb', line 9

def self.run(params)
  params.load_configuration_file("Maestrofile")
  FastlaneCore::PrintTable.print_values(config: params,
                                        title: "Summary for maestro #{Fastlane::Maestro::VERSION}")

  case params[:command]
  when "install"
    Maestro::Runner.install
  when "test"
    platform = (ENV['FASTLANE_PLATFORM_NAME'] ? ENV['FASTLANE_PLATFORM_NAME'].to_s : '')
    if platform == 'ios'
      self.check_ios_dependencies!
    end
    Maestro::Runner.run(params)
  when "download_samples"
    Maestro::Runner.download_samples
  end
end