milou 0.0.6 → 0.0.9
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 -4
- data/lib/watchdog/bootstrap.rb +24 -0
- data/lib/watchdog/detox.rb +25 -8
- data/lib/watchdog/utils.rb +18 -0
- data/lib/watchdog/version.rb +1 -1
- data/lib/watchdog.rb +19 -6
- metadata +18 -3
- data/lib/watchdog/hacker.rb +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b91e278dc1d209668ca72eab28abd1fdad87d343fe5f741f1b9aae21f6688066
|
4
|
+
data.tar.gz: cffbed557d71045ca7d3ec6264c24ea49821f2cedf15a46c721734fc3974fbf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 896af371c5aa516d979dfe5b9406fda18883c461cc4bae0dd544da0dea9968e2326d8af78b99de8098ea9e88304e5d93db614640dc1f4f2a481338a3af17dd6f
|
7
|
+
data.tar.gz: 6423b6b1238ae97f152489c605692b648a55b99bc655a5ea5958cc2fa1c617037f11ee713493f5409b7e363b8520089f7407a5eabd0d5f5391cba771eb7f4753
|
data/bin/watchdog
CHANGED
@@ -1,14 +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
|
10
|
-
when 'hackerman'
|
11
|
-
puts Watchdog::run_hacker
|
14
|
+
when 'version'
|
15
|
+
puts Watchdog::VERSION
|
12
16
|
else
|
13
17
|
puts 'need to specify which runner'
|
14
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
|
|
@@ -56,7 +72,8 @@ module Watchdog
|
|
56
72
|
'Content-Type' => 'application/json',
|
57
73
|
'X-API-KEY' => ENV['WATCHDOG_AUTH_TOKEN']
|
58
74
|
}
|
59
|
-
|
75
|
+
puts "run"
|
76
|
+
puts run
|
60
77
|
response = HTTParty.post(
|
61
78
|
ENV['WATCHDOG_API_URL'],
|
62
79
|
:body => run.to_json,
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Watchdog
|
4
|
+
class Utils
|
5
|
+
def self.run_cmd(cmd)
|
6
|
+
if $watchdog_relative_dir
|
7
|
+
Dir.chdir($watchdog_relative_dir){
|
8
|
+
# %x[ #{cmd} ]
|
9
|
+
_out, err, _sts = Open3.capture3(cmd)
|
10
|
+
return _out
|
11
|
+
}
|
12
|
+
else
|
13
|
+
_out, err, _sts = Open3.capture3(cmd)
|
14
|
+
return _out
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/watchdog/version.rb
CHANGED
data/lib/watchdog.rb
CHANGED
@@ -2,16 +2,29 @@ require 'dotenv'
|
|
2
2
|
Dotenv.load
|
3
3
|
|
4
4
|
require_relative 'watchdog/detox'
|
5
|
-
require_relative 'watchdog/
|
5
|
+
require_relative 'watchdog/bootstrap'
|
6
6
|
|
7
7
|
module Watchdog
|
8
|
-
def self.
|
9
|
-
|
10
|
-
|
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
|
11
24
|
end
|
12
25
|
|
13
|
-
def self.
|
14
|
-
runner = Watchdog::
|
26
|
+
def self.run_detox
|
27
|
+
runner = Watchdog::Detox.new
|
15
28
|
runner.run
|
16
29
|
end
|
17
30
|
end
|
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.9
|
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-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.20.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: open3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.1.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.1
|
41
55
|
description: Watchdog SDK to communicate with the Watchdog API
|
42
56
|
email:
|
43
57
|
- ops@gaspardbruno.com
|
@@ -48,8 +62,9 @@ extra_rdoc_files: []
|
|
48
62
|
files:
|
49
63
|
- bin/watchdog
|
50
64
|
- lib/watchdog.rb
|
65
|
+
- lib/watchdog/bootstrap.rb
|
51
66
|
- lib/watchdog/detox.rb
|
52
|
-
- lib/watchdog/
|
67
|
+
- lib/watchdog/utils.rb
|
53
68
|
- lib/watchdog/version.rb
|
54
69
|
homepage: https://github.com/Gaspard-Bruno/watchdog-ruby-gem
|
55
70
|
licenses:
|
data/lib/watchdog/hacker.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
|
3
|
-
module Watchdog
|
4
|
-
class Hacker
|
5
|
-
def initialize()
|
6
|
-
end
|
7
|
-
|
8
|
-
def run
|
9
|
-
send_test
|
10
|
-
end
|
11
|
-
|
12
|
-
# Watchdog runner
|
13
|
-
def send_test
|
14
|
-
run = {
|
15
|
-
test_run: {
|
16
|
-
commit_branch: "main",
|
17
|
-
commit_sha: "awugdadba",
|
18
|
-
commit_timestamp: "2022-05-27 17:42:31 +0100",
|
19
|
-
test_suite_name: "Test Suite v3",
|
20
|
-
test_results: [
|
21
|
-
{ status: "FAIL", test: "TEST-1", time: "50.028" },
|
22
|
-
{ status: "PASS", test: "TEST-2", time: "31.363" },
|
23
|
-
]
|
24
|
-
}
|
25
|
-
}
|
26
|
-
|
27
|
-
puts "ENV"
|
28
|
-
puts ENV['WATCHDOG_TEST_SUIT_NAME']
|
29
|
-
puts ENV['WATCHDOG_AUTH_TOKEN']
|
30
|
-
puts ENV['WATCHDOG_API_URL']
|
31
|
-
|
32
|
-
headers = {
|
33
|
-
'Content-Type' => 'application/json',
|
34
|
-
'X-API-KEY' => ENV['WATCHDOG_AUTH_TOKEN']
|
35
|
-
}
|
36
|
-
puts headers
|
37
|
-
response = HTTParty.post(
|
38
|
-
ENV['WATCHDOG_API_URL'],
|
39
|
-
:body => run.to_json,
|
40
|
-
:headers => headers
|
41
|
-
)
|
42
|
-
|
43
|
-
puts "Watchdog response: #{response}"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|