fast_ci 1.1.0 → 1.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c198e20b22117ce90305fa7c2f82c512ef268097b46c63fcb9cdfaaa9c45aa1d
4
- data.tar.gz: cede75f91ab2fad8ee74715660a273ed9a0f229f40beb0875b4edc6ae253d550
3
+ metadata.gz: 76c1186cf1228f3465acc2228203c51070ac0c80c18f567dec89d7bdcacca0c2
4
+ data.tar.gz: 15ab92271b656e5020a52f8b98fb1d53f587d7626f3c6035aa426b0cf57707f7
5
5
  SHA512:
6
- metadata.gz: 04040e4fff496fe2065fc2f120160fc29f253322abe3f6f526f9516e88bd9feb98ddb1319ce161858f204eacc2c59d6dccd2390645b1f168e254a91ad1ccb89e
7
- data.tar.gz: 168c07fddb1154357fa647d5d59e61a8a248206f933a96f437ff4ac8d2a485b56c8b15b0cecc05a9974ad181d8cff8cc999129767ae92de4993c6ea20fdbd40c
6
+ metadata.gz: bab65efe177bb36d558cd3d50977b11cf2422aed04c70791bac94b1f62d5e533099e7cdf0d3123363da31cbed50c57b472b23e00d67a6b3c474b03999d2fc4b3
7
+ data.tar.gz: db5e94d7764901155fe12199da461dfd7da3a72155de0a1f918f07fe8897202b6c55e3a92b62e08560e1b462979fc8b4c7842bd3f539f7cf012134506ce9a50e
data/Gemfile.lock CHANGED
@@ -11,7 +11,7 @@ GIT
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- fast_ci (1.1.0)
14
+ fast_ci (1.2.0)
15
15
  async-websocket (<= 0.20.0)
16
16
  brakeman (>= 5.4.1)
17
17
  console (>= 1.10.0)
@@ -80,7 +80,7 @@ GEM
80
80
  diff-lcs (1.5.0)
81
81
  docile (1.4.1)
82
82
  equalizer (0.0.11)
83
- erubi (1.13.0)
83
+ erubi (1.13.1)
84
84
  fiber-local (1.0.0)
85
85
  flay (2.13.3)
86
86
  erubi (~> 1.10)
@@ -98,13 +98,13 @@ GEM
98
98
  launchy (3.0.1)
99
99
  addressable (~> 2.8)
100
100
  childprocess (~> 5.0)
101
- logger (1.6.1)
101
+ logger (1.6.4)
102
102
  loofah (2.23.1)
103
103
  crass (~> 1.0.2)
104
104
  nokogiri (>= 1.12.0)
105
105
  method_source (1.0.0)
106
- mini_portile2 (2.8.7)
107
- minitest (5.25.1)
106
+ mini_portile2 (2.8.8)
107
+ minitest (5.25.4)
108
108
  minitest-rails (6.1.1)
109
109
  minitest (~> 5.10)
110
110
  railties (~> 6.1.0)
@@ -179,7 +179,7 @@ GEM
179
179
  simplecov (>= 0.17.0)
180
180
  tty-which (~> 0.4.0)
181
181
  virtus (~> 1.0)
182
- sexp_processor (4.17.2)
182
+ sexp_processor (4.17.3)
183
183
  simplecov (0.22.0)
184
184
  docile (~> 1.1)
185
185
  simplecov-html (~> 0.11)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FastCI
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
data/lib/fast_ci.rb CHANGED
@@ -124,9 +124,9 @@ module FastCI
124
124
  @on[event] = block
125
125
  end
126
126
 
127
- def send_msg(event, payload = {})
127
+ def send_msg(event, payload = {}, custom_topic = nil)
128
128
  FastCI.debug("ws#send_msg: #{event} -> #{payload.inspect}")
129
- connection.write({ "topic": topic, "event": event, "payload": payload, "ref": ref })
129
+ connection.write({ "topic": custom_topic || topic, "event": event, "payload": payload, "ref": ref })
130
130
  connection.flush
131
131
  end
132
132
 
@@ -159,6 +159,20 @@ module FastCI
159
159
  end
160
160
  end
161
161
 
162
+ def start_heartbeat
163
+ Async do
164
+ loop do
165
+ sleep 30
166
+ send_heartbeat
167
+ end
168
+ end
169
+ end
170
+
171
+ def send_heartbeat
172
+ FastCI.debug("Sending heartbeat")
173
+ send_msg("heartbeat", {}, "phoenix")
174
+ end
175
+
162
176
  def await(retry_count = 0)
163
177
  connect_to_ws do
164
178
  send_msg("phx_join")
@@ -216,6 +230,7 @@ module FastCI
216
230
 
217
231
  # https://github.com/bblimke/webmock/blob/b709ba22a2949dc3bfac662f3f4da88a21679c2e/lib/webmock/http_lib_adapters/async_http_client_adapter.rb#L8
218
232
  def after_start_connection
233
+ start_heartbeat
219
234
  if defined?(WebMock::HttpLibAdapters::AsyncHttpClientAdapter)
220
235
  WebMock::HttpLibAdapters::AsyncHttpClientAdapter.enable!
221
236
  end
@@ -3,6 +3,45 @@ require_relative "reporters/fastci_reporter"
3
3
  module Minitest
4
4
  def self.plugin_fastci_init(options)
5
5
  if ENV['FAST_CI_SECRET_KEY'].present?
6
+ FastCI.configure { |c| c.run_key = "minitest" }
7
+ Minitest.class_eval do
8
+ class<< self
9
+ def __run reporter, options
10
+ suites = Minitest::Runnable.runnables
11
+ tests = {}
12
+ suit_paths = {}
13
+ suites.each do |suite|
14
+ path = "./#{Object.const_source_location(suite.name)[0].gsub(Regexp.new("^#{::Rails.root}/"), '')}"
15
+ next if path.starts_with?('./vendor/bundle')
16
+ tests[path] ||= { run_time: 0.0, file_status: 'pending', test_count: suite.runnable_methods.count, test_counters: { failed: 0, passed: 0, pending: 0 }, '1' => {} }
17
+ suit_paths[path] = suite
18
+ suite.runnable_methods.each_with_index do |method, ix|
19
+ description = method.split(':')[1..-1].join(':')
20
+ tests[path]['1'][(ix + 1).to_s] ||= { status: 'pending', description: description }
21
+ end
22
+ end
23
+
24
+ FastCI.minitest_ws.on(:enq_request) do
25
+ tests
26
+ end
27
+
28
+ FastCI.minitest_ws.on(:deq) do |api_tests|
29
+ run_suites = api_tests.map do |test_path|
30
+ suit_paths[test_path]
31
+ end
32
+ parallel, serial = run_suites.partition { |s| s.test_order == :parallel }
33
+
34
+ serial.map { |suite| suite.run reporter, options }
35
+ parallel.map { |suite| suite.run reporter, options }
36
+
37
+ fc_reporter = reporter.report.select {|r| r.class == Minitest::Reporters::FastCIReporter }.first
38
+ fc_reporter.test_results
39
+ end
40
+ FastCI.minitest_await
41
+ end
42
+ end
43
+ end
44
+
6
45
  Minitest.reporter << Minitest::Reporters::FastCIReporter.new
7
46
  end
8
47
  end
@@ -31,18 +31,6 @@ module Minitest
31
31
  @test_results = {}
32
32
  @ids = {}
33
33
  @events = []
34
-
35
- $stdout = StringIO.new()
36
-
37
- if ENV['RBCI_REMOTE_TESTS'] != 'true'
38
- FastCI.minitest_ws.on(:enq_request) do
39
- tests
40
- end
41
-
42
- FastCI.minitest_ws.on(:deq) do |api_tests|
43
- test_results
44
- end
45
- end
46
34
  end
47
35
 
