selective-ruby-core 0.2.13 → 0.2.14

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: 5d3643de5fbf74dec705528962b1111de66b25b5fb975f945e5da1828500d3de
4
- data.tar.gz: a09d1e48481314114d23d66aa3b7db75d718fb567ad65f13e664ca42b93b951c
3
+ metadata.gz: 74313321667b468559de828b9a2384d1d5a34dcb5b1a77f8322e0e3aff0aa28a
4
+ data.tar.gz: 130316014813a90b14a60aa6b84ce7fa088ff7accfb4a7d1ce8541613dd8c70d
5
5
  SHA512:
6
- metadata.gz: 9ba89fbb7fed77ece4bde5bcaa2d231529737dcc9acdc6c426e124bd374a1a4d8b35e0ba51c2b8a999c4c415c479494f763c03dbc9781ef9a4a0fbbeabe6e453
7
- data.tar.gz: db0e919fa689c419d9ebd730918a16daa7044f9858f88250233f886181da0bc4c32301c17653e47b188535c685aa93041f2fd278df29ff927794fb9f9726ce3e
6
+ metadata.gz: 53b672dc6488a04e58e5b92d875bc55b9fedf70aa23804825b6049167a701829efadc1fe3e472264563a369fb0ac1bbcbadd89b5903dc15172ea23d7e16b648b
7
+ data.tar.gz: '011185c7551dbb53621aa4baa87ae34ee64e2eaa510c75e1098da06e1466d469bbe16b21069e5bf6b69ed78fb34a923bd797fe83405ed9e299b529b2a2eeb564'
@@ -10,6 +10,8 @@ module Selective
10
10
  @@selective_suppress_reporting = false
11
11
  @@report_at_finish = {}
12
12
 
13
+ TERMINATION_REPORT_GRACE = 0.25
14
+
13
15
  REQUIRED_CONFIGURATION = {
14
16
  "host" => "SELECTIVE_HOST",
15
17
  "api_key" => "SELECTIVE_API_KEY",
@@ -256,12 +258,30 @@ module Selective
256
258
  def handle_termination_signals(pid)
257
259
  ["INT", "TERM"].each do |signal|
258
260
  Signal.trap(signal) do
261
+ report_termination(signal)
259
262
  kill_transport(signal: signal)
260
263
  exit(runner.exit_status)
261
264
  end
262
265
  end
263
266
  end
264
267
 
268
+ # Tells the server this runner is being stopped on purpose, so a run
269
+ # whose runners all leave this way is recorded as cancelled rather
270
+ # than as runners lost. Best effort: a server that predates the
271
+ # message ignores it, and a dead pipe just means it isn't sent.
272
+ #
273
+ # The transport exits the moment it reads "exit", without draining
274
+ # what it has queued for the socket, so give it a moment to send this
275
+ # first. CI cancellations allow several seconds between TERM and KILL.
276
+ def report_termination(signal)
277
+ return unless pipe
278
+
279
+ write({type: "terminating", data: {signal: signal}})
280
+ sleep(TERMINATION_REPORT_GRACE)
281
+ rescue ConnectionLostError, IOError, SystemCallError
282
+ # Nothing to report to.
283
+ end
284
+
265
285
  def kill_transport(signal: "TERM")
266
286
  begin
267
287
  pipe.write "exit"
@@ -3,7 +3,7 @@
3
3
  module Selective
4
4
  module Ruby
5
5
  module Core
6
- VERSION = "0.2.13"
6
+ VERSION = "0.2.14"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selective-ruby-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.13
4
+ version: 0.2.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Wood
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2026-10-08 00:00:00.000000000 Z
12
+ date: 2026-10-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: logger
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  requirements: []
95
- rubygems_version: 3.4.10
95
+ rubygems_version: 3.5.22
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: Selective Ruby Client Core