specwrk 0.21.1 → 0.21.3

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: 50d79d9aa081a9093fe4119bdfbde0548138018eba3e5c4e3075234fbfc5ec46
4
- data.tar.gz: 764c9b7bf25d397b6d0145aa543134d18fcd0cde66a3ed4dbcf2d9f6c3f3b7ce
3
+ metadata.gz: 82780e6ddeb47d5bc80b841b15de243dee0419cf5b60e4d93412053384936dab
4
+ data.tar.gz: 82b3ae57d195ddb56544f240825e132eb95c251bbb160463d7afe2d03c4c3713
5
5
  SHA512:
6
- metadata.gz: 2a8d300e5c9ba723e6e2ecc608e914eb4e2d842e95d09d8586fdcbd417fea4ab2a9c92c1521cdf78d8125d0526bfd5cae4b09edcb61f1d95bbb81d2840c41b28
7
- data.tar.gz: 16c9cc423436493518d6f159d7ce046ae3e7b247dc2f730738a03bfbe0d5a5bb1feb96c2914e94c5b503fef1e7401d1e308ff575b70be6491bf05594f7407d29
6
+ metadata.gz: e684e17c0a0678993dac9632bb0a2d1c5821d0d9eb0ed9153e78eb03b682455f29f159101456348c91af5be6ebccf1816f7f1d956a75d1bf1d2f6b375daf08d1
7
+ data.tar.gz: 98f18857a73b0fe7162b7ca357fd82cc0a47e769e683f68256b51d4a103e2eb086a523256f74a13a876b2b89b04bbb9166c01c12776b50ceb824521cb9886922
data/CHANGELOG.md CHANGED
@@ -1,7 +1,15 @@
1
1
  # Changelog
2
2
 
3
3
  ## Unreleased
4
- [Compare](https://github.com/danielwestendorf/specwrk/compare/v0.21.1...main)
4
+ [Compare](https://github.com/danielwestendorf/specwrk/compare/v0.21.3...main)
5
+
6
+ ## v0.21.3 — 2026-10-11
7
+ [Compare](https://github.com/danielwestendorf/specwrk/compare/v0.21.2...v0.21.3)
8
+ - Make worker heartbeat intervals and expiration timeouts configurable — [#198](https://github.com/danielwestendorf/specwrk/pull/198) by [@danielwestendorf](https://github.com/danielwestendorf)
9
+
10
+ ## v0.21.2 — 2026-10-10
11
+ [Compare](https://github.com/danielwestendorf/specwrk/compare/v0.21.1...v0.21.2)
12
+ - Cache generated reports — [#197](https://github.com/danielwestendorf/specwrk/pull/197) by [@danielwestendorf](https://github.com/danielwestendorf)
5
13
 
6
14
  ## v0.21.1 — 2026-09-29
7
15
  [Compare](https://github.com/danielwestendorf/specwrk/compare/v0.21.0...v0.21.1)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Specwrk
4
- VERSION = "0.21.1"
4
+ VERSION = "0.21.3"
5
5
  end
@@ -59,13 +59,18 @@ module Specwrk
59
59
  @expired_examples ||= processing.to_h.select { |_id, example| expired?(example) }
60
60
  end
61
61
 
62
- # Has the worker missed two heartbeat check-ins?
62
+ # Has the worker missed its configured heartbeat timeout?
63
63
  def expired?(example)
64
64
  return false unless example[:worker_id]
65
65
  return false unless example[:processing_started_at]
66
- return false unless example[:processing_started_at] < (Time.now - 20).to_i
67
66
 
68
- workers_last_heartbeats[example[:worker_id]] < Time.now - 20
67
+ timeout = Integer(ENV.fetch("SPECWRK_WORKER_HEARTBEAT_TIMEOUT", "60"))
68
+ raise ArgumentError, "SPECWRK_WORKER_HEARTBEAT_TIMEOUT must be greater than 0" unless timeout.positive?
69
+
70
+ cutoff = Time.now - timeout
71
+ return false unless example[:processing_started_at] < cutoff.to_i
72
+
73
+ workers_last_heartbeats[example[:worker_id]] < cutoff
69
74
  end
70
75
 
71
76
  def workers_last_heartbeats
@@ -7,11 +7,33 @@ module Specwrk
7
7
  module Endpoints
8
8
  class Report < Base
9
9
  def with_response
10
+ cached_report = metadata[:report_json]
11
+ return report_response(cached_report) if cached_report
12
+
13
+ with_lock do
14
+ cached_report = metadata[:report_json]
15
+ if cached_report
16
+ report_response(cached_report)
17
+ else
18
+ report_json = JSON.generate(report_data)
19
+ metadata[:report_json] = report_json
20
+ report_response(report_json)
21
+ end
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def report_data
10
28
  completed_dump = completed.dump
11
29
  completed_dump[:meta][:unexecuted] = pending.length + processing.length
12
30
  completed_dump[:flakes] = failure_counts.to_h.reject { |id, _count| completed_dump.dig(:examples, id, :status) == "failed" }
13
31
 
14
- [200, {"content-type" => "application/json"}, [JSON.generate(completed_dump)]]
32
+ completed_dump
33
+ end
34
+
35
+ def report_response(report_json)
36
+ [200, {"content-type" => "application/json"}, [report_json]]
15
37
  end
16
38
  end
17
39
  end
@@ -17,6 +17,8 @@ module Specwrk
17
17
 
18
18
  pending.max_retries = payload.fetch(:max_retries, "0").to_i
19
19
 
20
+ metadata.delete("report_json")
21
+
20
22
  pending.update_run_time_bucket_maximum(
21
23
  @seeds_run_time_bucket_maximum,
22
24
  target_bucket_timing_duration: payload.fetch(:target_bucket_timing_duration, 0)
@@ -97,11 +97,14 @@ module Specwrk
97
97
  end
98
98
 
99
99
  def thump
100
+ heartbeat_interval = Integer(ENV.fetch("SPECWRK_HEARTBEAT_INTERVAL", "5"))
101
+ raise ArgumentError, "SPECWRK_HEARTBEAT_INTERVAL must be greater than 0" unless heartbeat_interval.positive?
102
+
100
103
  while running && !Specwrk.force_quit
101
- sleep 10
104
+ sleep heartbeat_interval
102
105
 
103
106
  begin
104
- client.heartbeat if client.last_request_at.nil? || client.last_request_at < Time.now - 9
107
+ client.heartbeat if client.last_request_at.nil? || client.last_request_at < Time.now - heartbeat_interval + 1
105
108
  rescue
106
109
  warn "Heartbeat failed!"
107
110
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specwrk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.1
4
+ version: 0.21.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Westendorf