shipit-engine 0.45.0 → 0.45.1

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: b78d46daa8d657f9643a129fc2d96499e2b51bc4513abb0f47ca920f638b18b6
4
- data.tar.gz: d690a361445793aea4b4f12325a58e557f73143d48e3cf023f9158710662ccf2
3
+ metadata.gz: 391e77ca5abe04617e4a8516804feb802778b777a37fe3797f37986d9344838d
4
+ data.tar.gz: 7cbf010614b60f11a67ca39c25d3a5c3a15a404f59160566989b705690fa652f
5
5
  SHA512:
6
- metadata.gz: 3e7fe16a035f3d4125870e7dc9b677d92b446abe63d2b753fa5c059d700b603a42d0dc87e367fa7b86b626f9ab380e3ddd07637699c404b2246489a341330bad
7
- data.tar.gz: 29573bc2889bc5e063e1a568c9fec1701198875b8e822db2cf5174179d242c6b2c64e2daf0697518626ff3ce680c322cba6cd54061afdd291a14255b75c50015
6
+ metadata.gz: be5fe9aba69281bef4a301180f0814c16e6094b1a3949f1903ae3e10bb2f8cd5375d9078994f210d8337eb30a84ae8afb585d838dd99d727ec9abb112df50677
7
+ data.tar.gz: 9e64330a930d8cd30599196a750ee5eb8ed73c310dcbf76752307c10991c61198ae11ce063ab2831daa537318b9f332eede5f1d6455e07c295daba30e3c56cd7
@@ -10,7 +10,6 @@ module Shipit
10
10
  end
11
11
  end
12
12
 
13
- PRESENCE_CHECK_TIMEOUT = 30
14
13
  ACTIVE_STATUSES = %w[pending running aborting].freeze
15
14
  COMPLETED_STATUSES = %w[success flapping faulty validating].freeze
16
15
  UNSUCCESSFUL_STATUSES = %w[error failed aborted flapping timedout faulty].freeze
@@ -327,7 +326,7 @@ module Shipit
327
326
  end
328
327
 
329
328
  def ping
330
- Shipit.redis.set(status_key, 'alive', ex: PRESENCE_CHECK_TIMEOUT)
329
+ Shipit.redis.set(status_key, 'alive', ex: Shipit.presence_check_timeout)
331
330
  end
332
331
 
333
332
  def alive?
@@ -335,7 +334,7 @@ module Shipit
335
334
  end
336
335
 
337
336
  def report_dead!
338
- write("ERROR: Background job hasn't reported back in #{PRESENCE_CHECK_TIMEOUT} seconds.")
337
+ write("ERROR: Background job hasn't reported back in #{Shipit.presence_check_timeout} seconds.")
339
338
  error!
340
339
  end
341
340
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shipit
4
- VERSION = '0.45.0'
4
+ VERSION = '0.45.1'
5
5
  end
data/lib/shipit.rb CHANGED
@@ -91,6 +91,14 @@ module Shipit
91
91
  ENV['SHIPIT_ENABLE_SAMESITE_NONE'].present?
92
92
  end
93
93
 
94
+ def presence_check_timeout
95
+ raw = ENV.fetch('SHIPIT_PRESENCE_CHECK_TIMEOUT', '30')
96
+ timeout = Integer(raw)
97
+ raise ArgumentError, "SHIPIT_PRESENCE_CHECK_TIMEOUT must be a positive integer, got #{raw.inspect}" if timeout <= 0
98
+
99
+ timeout
100
+ end
101
+
94
102
  def app_name
95
103
  @app_name ||= secrets.app_name || Rails.application.class.name.split(':').first || 'Shipit'
96
104
  end
@@ -30,6 +30,40 @@ module Shipit
30
30
  assert_equal(['shopify/developers'], Shipit.github_teams.map(&:handle))
31
31
  end
32
32
 
33
+ test ".presence_check_timeout defaults to 30" do
34
+ assert_equal 30, Shipit.presence_check_timeout
35
+ end
36
+
37
+ test ".presence_check_timeout returns the configured value from ENV" do
38
+ ENV['SHIPIT_PRESENCE_CHECK_TIMEOUT'] = '120'
39
+ assert_equal 120, Shipit.presence_check_timeout
40
+ ensure
41
+ ENV.delete('SHIPIT_PRESENCE_CHECK_TIMEOUT')
42
+ end
43
+
44
+ test ".presence_check_timeout raises on non-numeric string" do
45
+ ENV['SHIPIT_PRESENCE_CHECK_TIMEOUT'] = 'abc'
46
+ assert_raises(ArgumentError) { Shipit.presence_check_timeout }
47
+ ensure
48
+ ENV.delete('SHIPIT_PRESENCE_CHECK_TIMEOUT')
49
+ end
50
+
51
+ test ".presence_check_timeout raises on zero" do
52
+ ENV['SHIPIT_PRESENCE_CHECK_TIMEOUT'] = '0'
53
+ error = assert_raises(ArgumentError) { Shipit.presence_check_timeout }
54
+ assert_match(/must be a positive integer/, error.message)
55
+ ensure
56
+ ENV.delete('SHIPIT_PRESENCE_CHECK_TIMEOUT')
57
+ end
58
+
59
+ test ".presence_check_timeout raises on negative value" do
60
+ ENV['SHIPIT_PRESENCE_CHECK_TIMEOUT'] = '-5'
61
+ error = assert_raises(ArgumentError) { Shipit.presence_check_timeout }
62
+ assert_match(/must be a positive integer/, error.message)
63
+ ensure
64
+ ENV.delete('SHIPIT_PRESENCE_CHECK_TIMEOUT')
65
+ end
66
+
33
67
  class RedisTest < self
34
68
  setup do
35
69
  @client = mock(:client)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shipit-engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.45.0
4
+ version: 0.45.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier