milou 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c9bc8a19468e78e1167b38d6e4f958a32f22a12b6a187ae00fda9b1239b08ca1
4
+ data.tar.gz: 5ff3ae312ae74c6f808c1d89b507646319b76b071601a6693ee3b13c89dbf6d0
5
+ SHA512:
6
+ metadata.gz: 6ca00c29ad2d485701e83bc43e2c3f049dbc155f5e5fade9185f382aab22ea8deb53898ddd8daad949ef0183b3ee3070365996d482ca056417fd44f4e0faf052
7
+ data.tar.gz: 792c46251ca326876b71e73732b51b4b8b49783bd6bd0b51785084e4c337dfeb32b9071fcc6e9d99f05e4783c4e576671ff79cd2bc79a2521b462de0576d8e20
data/bin/watchdog ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ require 'watchdog'
3
+ puts ARGV
4
+
5
+ case ARGV[0]
6
+ when 'detox'
7
+ puts Watchdog::run_detox
8
+ when 'jest'
9
+ puts 'JEST'
10
+ else
11
+ puts 'need to specify which runner'
12
+ end
@@ -0,0 +1,67 @@
1
+ require 'httparty'
2
+
3
+ module Watchdog
4
+ class Detox
5
+ def initialize()
6
+ end
7
+
8
+ def run
9
+ detox_result = run_detox
10
+
11
+ run_watchdog(detox_result)
12
+ end
13
+
14
+ # Detox runner
15
+ def run_detox
16
+ detox_cmd = 'yarn run detox-test'
17
+
18
+ %x[ #{detox_cmd} 2>&1 ]
19
+ end
20
+
21
+ # Watchdog runner
22
+ def run_watchdog(detox_result)
23
+ status_regex = /(FAIL|PASS) (.*\.js) \((.*)\)/
24
+
25
+ commit_branch = %x[ #{'git symbolic-ref --short HEAD'} 2>&1 ]
26
+ commit_sha = %x[ #{'git --no-pager show -s --format=%H'} 2>&1 ]
27
+ commit_timestamp = %x[ #{'git --no-pager log -1 --format=%cd'} 2>&1 ]
28
+
29
+ run = {
30
+ test_run: {
31
+ commit_branch: commit_branch,
32
+ commit_sha: commit_sha,
33
+ commit_timestamp: commit_timestamp,
34
+ test_suite_name: ENV['TEST_SUIT_NAME'],
35
+ test_results: []
36
+ }
37
+ }
38
+
39
+ puts 'detox_result'
40
+ puts detox_result
41
+
42
+ detox_result.each_line do |line|
43
+ line_match = line.match(status_regex)
44
+
45
+ if line_match
46
+ run[:test_run][:test_results] << {
47
+ status: line_match[1],
48
+ test: line_match[2],
49
+ time: line_match[3]
50
+ }
51
+ puts "Status: #{line_match[1]} | Test: #{line_match[2]} | Time: #{line_match[3]}"
52
+ end
53
+ end
54
+
55
+ response = HTTParty.post(
56
+ ENV['API_URL'],
57
+ body: run.to_json,
58
+ headers: {
59
+ 'Content-Type' => 'application/json',
60
+ 'Authorization' => ENV['AUTH_TOKEN']
61
+ }
62
+ )
63
+
64
+ puts "Watchdog response: #{response}"
65
+ end
66
+ end
67
+ end
data/lib/watchdog.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'dotenv'
2
+ Dotenv.load
3
+
4
+ require_relative 'watchdog/detox'
5
+
6
+ module Watchdog
7
+ def self.run_detox
8
+ runner = Watchdog::Detox.new
9
+ runner.run
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: milou
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Carlos Silva
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-07-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Watchdog SDK to communicate with the Watchdog API
14
+ email:
15
+ - carlos@gaspardbruno.com
16
+ executables:
17
+ - watchdog
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - bin/watchdog
22
+ - lib/watchdog.rb
23
+ - lib/watchdog/detox.rb
24
+ homepage: http://rubygems.org/gems/watchdog
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubygems_version: 3.3.7
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Watchdog SDK
47
+ test_files: []