ci-queue 0.22.0 → 0.22.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a727d6a5f5c01a4b5837d1f7ed629ce3f9c971fed502d6b850a43b384e72c59a
4
- data.tar.gz: 3ab46419fd8c1932d2e94cd40bbfb087df927d9013f9d0e998f3ed60839440e6
3
+ metadata.gz: 2847d2cc56c64030f51a65ef6b9262d04b647b15b6d6ef846cf76adb90715e44
4
+ data.tar.gz: bf4f65911c9f39c2e6049abc6006f853f8de1aa444dfe8d5c7237cd698d0a59f
5
5
  SHA512:
6
- metadata.gz: f6fd6c5f71fc10b0b5085b0d5259aa25eb1b1cc969f7b182e45c975deff56e72b1bef6e133adb812db87809feda33044ad7e137f36d88c5866c34a469af4b0fd
7
- data.tar.gz: 0415f91c5aa6c1bdfd185842ae88ee5d73ed3c553945eeacd2a095288156336f4bb00d2d49ab302f7758d7fcbb78c7fcd2b500d6265c12aa3b33dfbc2d5d7829
6
+ metadata.gz: b7c62dd52f53069dd2aad2b51724334e7ea2e8fc2cdc8f19f022b6dfd926bb7323437c3f6d1c4ffe7071316c07cde6b924671be07a2e7b402e2d528becd16acf
7
+ data.tar.gz: 056b3a585d95b88479f79448dd204eef72e16635c0c2df5c619ad78be2caf3b97a6e52c15edf09f2a2dcccf80afa3ea0018cfe9361114f6d03914383ab080efb
data/ci-queue.gemspec CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency 'bundler'
33
33
  spec.add_development_dependency 'rake'
34
34
  spec.add_development_dependency 'minitest', ENV.fetch('MINITEST_VERSION', '~> 5.11')
35
- spec.add_development_dependency 'rspec', '~> 3.7.0'
35
+ spec.add_development_dependency 'rspec', '~> 3.10'
36
36
  spec.add_development_dependency 'redis'
37
37
  spec.add_development_dependency 'simplecov', '~> 0.12'
38
38
  spec.add_development_dependency 'minitest-reporters', '~> 1.1'
@@ -21,16 +21,16 @@ module CI
21
21
  end
22
22
 
23
23
  def size
24
- redis.multi do
25
- redis.llen(key('queue'))
26
- redis.zcard(key('running'))
24
+ redis.multi do |transaction|
25
+ transaction.llen(key('queue'))
26
+ transaction.zcard(key('running'))
27
27
  end.inject(:+)
28
28
  end
29
29
 
30
30
  def to_a
31
- redis.multi do
32
- redis.lrange(key('queue'), 0, -1)
33
- redis.zrange(key('running'), 0, -1)
31
+ redis.multi do |transaction|
32
+ transaction.lrange(key('queue'), 0, -1)
33
+ transaction.zrange(key('running'), 0, -1)
34
34
  end.flatten.reverse.map { |k| index.fetch(k) }
35
35
  end
36
36
 
@@ -22,9 +22,9 @@ module CI
22
22
  end
23
23
 
24
24
  def pop_warnings
25
- warnings = redis.multi do
26
- redis.lrange(key('warnings'), 0, -1)
27
- redis.del(key('warnings'))
25
+ warnings = redis.multi do |transaction|
26
+ transaction.lrange(key('warnings'), 0, -1)
27
+ transaction.del(key('warnings'))
28
28
  end.first
29
29
 
30
30
  warnings.map { |p| Marshal.load(p) }
@@ -35,21 +35,21 @@ module CI
35
35
  end
36
36
 
37
37
  def record_error(id, payload, stats: nil)
