Class: Fastlane::Actions::TestmunkAction

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

Class Method Summary collapse

Methods inherited from Fastlane::Action

details, output, sh

Class Method Details

.authorObject



49
50
51
# File 'lib/fastlane/actions/testmunk.rb', line 49

def self.author
  "mposchen"
end

.available_optionsObject



41
42
43
44
45
46
47
# File 'lib/fastlane/actions/testmunk.rb', line 41

def self.available_options
  [
    ['', 'Your email address', 'TESTMUNK_EMAIL'],
    ['', 'Testmunk API Key', 'TESTMUNK_API'],
    ['', 'Testmunk App Name', 'TESTMUNK_APP']
  ]
end

.descriptionObject



37
38
39
# File 'lib/fastlane/actions/testmunk.rb', line 37

def self.description
  "Run tests on real devices using Testmunk"
end

.run(_params) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fastlane/actions/testmunk.rb', line 15

def self.run(_params)
  raise "Please pass your Testmunk email address using `ENV['TESTMUNK_EMAIL'] = 'value'`" unless ENV['TESTMUNK_EMAIL']
  raise "Please pass your Testmunk API Key using `ENV['TESTMUNK_API'] = 'value'`" unless ENV['TESTMUNK_API']
  raise "Please pass your Testmunk app name using `ENV['TESTMUNK_APP'] = 'value'`" unless ENV['TESTMUNK_APP']

  ipa_path = ENV['TESTMUNK_IPA'] || ENV[Actions::SharedValues::IPA_OUTPUT_PATH.to_s]
  raise "Please pass a path to your ipa file using `ENV['TESTMUNK_IPA'] = 'value'`" unless ipa_path

  Helper.log.info 'Testmunk: Uploading the .ipa and starting your tests'.green

  response = system("#{"curl -H 'Accept: application/vnd.testmunk.v1+json'" +
      " -F 'file=@#{ipa_path}' -F 'autoStart=true'" +
      " -F 'email=#{ENV['TESTMUNK_EMAIL']}'" +
      " https://#{ENV['TESTMUNK_API']}@api.testmunk.com/apps/#{ENV['TESTMUNK_APP']}/testruns"}")

  if response
    Helper.log.info 'Your tests are being executed right now. Please wait for the mail with results and decide if you want to continue.'.green
  else
    raise 'Something went wrong while uploading your app to Testmunk'.red
  end
end