Class: Fastlane::Saucectl::ConfigGenerator
- Inherits:
-
Object
- Object
- Fastlane::Saucectl::ConfigGenerator
- Defined in:
- lib/fastlane/plugin/saucectl/helper/config.rb
Overview
This class creates saucectl config.yml file based on given specifications
Constant Summary collapse
- UI =
FastlaneCore::UI
Instance Method Summary collapse
- #base_config ⇒ Object
- #creat_sauce_dir ⇒ Object
- #create ⇒ Object
- #create_suite ⇒ Object
-
#initialize(config) ⇒ ConfigGenerator
constructor
A new instance of ConfigGenerator.
- #set_apps ⇒ Object
- #set_region ⇒ Object
Constructor Details
#initialize(config) ⇒ ConfigGenerator
Returns a new instance of ConfigGenerator.
18 19 20 |
# File 'lib/fastlane/plugin/saucectl/helper/config.rb', line 18 def initialize(config) @config = config end |
Instance Method Details
#base_config ⇒ Object
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 |
# File 'lib/fastlane/plugin/saucectl/helper/config.rb', line 22 def base_config { 'apiVersion' => 'v1alpha', 'kind' => @config[:kind], 'retries' => @config[:retries], 'sauce' => { 'region' => set_region.to_s, 'concurrency' => @config[:max_concurrency_size], 'metadata' => { 'name' => "#{ENV['JOB_NAME']}-#{ENV['BUILD_NUMBER']}", 'build' => "Release #{ENV['CI_COMMIT_SHORT_SHA']}" } }, (@config[:kind]).to_s => set_apps, 'artifacts' => { 'download' => { 'when' => 'always', 'match' => ['junit.xml'], 'directory' => './artifacts/' } }, 'reporters' => { 'junit' => { 'enabled' => true } } } end |
#creat_sauce_dir ⇒ Object
91 92 93 94 |
# File 'lib/fastlane/plugin/saucectl/helper/config.rb', line 91 def creat_sauce_dir dirname = '.sauce' FileUtils.mkdir_p(dirname) unless File.directory?(dirname) end |
#create ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/fastlane/plugin/saucectl/helper/config.rb', line 67 def create UI.("Creating saucectl config .....🚕💨") file_name = 'config.yml' UI.user_error!("❌ Sauce Labs platform does not support virtual device execution for ios apps") if @config[:platform].eql?('ios') && @config[:emulators] config = base_config.merge(create_suite) out_file = File.new(file_name, 'w') out_file.puts(config.to_yaml) out_file.close creat_sauce_dir FileUtils.move(file_name, './.sauce') UI.("Successfully created saucectl config ✅") if Dir.exist?('.sauce') UI.user_error!("Failed to create saucectl config ❌") unless Dir.exist?('.sauce') end |
#create_suite ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/fastlane/plugin/saucectl/helper/config.rb', line 82 def create_suite suite = Fastlane::Saucectl::Suites.new(@config) { 'suites' => if @config[:emulators] suite.create_virtual_device_suites else suite.create_real_device_suites end } end |
#set_apps ⇒ Object
60 61 62 63 64 65 |
# File 'lib/fastlane/plugin/saucectl/helper/config.rb', line 60 def set_apps { 'app' => @config[:app], 'testApp' => @config[:test_app] } end |
#set_region ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/fastlane/plugin/saucectl/helper/config.rb', line 51 def set_region case @config[:region] when 'eu' 'eu-central-1' else 'us-west-1' end end |