milou 0.0.4 → 0.0.7
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/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: 687aec27808949b4cbc36912fb43a4da89914b0ee8615d654c9ef5cf7c154654
|
4
|
+
data.tar.gz: d4592882c81da612bbc4c1957a56a744f8c864e14cc46e5b3340d61d4579952c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7664f8a943335848af0790f481085c0a4d8c5fcae055061fe03b9ccfc5daaa43606c88636e52813a74c674f8d776120b7d4c6fcc856fc3ad39ab86edecfbb2cd
|
7
|
+
data.tar.gz: bce1b121bc7ff1a24c6edf2188d238cdf70b25f2249822a172be23bd3afc5eaa47bd02e74af5c4043d2f35e6933ab4891614f76b4eb184875e7c98725af895f5
|
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
|
-
'Authorization' => 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.7
|
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:
|