tuya-ci-DSL 0.1.5 → 0.1.6
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/tuya/ci/DSL/trigger_create.rb +14 -0
- data/lib/tuya/ci/DSL/trigger_test.rb +4 -0
- data/lib/tuya/ci/DSL/tuya_ci_monitor.rb +43 -2
- data/lib/tuya/ci/DSL/tuya_dsl.rb +10 -3
- data/lib/tuya/ci/DSL/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5bb46b1b4cda6e39577b28d949b0a1f91b10491
|
4
|
+
data.tar.gz: 8b80824cff9ff9a50625f6ea468d972f8e774309
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0269bf8f4abc9cfbeb9d8f7f222a822d0902c38c45a264130f172613aac7fc9417d42667e1b730d778d1a0ee7136d262cf37d53badcd7330d44e36967f13131
|
7
|
+
data.tar.gz: bde2f19ad421425240e1e85ff492b8ccd557cf5053fba485a820ccc0904040f29d120f9238e922c4227fab4a218a0046551b54495b0608863baf1266317f64cc
|
@@ -70,6 +70,20 @@ end
|
|
70
70
|
after_project_build do |options|
|
71
71
|
end
|
72
72
|
|
73
|
+
building_project_pod_update_end do |options|
|
74
|
+
end
|
75
|
+
|
76
|
+
# trigger 执行策略
|
77
|
+
# strategy_always_open
|
78
|
+
# strategy_always_close
|
79
|
+
# strategy_auto
|
80
|
+
# 如果不指定 strategy 默认为 strategy_always_open
|
81
|
+
strategy do |options|
|
82
|
+
[strategy_auto, :test]
|
83
|
+
[strategy_always_open, :test]
|
84
|
+
[strategy_always_close, :test]
|
85
|
+
end
|
86
|
+
|
73
87
|
error do |exception, position, options, process|
|
74
88
|
end
|
75
89
|
"
|
@@ -10,6 +10,10 @@ module TuyaCIDSL
|
|
10
10
|
dsl = TuyaCIDSL::TuyaDSL.instance
|
11
11
|
dsl.load_monitors
|
12
12
|
|
13
|
+
data = Hash.new
|
14
|
+
data[:test] = "some data"
|
15
|
+
dsl.insert_strategy data
|
16
|
+
|
13
17
|
|
14
18
|
options_p = {:branch=>"develop_3.8.0", :dependBranch=>"master", :updateComponents=>"[{\"id\":509,\"name\":\"TYUIKit\",\"branch\":\"develop\",\"version\":\"0.1.4-rc.1\"},{\"id\":500,\"name\":\"TYBusinessLibrary\",\"branch\":\"master\",\"version\":\"6.4.2-rc.3\"}]", :deleteComponents=>"[{\"id\":683,\"name\":\"TYSmartApplicationImpl\",\"branch\":\"develop\",\"version\":\"\"}]", :advanceFields=>"{}", :isIntegrate=>"0", :hashKey=>"48a62cb2cf577a0de28f60d561e8adb2", :buildId=>"146", :jobName=>"TuyaSmartV3.8.0_90"}
|
15
19
|
options_m = {:repo=>"TYSpecs", :branch=>"develop", :project=>"TestDemo", :version=>"10.4.1-rc.4", :hashKey=>"66f6f34a45ae9f71c77836069cd758ea", :buildId=>"12", :moduleName=>"TestDemo"}
|
@@ -1,14 +1,24 @@
|
|
1
1
|
class TuyaCIMonitor
|
2
2
|
attr_accessor :methods, :name
|
3
|
+
|
4
|
+
ALWAYS_OPEN = 1
|
5
|
+
ALWAYS_CLOSE = 2
|
6
|
+
AUTO = 3
|
7
|
+
|
3
8
|
def initialize
|
4
9
|
# puts 'in initialize'
|
5
10
|
@methods = {}
|
6
11
|
end
|
7
12
|
|
8
|
-
def exe_action(action, options)
|
13
|
+
def exe_action(action, options, key)
|
9
14
|
method = @methods[action.to_sym]
|
10
15
|
begin
|
11
|
-
|
16
|
+
strategy_method = @methods[:strategy]
|
17
|
+
strategy, strategy_key = strategy_method.call options if strategy_method
|
18
|
+
unless strategy.class == Fixnum
|
19
|
+
strategy = ALWAYS_OPEN
|
20
|
+
end
|
21
|
+
trigger_call method, action, options, key, strategy, strategy_key
|
12
22
|
rescue Exception => e
|
13
23
|
if e.class == TuyaCIMonitorStopError
|
14
24
|
puts "Trigger Exception cached, tuya_stop_build has been used. the stop message is: #{$!}".red
|
@@ -22,6 +32,37 @@ class TuyaCIMonitor
|
|
22
32
|
end
|
23
33
|
end
|
24
34
|
|
35
|
+
def trigger_call(method, action, options, key, strategy, strategy_key)
|
36
|
+
|
37
|
+
call_strategy = false
|
38
|
+
if strategy == ALWAYS_OPEN
|
39
|
+
call_strategy = true if method
|
40
|
+
elsif strategy == ALWAYS_CLOSE
|
41
|
+
call_strategy = false
|
42
|
+
elsif strategy == AUTO
|
43
|
+
monitors = TuyaCIDSL::TuyaDSL.instance
|
44
|
+
call_strategy = true if ( (monitors.strategy_auto.has_key? strategy_key) && method )
|
45
|
+
end
|
46
|
+
|
47
|
+
if call_strategy
|
48
|
+
puts "Trigger '#{action}' in '#{key}'".green
|
49
|
+
method.call options
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def strategy_always_open
|
54
|
+
ALWAYS_OPEN
|
55
|
+
end
|
56
|
+
|
57
|
+
def strategy_always_close
|
58
|
+
ALWAYS_CLOSE
|
59
|
+
end
|
60
|
+
|
61
|
+
def strategy_auto
|
62
|
+
AUTO
|
63
|
+
end
|
64
|
+
|
65
|
+
|
25
66
|
def tuya_stop_build(message)
|
26
67
|
raise TuyaCIMonitorStopError, message
|
27
68
|
end
|
data/lib/tuya/ci/DSL/tuya_dsl.rb
CHANGED
@@ -4,6 +4,8 @@ module TuyaCIDSL
|
|
4
4
|
|
5
5
|
class TuyaDSL
|
6
6
|
|
7
|
+
attr_accessor :strategy_auto
|
8
|
+
|
7
9
|
include Singleton
|
8
10
|
|
9
11
|
def initialize
|
@@ -11,6 +13,7 @@ module TuyaCIDSL
|
|
11
13
|
@default_folder = 'CIMonitors'
|
12
14
|
@files = []
|
13
15
|
@monitors = {}
|
16
|
+
@strategy_auto = {}
|
14
17
|
load_files
|
15
18
|
end
|
16
19
|
|
@@ -26,6 +29,10 @@ module TuyaCIDSL
|
|
26
29
|
end
|
27
30
|
end
|
28
31
|
|
32
|
+
def insert_strategy(strategy)
|
33
|
+
@strategy_auto = strategy
|
34
|
+
end
|
35
|
+
|
29
36
|
def load_monitors
|
30
37
|
@files.each do |item|
|
31
38
|
add_monitor item
|
@@ -55,13 +62,13 @@ module TuyaCIDSL
|
|
55
62
|
|
56
63
|
private
|
57
64
|
|
65
|
+
|
66
|
+
# trigger 执行策略
|
58
67
|
def trigger(action, options)
|
59
68
|
# puts "trigger action: #{action} options: #{options}"
|
60
|
-
|
61
69
|
@monitors.each_key do |key|
|
62
|
-
puts "Start trigger: #{action} in #{key}".green
|
63
70
|
item = @monitors[key]
|
64
|
-
item.exe_action action, options
|
71
|
+
item.exe_action action, options, key
|
65
72
|
end
|
66
73
|
|
67
74
|
end
|
data/lib/tuya/ci/DSL/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tuya-ci-DSL
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fangdong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|