fastlane-plugin-maestro 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 37f335eafb373f14938384183d72cb7163b04af56c657b6ba278476fb2f34a68
4
+ data.tar.gz: 6215b246874984611ee549ea6f5b5cf0dd77a36b81aae67f0f9d7f48aaac3e8a
5
+ SHA512:
6
+ metadata.gz: f0ca71d04d9781a0534088d3ece247467d3730e93ba6dffbf975a0f05860936053a22c5901a2e29172c1ebba6b39fd5109a82ec82434f56ceae64b9e63aa33ce
7
+ data.tar.gz: 5b1c7b72c864462d8240be53e306386ef2767aa4712a3786644ab0b589bb339a62a0b48f71369abfa2a97efbd23ad282a6303cb9b0235f2b862371f6fd99a4fe
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Marc Bormeth <marc.bormeth@icloud.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,81 @@
1
+ 🧪 Maestro fastlane plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-maestro)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started
8
+ with `fastlane-plugin-maestro`, add it to your project by adding the following line to your `Pluginfile`:
9
+
10
+ ```ruby
11
+ gem "fastlane-plugin-maestro", git: "https://github.com/inf2381/fastlane-plugin-maestro.git", branch: "main"
12
+ ```
13
+
14
+ ## About this plugin
15
+
16
+ fastlane plugin for [maestro](https://github.com/mobile-dev-inc/maestro).
17
+ You can directly pass the options to maestro or provide them in the file `fastlane/Maestrofile`
18
+
19
+ Additionally to the maestro action, this plugin provides an action to start an iOS simulator and install a given .app
20
+ file to it.
21
+
22
+ ## Examples
23
+
24
+ Create a simulator, install a .app file on it and patch the device for testing
25
+
26
+ ```ruby
27
+ app = File.realpath(Dir["../**/*.app"].first)
28
+
29
+ device = launch_simulator(
30
+ app_path: app,
31
+ device_name: "iPhone 14",
32
+ language: "en-US"
33
+ )
34
+ ```
35
+
36
+ Run all flows defined in the folder .maestro/screenshot
37
+
38
+ ```ruby
39
+ maestro(
40
+ command: 'test',
41
+ directory: '.maestro/screenshot',
42
+ report_type: 'junit'
43
+ )
44
+ ```
45
+
46
+ Install maestro
47
+
48
+ ```ruby
49
+ maestro(
50
+ command: 'install'
51
+ )
52
+ ```
53
+
54
+ Download the samples
55
+
56
+ ```ruby
57
+ maestro(
58
+ command: 'download_samples'
59
+ )
60
+ ```
61
+
62
+ For other examples, please have a look at the [Fastfile of this repository](./fastlane/Fastfile)
63
+
64
+ ## Issues and Feedback
65
+
66
+ For any other issues and feedback about this plugin, please submit it to this repository.
67
+
68
+ ## Troubleshooting
69
+
70
+ If you have trouble using plugins, check out
71
+ the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
72
+
73
+ ## Using _fastlane_ Plugins
74
+
75
+ For more information about how the `fastlane` plugin system works, check out
76
+ the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
77
+
78
+ ## About _fastlane_
79
+
80
+ _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more,
81
+ check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,105 @@
1
+ require 'fastlane/action'
2
+ require 'fileutils'
3
+ require 'simctl'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ class LaunchSimulatorAction < Action
8
+ def self.run(params)
9
+ device_type = SimCtl.devicetype(name: params[:device_name])
10
+ device_name = "Maestro - #{params[:device_name]}"
11
+
12
+ runtime_name = ''
13
+ if params[:ios_version].nil? || params[:ios_version].empty?
14
+ runtime_name = SimCtl.list_runtimes()[0].name
15
+ else
16
+ runtime_name = "iOS #{params[:ios_version]}"
17
+ end
18
+ runtime = SimCtl.runtime(name: runtime_name)
19
+ UI.message("Creating device #{device_name} with runtime #{runtime_name}…")
20
+ device = SimCtl.create_device(device_name, device_type, runtime)
21
+
22
+ device.boot
23
+
24
+ UI.message("Waiting for device to boot")
25
+ device.wait { |d| d.state == :booted }
26
+
27
+ unless params[:language].nil? || params[:language].empty?
28
+ UI.message("Setting device language to #{params[:language]}")
29
+ device.settings.set_language(params[:language])
30
+ device.settings.set_locale(params[:language])
31
+ end
32
+
33
+ UI.message("Patching device settings for tests")
34
+ time = Time.new(2007, 1, 9, 9, 41, 0)
35
+ device.status_bar.clear
36
+ device.status_bar.override(
37
+ time: time.iso8601,
38
+ dataNetwork: '5g',
39
+ wifiMode: 'active',
40
+ cellularMode: 'active',
41
+ batteryState: 'charging',
42
+ batteryLevel: 100
43
+ )
44
+ device.settings.disable_keyboard_helpers
45
+
46
+ device.launch
47
+
48
+ UI.message("Installing app #{params[:app_path]} on the simulator")
49
+ device.install(params[:app_path])
50
+
51
+ return device
52
+ end
53
+
54
+ def self.description
55
+ 'Prepares an iOS simulator for Maestro testing'
56
+ end
57
+
58
+ def self.authors
59
+ ['Marc Bormeth']
60
+ end
61
+
62
+ def self.return_value
63
+ "Object of [SimCtl::Device](https://www.rubydoc.info/gems/simctl/SimCtl/Device)"
64
+ end
65
+
66
+ def self.details
67
+ 'Creates a simulator for the given `:ios_version` and `:device`. \nAfterwards, it patches the language, locale & status bar and installs the given :app on it.'
68
+ end
69
+
70
+ def self.available_options
71
+ [
72
+ FastlaneCore::ConfigItem.new(key: :app_path,
73
+ env_name: "FL_APP_PATH",
74
+ description: "Path to the .app file for simulators",
75
+ type: String,
76
+ default_value: ""),
77
+ FastlaneCore::ConfigItem.new(key: :ios_version,
78
+ description: "iOS runtime version to be used for the simulator",
79
+ short_option: "-i", # same as for scan
80
+ optional: true,
81
+ default_value: ''),
82
+ FastlaneCore::ConfigItem.new(key: :language,
83
+ description: "The language which should be used",
84
+ short_option: "-g", # same as for scan
85
+ type: String,
86
+ default_value: 'en-US',
87
+ optional: true),
88
+ FastlaneCore::ConfigItem.new(key: :device_name,
89
+ short_option: "-a", # same as for scan
90
+ optional: false,
91
+ type: String,
92
+ env_name: "MAESTRO_DEVICE",
93
+ description: "The name of the simulator type you want to run tests on (e.g. 'iPhone 14' or 'iPhone SE (2nd generation) (14.5)')")
94
+ ]
95
+ end
96
+
97
+ def self.is_supported?(platform)
98
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
99
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
100
+ #
101
+ [:ios].include?(platform)
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,118 @@
1
+ require 'fastlane/action'
2
+ require 'fileutils'
3
+
4
+ require_relative '../helper/runner'
5
+
6
+ module Fastlane
7
+ module Actions
8
+ class MaestroAction < Action
9
+ def self.run(params)
10
+ params.load_configuration_file("Maestrofile")
11
+ FastlaneCore::PrintTable.print_values(config: params,
12
+ title: "Summary for maestro #{Fastlane::Maestro::VERSION}")
13
+
14
+ case params[:command]
15
+ when "install"
16
+ Maestro::Runner.install
17
+ when "test"
18
+ platform = (ENV['FASTLANE_PLATFORM_NAME'] ? ENV['FASTLANE_PLATFORM_NAME'].to_s : '')
19
+ if platform == 'ios'
20
+ self.check_ios_dependencies!
21
+ end
22
+ Maestro::Runner.run(params)
23
+ when "download_samples"
24
+ Maestro::Runner.download_samples
25
+ end
26
+ end
27
+
28
+ def self.check_ios_dependencies!
29
+ UI.message("Making sure you installed the dependencies to run Maestro…")
30
+ return if `find #{ENV["HOMEBREW_REPOSITORY"]} -iname "idb_companion"`.include?('idb_companion')
31
+
32
+ UI.error("You have to install idb companion to use `maestro` with iOS simulators")
33
+ UI.error("")
34
+ UI.error("Install it via brew:")
35
+ UI.command("brew tap facebook/fb")
36
+ UI.command("brew install idb-companion")
37
+
38
+ UI.error("If you don't have homebrew, visit https://github.com/facebook/idb")
39
+
40
+ UI.user_error!("Pleas install idb companion and start your lane again.")
41
+ end
42
+
43
+ def self.description
44
+ 'Runs Maestro test'
45
+ end
46
+
47
+ def self.authors
48
+ ['Marc Bormeth']
49
+ end
50
+
51
+ def self.return_value
52
+ end
53
+
54
+ def self.details
55
+ 'Installs / updates Maestro or runs maestro test depending on the parameter `:command`'
56
+ end
57
+
58
+ def self.available_options
59
+ [
60
+ FastlaneCore::ConfigItem.new(key: :command,
61
+ env_name: 'FL_MAESTRO_COMMAND',
62
+ description: 'Command to be executed (`download_samples`, `install`, or `test`)',
63
+ type: String,
64
+ default_value: 'test',
65
+ verify_block: proc do |value|
66
+ unless ["download_samples", "install", "test"].include?(value)
67
+ UI.user_error!("Unsupported value '#{value}' for parameter ':command'! \nAvailable options: `download_samples`, `install`, `test`")
68
+ end
69
+ end),
70
+ FastlaneCore::ConfigItem.new(key: :report_type,
71
+ env_name: 'FL_MAESTRO_FORMAT',
72
+ description: 'Format of the generated report (`junit`)',
73
+ optional: true,
74
+ type: String,
75
+ default_value: '',
76
+ verify_block: proc do |value|
77
+ unless ["", "junit"].include?(value)
78
+ UI.user_error!("Unsupported value '#{value}' for parameter ':format'! Available options: `junit`")
79
+ end
80
+ end),
81
+ FastlaneCore::ConfigItem.new(key: :output,
82
+ env_name: 'FL_MAESTRO_OUTPUT',
83
+ description: 'Allows to override the report filename. Requires parameter :format to be set as well',
84
+ optional: true,
85
+ type: String,
86
+ default_value: ''),
87
+ FastlaneCore::ConfigItem.new(key: :device,
88
+ env_name: 'FL_MAESTRO_DEVICE',
89
+ description: 'iOS UDID or Android device name to be used for running the tests ',
90
+ optional: true,
91
+ type: String,
92
+ default_value: ''),
93
+ FastlaneCore::ConfigItem.new(key: :tests,
94
+ env_name: 'FL_MAESTRO_TESTS',
95
+ description: 'Maestro flow (or folder containing flows) to be executed',
96
+ optional: true,
97
+ type: String,
98
+ verify_block: proc do |value|
99
+ v = File.expand_path(value.to_s)
100
+ UI.user_error!("No file or directory found with path '#{v}'") unless File.exist?(v)
101
+ end)
102
+ ]
103
+ end
104
+
105
+ def self.is_supported?(platform)
106
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
107
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
108
+ #
109
+ [:ios, :android].include?(platform)
110
+
111
+ end
112
+
113
+ def self.category
114
+ :testing
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,46 @@
1
+ require 'fastlane_core/print_table'
2
+
3
+ HighLine.track_eof = false
4
+ module Fastlane
5
+ module Maestro
6
+ class Runner
7
+
8
+ def self.run(options)
9
+ # TODO: add possibility to specify maestro path
10
+ maestro_path = ENV["HOME"] + "/.maestro/bin/maestro"
11
+
12
+ command = [maestro_path]
13
+
14
+ unless options[:device].empty? || options[:device].nil?
15
+ command.push("--device", options[:device])
16
+ end
17
+
18
+ command.push("test")
19
+
20
+ unless options[:report_type].empty? || options[:report_type].nil?
21
+ command.push("--format", options[:report_type])
22
+ end
23
+ unless options[:output].empty? || options[:output].nil?
24
+ command.push("--output", options[:output])
25
+ # Make sure that the output folder is available
26
+ FileUtils.mkdir_p(File.dirname(options[:output]))
27
+ end
28
+
29
+ command.push("#{options[:tests]}")
30
+ command_string = command.join(" ")
31
+ UI.message("Running command: #{command_string}")
32
+ # TODO: set exception based on parameter `failRun`
33
+ system(command_string, out: $stdout, err: :out, exception: true)
34
+ end
35
+
36
+ def self.install
37
+ system("curl -Ls 'https://get.maestro.mobile.dev' | bash", out: $stdout, err: :out, exception: true)
38
+ end
39
+
40
+ def self.download_samples
41
+ maestro_path = ENV["HOME"] + "/.maestro/bin/maestro"
42
+ system("#{maestro_path} download-samples", out: $stdout, err: :out, exception: true)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Maestro
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/maestro/version'
2
+
3
+ module Fastlane
4
+ module Maestro
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::Maestro.all_classes.each do |current|
15
+ require current
16
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-maestro
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Marc Bormeth
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-02-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec_junit_formatter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-require_tools
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: fastlane
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simctl
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description:
154
+ email: marc.bormeth@icloud.com
155
+ executables: []
156
+ extensions: []
157
+ extra_rdoc_files: []
158
+ files:
159
+ - LICENSE
160
+ - README.md
161
+ - lib/fastlane/plugin/maestro.rb
162
+ - lib/fastlane/plugin/maestro/actions/launch_simulator.rb
163
+ - lib/fastlane/plugin/maestro/actions/maestro.rb
164
+ - lib/fastlane/plugin/maestro/helper/runner.rb
165
+ - lib/fastlane/plugin/maestro/version.rb
166
+ homepage: https://github.com/inf2381/fastlane-plugin-maestro
167
+ licenses:
168
+ - MIT
169
+ metadata: {}
170
+ post_install_message:
171
+ rdoc_options: []
172
+ require_paths:
173
+ - lib
174
+ required_ruby_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ required_rubygems_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ requirements: []
185
+ rubygems_version: 3.3.7
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: Running maestro test commands from fastlane
189
+ test_files: []