milou 0.0.5 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/watchdog +8 -2
- data/lib/watchdog/bootstrap.rb +24 -0
- data/lib/watchdog/detox.rb +31 -12
- data/lib/watchdog/utils.rb +16 -0
- data/lib/watchdog/version.rb +1 -1
- data/lib/watchdog.rb +19 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32d9d2cbf9ddb61fa3668980c53355646e204bd9d76b69a13cfd4fb039da1b0a
|
4
|
+
data.tar.gz: 69a77f4bcd51a62216e118fb894f2c0832f63ab50e99652bfff15fe31405ab4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfb05b0a6cc58aefef28b47b7ed653a946a6c38d30ee8995ea34ee339d4f1e09828b744ce8a6674f901c186153192e729b511cb661c32320e5dae6a2e950f5d3
|
7
|
+
data.tar.gz: 60b0d490069fccf27b8ddf042711a71ebfbad6521fb199521873cf17d31f1079aff5bc61e7e19fb8a83360351ef8cf3f3545bdfe70c7fad7d9d312a94f12fda9
|
data/bin/watchdog
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'watchdog'
|
3
|
+
require "watchdog/version"
|
3
4
|
puts ARGV
|
4
5
|
|
6
|
+
case ARGV[1]
|
7
|
+
when 'bootstrap'
|
8
|
+
puts Watchdog::bootstrap
|
9
|
+
end
|
10
|
+
|
5
11
|
case ARGV[0]
|
6
12
|
when 'detox'
|
7
13
|
puts Watchdog::run_detox
|
8
|
-
when '
|
9
|
-
puts
|
14
|
+
when 'version'
|
15
|
+
puts Watchdog::VERSION
|
10
16
|
else
|
11
17
|
puts 'need to specify which runner'
|
12
18
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'utils'
|
2
|
+
|
3
|
+
module Watchdog
|
4
|
+
class Bootstrap
|
5
|
+
def self.clone_repository(git_url)
|
6
|
+
%x[ #{"git clone #{git_url} project_dir"} ]
|
7
|
+
|
8
|
+
$watchdog_relative_dir = 'project_dir'
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.change_branch(git_branch)
|
12
|
+
Watchdog::Utils.run_cmd "git checkout #{git_branch}"
|
13
|
+
Watchdog::Utils.run_cmd "git reset --hard origin/#{git_branch}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.setup_environment
|
17
|
+
%x[ #{"cp .env.project #{$watchdog_relative_dir}/.env"} ]
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.setup_project(setup_cmd)
|
21
|
+
Watchdog::Utils.run_cmd setup_cmd
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/watchdog/detox.rb
CHANGED
@@ -1,30 +1,49 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
|
3
|
+
require_relative 'utils'
|
4
|
+
|
3
5
|
module Watchdog
|
4
6
|
class Detox
|
5
7
|
def initialize()
|
6
8
|
end
|
7
9
|
|
8
10
|
def run
|
11
|
+
build_detox
|
12
|
+
|
9
13
|
detox_result = run_detox
|
10
14
|
|
11
15
|
run_watchdog(detox_result)
|
12
16
|
end
|
13
17
|
|
18
|
+
def build_detox
|
19
|
+
detox_cmd = 'yarn run detox-build'
|
20
|
+
|
21
|
+
Watchdog::Utils.run_cmd detox_cmd
|
22
|
+
|
23
|
+
# %x[ #{detox_cmd} 2>&1 ]
|
24
|
+
end
|
25
|
+
|
14
26
|
# Detox runner
|
15
27
|
def run_detox
|
16
28
|
detox_cmd = 'yarn run detox-test'
|
17
29
|
|
18
|
-
|
30
|
+
Watchdog::Utils.run_cmd(detox_cmd).chomp
|
31
|
+
|
32
|
+
# %x[ #{detox_cmd} 2>&1 ]
|
19
33
|
end
|
20
34
|
|
21
35
|
# Watchdog runner
|
22
36
|
def run_watchdog(detox_result)
|
37
|
+
|
23
38
|
status_regex = /(FAIL|PASS) (.*\.js) \((.*)\)/
|
24
39
|
|
25
|
-
commit_branch =
|
26
|
-
commit_sha =
|
27
|
-
commit_timestamp =
|
40
|
+
commit_branch = Watchdog::Utils.run_cmd('git symbolic-ref --short HEAD').chomp
|
41
|
+
commit_sha = Watchdog::Utils.run_cmd('git --no-pager show -s --format=%H').chomp
|
42
|
+
commit_timestamp = Watchdog::Utils.run_cmd('git --no-pager log -1 --format=%cd').chomp
|
43
|
+
|
44
|
+
# commit_branch = %x[ #{'git symbolic-ref --short HEAD'} 2>&1 ]
|
45
|
+
# commit_sha = %x[ #{'git --no-pager show -s --format=%H'} 2>&1 ]
|
46
|
+
# commit_timestamp = %x[ #{'git --no-pager log -1 --format=%cd'} 2>&1 ]
|
28
47
|
|
29
48
|
run = {
|
30
49
|
test_run: {
|
@@ -36,9 +55,6 @@ module Watchdog
|
|
36
55
|
}
|
37
56
|
}
|
38
57
|
|
39
|
-
puts 'detox_result'
|
40
|
-
puts detox_result
|
41
|
-
|
42
58
|
detox_result.each_line do |line|
|
43
59
|
line_match = line.match(status_regex)
|
44
60
|
|
@@ -52,13 +68,16 @@ module Watchdog
|
|
52
68
|
end
|
53
69
|
end
|
54
70
|
|
71
|
+
headers = {
|
72
|
+
'Content-Type' => 'application/json',
|
73
|
+
'X-API-KEY' => ENV['WATCHDOG_AUTH_TOKEN']
|
74
|
+
}
|
75
|
+
puts "run"
|
76
|
+
puts run
|
55
77
|
response = HTTParty.post(
|
56
78
|
ENV['WATCHDOG_API_URL'],
|
57
|
-
body
|
58
|
-
headers
|
59
|
-
'Content-Type' => 'application/json',
|
60
|
-
'X-API-KEY' => ENV['WATCHDOG_AUTH_TOKEN']
|
61
|
-
}
|
79
|
+
:body => run.to_json,
|
80
|
+
:headers => headers
|
62
81
|
)
|
63
82
|
|
64
83
|
puts "Watchdog response: #{response}"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Watchdog
|
2
|
+
class Utils
|
3
|
+
def self.run_cmd(cmd)
|
4
|
+
if $watchdog_relative_dir
|
5
|
+
Dir.chdir($watchdog_relative_dir){
|
6
|
+
# %x[ #{cmd} ]
|
7
|
+
_out, err, _sts = Open3.capture3(cmd)
|
8
|
+
return _out
|
9
|
+
}
|
10
|
+
else
|
11
|
+
_out, err, _sts = Open3.capture3(cmd)
|
12
|
+
return _out
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/watchdog/version.rb
CHANGED
data/lib/watchdog.rb
CHANGED
@@ -2,8 +2,27 @@ require 'dotenv'
|
|
2
2
|
Dotenv.load
|
3
3
|
|
4
4
|
require_relative 'watchdog/detox'
|
5
|
+
require_relative 'watchdog/bootstrap'
|
5
6
|
|
6
7
|
module Watchdog
|
8
|
+
def self.bootstrap
|
9
|
+
if ENV['WATCHDOG_GIT_URL']
|
10
|
+
Watchdog::Bootstrap.clone_repository(ENV['WATCHDOG_GIT_URL'])
|
11
|
+
|
12
|
+
if ENV['WATCHDOG_GIT_BRANCH']
|
13
|
+
Watchdog::Bootstrap.change_branch(ENV['WATCHDOG_GIT_BRANCH'])
|
14
|
+
end
|
15
|
+
|
16
|
+
Watchdog::Bootstrap.setup_environment
|
17
|
+
|
18
|
+
if ENV['WATCHDOG_SETUP_CMD']
|
19
|
+
Watchdog::Bootstrap.setup_project(ENV['WATCHDOG_SETUP_CMD'])
|
20
|
+
end
|
21
|
+
else
|
22
|
+
puts 'Bootstrap execution missing WATCHDOG_GIT_URL in environment'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
7
26
|
def self.run_detox
|
8
27
|
runner = Watchdog::Detox.new
|
9
28
|
runner.run
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: milou
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -48,7 +48,9 @@ extra_rdoc_files: []
|
|
48
48
|
files:
|
49
49
|
- bin/watchdog
|
50
50
|
- lib/watchdog.rb
|
51
|
+
- lib/watchdog/bootstrap.rb
|
51
52
|
- lib/watchdog/detox.rb
|
53
|
+
- lib/watchdog/utils.rb
|
52
54
|
- lib/watchdog/version.rb
|
53
55
|
homepage: https://github.com/Gaspard-Bruno/watchdog-ruby-gem
|
54
56
|
licenses:
|