38
- redis.pipelined do
39
- redis.hset(
38
+ redis.pipelined do |pipeline|
39
+ pipeline.hset(
40
40
  key('error-reports'),
41
41
  id.dup.force_encoding(Encoding::BINARY),
42
42
  payload.dup.force_encoding(Encoding::BINARY),
43
43
  )
44
- record_stats(stats)
44
+ record_stats(stats, pipeline: pipeline)
45
45
  end
46
46
  nil
47
47
  end
48
48
 
49
49
  def record_success(id, stats: nil)
50
- redis.pipelined do
51
- redis.hdel(key('error-reports'), id.dup.force_encoding(Encoding::BINARY))
52
- record_stats(stats)
50
+ redis.pipelined do |pipeline|
51
+ pipeline.hdel(key('error-reports'), id.dup.force_encoding(Encoding::BINARY))
52
+ record_stats(stats, pipeline: pipeline)
53
53
  end
54
54
  nil
55
55
  end
@@ -65,8 +65,8 @@ module CI
65
65
  end
66
66
 
67
67
  def fetch_stats(stat_names)
68
- counts = redis.pipelined do
69
- stat_names.each { |c| redis.hvals(key(c)) }
68
+ counts = redis.pipelined do |pipeline|
69
+ stat_names.each { |c| pipeline.hvals(key(c)) }
70
70
  end
71
71
  sum_counts = counts.map do |values|
72
72
  values.map(&:to_f).inject(:+).to_f
@@ -75,9 +75,9 @@ module CI
75
75
  end
76
76
 
77
77
  def reset_stats(stat_names)
78
- redis.pipelined do
78
+ redis.pipelined do |pipeline|
79
79
  stat_names.each do |stat_name|
80
- redis.hdel(key(stat_name), config.worker_id)
80
+ pipeline.hdel(key(stat_name), config.worker_id)
81
81
  end
82
82
  end
83
83
  end
@@ -86,10 +86,10 @@ module CI
86
86
 
87
87
  attr_reader :config, :redis
88
88
 
89
- def record_stats(stats)
89
+ def record_stats(stats, pipeline: redis)
90
90
  return unless stats
91
91
  stats.each do |stat_name, stat_value|
92
- redis.hset(key(stat_name), config.worker_id, stat_value)
92
+ pipeline.hset(key(stat_name), config.worker_id, stat_value)
93
93
  end
94
94
  end
95
95
 
@@ -11,12 +11,12 @@ module CI
11
11
  end
12
12
 
13
13
  def record_error(payload, stats: nil)
14
- redis.pipelined do
15
- redis.lpush(
14
+ redis.pipelined do |pipeline|
15
+ pipeline.lpush(
16
16
  key('error-reports'),
17
17
  payload.force_encoding(Encoding::BINARY),
18
18
  )
19
- record_stats(stats)
19
+ record_stats(stats, pipeline: pipeline)
20
20
  end
21
21
  nil
22
22
  end
@@ -34,8 +34,8 @@ module CI
34
34
  end
35
35
 
36
36
  def fetch_stats(stat_names)
37
- counts = redis.pipelined do
38
- stat_names.each { |c| redis.hvals(key(c)) }
37
+ counts = redis.pipelined do |pipeline|
38
+ stat_names.each { |c| pipeline.hvals(key(c)) }
39
39
  end
40
40
  stat_names.zip(counts.map { |values| values.map(&:to_f).inject(:+).to_f }).to_h
41
41
  end
@@ -54,10 +54,10 @@ module CI
54
54
  ['build', config.build_id, *args].join(':')
55
55
  end
56
56
 
57
- def record_stats(stats)
57
+ def record_stats(stats, pipeline: redis)
58
58
  return unless stats
59
59
  stats.each do |stat_name, stat_value|
60
- redis.hset(key(stat_name), config.worker_id, stat_value)
60
+ pipeline.hset(key(stat_name), config.worker_id, stat_value)
61
61
  end
62
62
  end
63
63
  end
@@ -19,8 +19,8 @@ module CI
19
19
  attr_reader :redis
20
20
 
21
21
  def record_test_time(test_name, duration)
22
- redis.pipelined do
23
- redis.lpush(
22
+ redis.pipelined do |pipeline|
23
+ pipeline.lpush(
24
24
  test_time_key(test_name),
25
25
  duration.to_s.force_encoding(Encoding::BINARY),
26
26
  )
@@ -29,8 +29,8 @@ module CI
29
29
  end
30
30
 
31
31
  def record_test_name(test_name)
32
- redis.pipelined do
33
- redis.lpush(
32
+ redis.pipelined do |pipeline|
33
+ pipeline.lpush(
34
34
  all_test_names_key,
35
35
  test_name.dup.force_encoding(Encoding::BINARY),
36
36
  )
@@ -39,18 +39,15 @@ module CI
39
39
  end
40
40
 
41
41
  def fetch_all_test_names
42
- values = redis.pipelined do
43
- redis.lrange(all_test_names_key, 0, -1)
42
+ values = redis.pipelined do |pipeline|
43
+ pipeline.lrange(all_test_names_key, 0, -1)
44
44
  end
45
45
  values.flatten.map(&:to_s)
46
46
  end
47
47
 
48
48
  def fetch_test_time(test_name)
49
- values = redis.pipelined do
50
- key = test_time_key(test_name)
51
- redis.lrange(key, 0, -1)
52
- end
53
- values.flatten.map(&:to_f)
49
+ key = test_time_key(test_name)
50
+ redis.lrange(key, 0, -1).map(&:to_f)
54
51
  end
55
52
 
56
53
  def all_test_names_key
@@ -194,10 +194,10 @@ module CI
194
194
  @total = tests.size
195
195
 
196
196
  if @master = redis.setnx(key('master-status'), 'setup')
197
- redis.multi do
198
- redis.lpush(key('queue'), tests) unless tests.empty?
199
- redis.set(key('total'), @total)
200
- redis.set(key('master-status'), 'ready')
197
+ redis.multi do |transaction|
198
+ transaction.lpush(key('queue'), tests) unless tests.empty?
199
+ transaction.set(key('total'), @total)
200
+ transaction.set(key('master-status'), 'ready')
201
201
  end
202
202
  end
203
203
  register
@@ -2,7 +2,7 @@
2
2
 
3
3
  module CI
4
4
  module Queue
5
- VERSION = '0.22.0'
5
+ VERSION = '0.22.1'
6
6
  DEV_SCRIPTS_ROOT = ::File.expand_path('../../../../../redis', __FILE__)
7
7
  RELEASE_SCRIPTS_ROOT = ::File.expand_path('../redis', __FILE__)
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ci-queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.22.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-14 00:00:00.000000000 Z
11
+ date: 2022-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.7.0
61
+ version: '3.10'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.7.0
68
+ version: '3.10'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: redis
71
71
  requirement: !ruby/object:Gem::Requirement