fastlane-plugin-mango 1.1.0 → 1.1.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 +4 -4
- data/lib/fastlane/plugin/mango/actions/run_dockerized_task_action.rb +4 -2
- data/lib/fastlane/plugin/mango/helper/docker_commander.rb +24 -13
- data/lib/fastlane/plugin/mango/helper/emulator_commander.rb +32 -12
- data/lib/fastlane/plugin/mango/helper/mango_helper.rb +26 -15
- data/lib/fastlane/plugin/mango/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b461b1084d0ae59adbf1f20844acf789c2c8f04ab66dd26f54ce90251960130c
|
4
|
+
data.tar.gz: 7a77604dc25fc8b70eeef54acfb3e66571c5b18506202d9c49f4c57854a68beb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c6f546b393173e943ef8c60217ade021ba1cf7cb0e3c4ab5ff9734316eb49121f005d4ba9e33101a19bf786b611e6684cbf05623ede9b3ab9dfadcb87f9d37e
|
7
|
+
data.tar.gz: 1df19671e8722c6c5bec82a1b1f77d5c59f2917bd1a8652cd69772929c5af3d0ae28ec9bb5a6ede443d8383b8af806aeacf9c6c172ef9c1f46010b46e9055f98
|
@@ -8,6 +8,8 @@ module Fastlane
|
|
8
8
|
mango_helper = Fastlane::Helper::MangoHelper.new(params)
|
9
9
|
mango_helper.setup_container
|
10
10
|
|
11
|
+
docker_commander = Helper::DockerCommander.new(mango_helper.container_name)
|
12
|
+
|
11
13
|
failure_buffer_timeout = 5
|
12
14
|
timeout_command = "timeout #{params[:maximal_run_time] - failure_buffer_timeout}m"
|
13
15
|
workspace_dir = params[:workspace_dir]
|
@@ -17,13 +19,13 @@ module Fastlane
|
|
17
19
|
UI.success("Starting Android Task.")
|
18
20
|
bundle_install = params[:bundle_install] ? '&& bundle install ' : ''
|
19
21
|
|
20
|
-
|
22
|
+
docker_commander.exec(command: "cd #{workspace_dir} #{bundle_install}&& #{timeout_command} #{android_task} || exit 1")
|
21
23
|
end
|
22
24
|
|
23
25
|
ensure
|
24
26
|
post_actions = params[:post_actions]
|
25
27
|
if post_actions && !mango_helper.kvm_disabled?
|
26
|
-
|
28
|
+
docker_commander.exec(command: "cd #{workspace_dir} && #{post_actions}")
|
27
29
|
end
|
28
30
|
|
29
31
|
UI.important("Cleaning up #{params[:emulator_name]} container")
|
@@ -3,17 +3,23 @@ require 'os'
|
|
3
3
|
|
4
4
|
module Fastlane
|
5
5
|
module Helper
|
6
|
-
|
6
|
+
class DockerCommander
|
7
7
|
|
8
|
-
|
8
|
+
attr_accessor :container_name
|
9
|
+
|
10
|
+
def initialize(container_name)
|
11
|
+
@container_name = container_name
|
12
|
+
end
|
13
|
+
|
14
|
+
def pull_image(docker_image_name:)
|
9
15
|
handle_thin_pool_exception do
|
10
16
|
Actions.sh("docker pull #{docker_image_name}")
|
11
17
|
end
|
12
18
|
end
|
13
19
|
|
14
|
-
def
|
15
|
-
docker_name = if
|
16
|
-
"--name #{
|
20
|
+
def start_container(emulator_args:, docker_image:)
|
21
|
+
docker_name = if container_name
|
22
|
+
"--name #{container_name}"
|
17
23
|
else
|
18
24
|
''
|
19
25
|
end
|
@@ -26,25 +32,33 @@ module Fastlane
|
|
26
32
|
end
|
27
33
|
end
|
28
34
|
|
29
|
-
def
|
35
|
+
def stop_container
|
30
36
|
Actions.sh("docker stop #{container_name}") if container_name
|
31
37
|
end
|
32
38
|
|
33
|
-
def
|
39
|
+
def delete_container
|
34
40
|
Actions.sh("docker rm #{container_name}") if container_name
|
35
41
|
end
|
36
42
|
|
37
|
-
def
|
43
|
+
def disconnect_network_bridge
|
38
44
|
Actions.sh("docker network disconnect -f bridge #{container_name}") if container_name
|
39
45
|
rescue StandardError
|
40
46
|
# Do nothing if the network bridge is already gone
|
41
47
|
end
|
42
48
|
|
43
|
-
def
|
49
|
+
def exec(command:)
|
50
|
+
if container_name
|
51
|
+
Actions.sh("docker exec -i #{container_name} bash -l -c \"#{command}\"")
|
52
|
+
else
|
53
|
+
raise('Cannot execute docker command because the container name is unknown')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def prune
|
44
58
|
Action.sh('docker system prune -f')
|
45
59
|
end
|
46
60
|
|
47
|
-
def
|
61
|
+
def handle_thin_pool_exception(&block)
|
48
62
|
begin
|
49
63
|
block.call
|
50
64
|
rescue FastlaneCore::Interface::FastlaneShellError => exception
|
@@ -58,9 +72,6 @@ module Fastlane
|
|
58
72
|
end
|
59
73
|
end
|
60
74
|
|
61
|
-
def self.docker_exec(command:, container_name:)
|
62
|
-
Actions.sh("docker exec -i #{container_name} bash -l -c \"#{command}\"") if container_name
|
63
|
-
end
|
64
75
|
end
|
65
76
|
end
|
66
77
|
end
|
@@ -2,23 +2,43 @@ require_relative 'docker_commander'
|
|
2
2
|
|
3
3
|
module Fastlane
|
4
4
|
module Helper
|
5
|
-
module EmulatorCommander
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
class EmulatorCommander
|
7
|
+
|
8
|
+
attr_accessor :container_name
|
9
|
+
|
10
|
+
def initialize(container_name)
|
11
|
+
@container_name = container_name
|
12
|
+
@docker_commander = DockerCommander.new(container_name)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Disables animation for faster and stable testing
|
16
|
+
def disable_animations
|
17
|
+
@docker_commander.exec(command: 'adb shell settings put global window_animation_scale 0.0')
|
18
|
+
@docker_commander.exec(command: 'adb shell settings put global transition_animation_scale 0.0')
|
19
|
+
@docker_commander.exec(command: 'adb shell settings put global animator_duration_scale 0.0')
|
20
|
+
rescue FastlaneCore::Interface::FastlaneShellError => e
|
21
|
+
# Under weird circumstances it can happen that adb is running but shell on the emu is not completely up
|
22
|
+
# it recovers after some time, so wait and retry
|
23
|
+
retry_counter = retry_counter.to_i + 1
|
24
|
+
if retry_counter <= 5
|
25
|
+
sleep 10*retry_counter
|
26
|
+
retry
|
27
|
+
else
|
28
|
+
raise e
|
29
|
+
end
|
11
30
|
end
|
12
31
|
|
13
|
-
|
14
|
-
|
32
|
+
# Increases logcat storage
|
33
|
+
def increase_logcat_storage
|
34
|
+
@docker_commander.exec(command: 'adb logcat -G 16m')
|
15
35
|
end
|
16
36
|
|
17
|
-
#
|
18
|
-
def
|
37
|
+
# Restarts adb on the separate port and checks if created emulator is connected
|
38
|
+
def check_connection
|
19
39
|
UI.success('Checking if emulator is connected to ADB.')
|
20
40
|
|
21
|
-
if emulator_is_healthy?
|
41
|
+
if emulator_is_healthy?
|
22
42
|
UI.success('Emulator connected successfully')
|
23
43
|
true
|
24
44
|
else
|
@@ -27,8 +47,8 @@ module Fastlane
|
|
27
47
|
end
|
28
48
|
end
|
29
49
|
|
30
|
-
def
|
31
|
-
list_devices =
|
50
|
+
def emulator_is_healthy?
|
51
|
+
list_devices = @docker_commander.exec(command: 'adb devices')
|
32
52
|
list_devices.include? "\tdevice"
|
33
53
|
end
|
34
54
|
end
|
@@ -26,6 +26,9 @@ module Fastlane
|
|
26
26
|
@pre_action = params[:pre_action]
|
27
27
|
@docker_registry_login = params[:docker_registry_login]
|
28
28
|
@pull_latest_image = params[:pull_latest_image]
|
29
|
+
|
30
|
+
@docker_commander = DockerCommander.new(container_name)
|
31
|
+
@emulator_commander = EmulatorCommander.new(container_name)
|
29
32
|
end
|
30
33
|
|
31
34
|
# Setting up the container:
|
@@ -48,7 +51,7 @@ module Fastlane
|
|
48
51
|
pull_from_registry if @pull_latest_image
|
49
52
|
|
50
53
|
# Make sure that network bridge for the current container is not already used
|
51
|
-
|
54
|
+
@docker_commander.disconnect_network_bridge
|
52
55
|
|
53
56
|
create_container
|
54
57
|
|
@@ -59,7 +62,7 @@ module Fastlane
|
|
59
62
|
container_state = wait_for_healthy_container
|
60
63
|
|
61
64
|
if is_running_on_emulator
|
62
|
-
connection_state =
|
65
|
+
connection_state = @emulator_commander.check_connection
|
63
66
|
container_state = connection_state && connection_state
|
64
67
|
end
|
65
68
|
|
@@ -76,25 +79,25 @@ module Fastlane
|
|
76
79
|
exit 2
|
77
80
|
end
|
78
81
|
|
79
|
-
if is_running_on_emulator &&
|
82
|
+
if is_running_on_emulator && !@emulator_commander.check_connection
|
80
83
|
UI.important('Cannot connect to emulator. Exiting..')
|
81
84
|
exit 2
|
82
85
|
end
|
83
86
|
end
|
84
87
|
|
85
88
|
if is_running_on_emulator
|
86
|
-
|
87
|
-
|
89
|
+
@emulator_commander.disable_animations
|
90
|
+
@emulator_commander.increase_logcat_storage
|
88
91
|
end
|
89
92
|
end
|
90
93
|
|
91
94
|
def kvm_disabled?
|
92
95
|
begin
|
93
|
-
|
96
|
+
@docker_commander.exec(command: 'kvm-ok > kvm-ok.txt')
|
94
97
|
rescue StandardError
|
95
98
|
# kvm-ok will always throw regardless of the result. therefore we save the output in the file and ignore the error
|
96
99
|
end
|
97
|
-
|
100
|
+
@docker_commander.exec(command: 'cat kvm-ok.txt').include?('KVM acceleration can NOT be used')
|
98
101
|
end
|
99
102
|
|
100
103
|
# Stops and remove container
|
@@ -124,15 +127,16 @@ module Fastlane
|
|
124
127
|
print_cpu_load
|
125
128
|
begin
|
126
129
|
container = create_container_call
|
127
|
-
|
130
|
+
set_container_name(container)
|
128
131
|
rescue StandardError
|
129
132
|
UI.important("Something went wrong while creating: #{container_name}, will retry in #{@sleep_interval} seconds")
|
130
133
|
print_cpu_load
|
131
|
-
|
132
|
-
|
134
|
+
@docker_commander.stop_container
|
135
|
+
@docker_commander.delete_container
|
136
|
+
|
133
137
|
sleep @sleep_interval
|
134
138
|
container = create_container_call
|
135
|
-
|
139
|
+
set_container_name(container)
|
136
140
|
end
|
137
141
|
get_container_instance(container)
|
138
142
|
end
|
@@ -154,7 +158,7 @@ module Fastlane
|
|
154
158
|
|
155
159
|
emulator_args = is_running_on_emulator ? "-p #{no_vnc_port}:6080 -e DEVICE='#{device_name}'" : ''
|
156
160
|
|
157
|
-
|
161
|
+
@docker_commander.start_container(emulator_args: emulator_args, docker_image: docker_image)
|
158
162
|
end
|
159
163
|
|
160
164
|
def execute_pre_action
|
@@ -165,7 +169,7 @@ module Fastlane
|
|
165
169
|
def pull_from_registry
|
166
170
|
docker_image_name = docker_image.gsub(':latest', '')
|
167
171
|
Actions.sh(@docker_registry_login) if @docker_registry_login
|
168
|
-
|
172
|
+
@docker_commander.pull_image(docker_image_name: docker_image_name)
|
169
173
|
end
|
170
174
|
|
171
175
|
# Checks that chosen ports are not already allocated. If they are, it will stop the allocated container
|
@@ -179,8 +183,8 @@ module Fastlane
|
|
179
183
|
if port_open?('0.0.0.0', @no_vnc_port)
|
180
184
|
UI.important('Something went wrong. VNC port is still busy')
|
181
185
|
sleep @sleep_interval
|
182
|
-
|
183
|
-
|
186
|
+
@docker_commander.stop_container
|
187
|
+
@docker_commander.delete_container
|
184
188
|
end
|
185
189
|
end
|
186
190
|
|
@@ -281,6 +285,13 @@ module Fastlane
|
|
281
285
|
raise "CPU was overloaded. Couldn't start emulator"
|
282
286
|
end
|
283
287
|
|
288
|
+
# if we do not have container name, we cane use container ID that we got from create call
|
289
|
+
def set_container_name(container)
|
290
|
+
unless container_name
|
291
|
+
@container_name = @emulator_commander.container_name = @docker_commander.container_name = container
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
284
295
|
end
|
285
296
|
end
|
286
297
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-mango
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serghei Moret, Daniel Hartwich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docker-api
|