48
36
  def start
@@ -63,20 +51,18 @@ module Minitest
63
51
  end
64
52
 
65
53
  def before_test(test)
66
- $stdout = StringIO.new()
67
54
  end
68
55
 
69
56
  def prerecord(klass, name)
70
57
  description = test_description(name)
71
58
  path = test_path(klass.name)
72
59
 
73
- test_results[path] ||= { run_time: 0.0, file_status: 'pending', test_count: 0, test_counters: { failed: 0, passed: 0, pending: 0 }, '1' => { description: klass.name } }
74
- test_results[path][:test_count] += 1
60
+ test_results[path] ||= { '1' => {} }
75
61
 
76
62
  id = (test_results[path]['1'].keys.size + 1).to_s
77
63
  ids[description] = id
78
64
 
79
- test_results[path]['1'][id] ||= { status: 'pending', description: description }
65
+ test_results[path]['1'][id] ||= { status: 'pending' }
80
66
  test_results[path]['1'][id][:start] = Minitest.clock_time
81
67
 
82
68
  tests[path] ||= { run_time: 0.0, file_status: 'pending', test_count: 0, test_counters: { failed: 0, passed: 0, pending: 0 }, '1' => {} }
@@ -85,7 +71,6 @@ module Minitest
85
71
  end
86
72
 
87
73
  def record(result)
88
- test_finished(result)
89
74
  description = test_description(result.name)
90
75
  id = ids[description]
91
76
  path = test_path(result.klass)
@@ -93,8 +78,8 @@ module Minitest
93
78
  test_results[path]['1'][id][:end] = Minitest.clock_time
94
79
  test_results[path]['1'][id][:run_time] = test_results[path]['1'][id][:end] - test_results[path]['1'][id][:start]
95
80
  test_results[path]['1'][id][:status] = result_status(result).to_s
96
- test_results[path][:test_counters][result_status(result)] += 1
97
- test_results[path][:run_time] += test_results[path]['1'][id][:run_time]
81
+ test_results[path]['1'][id].delete(:start)
82
+ test_results[path]['1'][id].delete(:end)
98
83
  end
99
84
 
100
85
  def report
@@ -108,13 +93,6 @@ module Minitest
108
93
  file_status = 'failed'
109
94
  end
110
95
  end
111
- test_results[path][:file_status] = file_status
112
- end
113
-
114
- if ENV['RBCI_REMOTE_TESTS'] == 'true'
115
- send_events
116
- else
117
- FastCI.minitest_await
118
96
  end
119
97
  end
120
98
 
@@ -131,16 +109,7 @@ module Minitest
131
109
  end
132
110
  end
133
111
 
134
- pass = results.any? {|reult| !result }
135
-
136
- if pass
137
- @events << ['run_minitest'.upcase, { succeed_after: 1 }]
138
- else
139
- @events << ['run_minitest'.upcase, { failed_after: 1 }]
140
- end
141
- send_events if ENV['RBCI_REMOTE_TESTS'] == 'true'
142
-
143
- return pass
112
+ return results.any? {|reult| !result }
144
113
  end
145
114
 
146
115
  def method_missing(method, *args)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nesha Zoric
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-16 00:00:00.000000000 Z
11
+ date: 2025-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: console
@@ -174,7 +174,7 @@ metadata:
174
174
  homepage_uri: https://github.com/RubyCI/fast_ci_gem
175
175
  source_code_uri: https://github.com/RubyCI/fast_ci_gem
176
176
  changelog_uri: https://github.com/RubyCI/fast_ci_gem
177
- post_install_message:
177
+ post_install_message:
178
178
  rdoc_options: []
179
179
  require_paths:
180
180
  - lib
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  version: '0'
191
191
  requirements: []
192
192
  rubygems_version: 3.2.3
193
- signing_key:
193
+ signing_key:
194
194
  specification_version: 4
195
195
  summary: Ruby wrapper for creating FastCI integrations
196
196
  test_files: []