specwrk 0.4.0 → 0.4.2

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: e3916d92756b30810112db210d2a7ab6627ed250dbddfdc64ba8b0f24248d22c
4
- data.tar.gz: eaa7c44ddacb99dde93337de842a420ebe8b12157b9dd90b5a158d75be8bebbb
3
+ metadata.gz: 9d76f2f9716e7c7e613bc0b341f89e42caf9375dfe0d48083afb908146d1374b
4
+ data.tar.gz: 36136d67829a41b39f4e9de4fff45ea1a614111f9556a523eefde1b35cceba51
5
5
  SHA512:
6
- metadata.gz: 138e0a9358bcdd82472f3ab03c607ca647393c6d79c818d2c470fbd13670e045853e1355d3ca53634e0e8447058d5cc50676ea8692fb3286afa015346765970a
7
- data.tar.gz: 2480031a9d3a080c3ddda3f4a6b5e736c3331356415da510c77ec8525114c65469c34fd0530a60fed49ccb15cef2ca03b438672920118872cc45fa8393edd8a5
6
+ metadata.gz: b7fd2a78d6019864949e6847f09474ad357b04614dd1a2cc3f563ec95f915e7958bfdf211c9d60213d61bea517e59e200ad3e7898963fe0cdd49df114941a786
7
+ data.tar.gz: 6b1836bb1a50ba0d853689ec5b7f169c83883a39c134caf93b4a70637a81c3b4f6e4f8112285dca4b30065d0c6a816807e13e65ff748dc7b16d5c5d03064e52c
data/lib/specwrk/cli.rb CHANGED
@@ -37,11 +37,13 @@ module Specwrk
37
37
  base.unique_option :id, type: :string, default: "specwrk-worker", desc: "The identifier for this worker. Default specwrk-worker(-COUNT_INDEX)."
38
38
  base.unique_option :count, type: :integer, default: 1, aliases: ["-c"], desc: "The number of worker processes you want to start. Default 1."
39
39
  base.unique_option :output, type: :string, default: ENV.fetch("SPECWRK_OUT", ".specwrk/"), aliases: ["-o"], desc: "Directory where worker output is stored. Overrides SPECWRK_OUT. Default '.specwrk/'."
40
+ base.unique_option :seed_waits, type: :integer, default: ENV.fetch("SPECWRK_SEED_WAITS", "10"), aliases: ["-w"], desc: "Number of times the worker will wait for examples to be seeded to the server. 1sec between attempts. Overrides SPECWRK_SEED_WAITS. Default '10'."
40
41
  end
41
42
 
42
- on_setup do |id:, count:, output:, **|
43
+ on_setup do |id:, count:, output:, seed_waits:, **|
43
44
  ENV["SPECWRK_ID"] = id
44
45
  ENV["SPECWRK_COUNT"] = count.to_s
46
+ ENV["SPECWRK_SEED_WAITS"] = seed_waits.to_s
45
47
  ENV["SPECWRK_OUT"] = Pathname.new(output).expand_path(Dir.pwd).to_s
46
48
  FileUtils.mkdir_p(ENV["SPECWRK_OUT"])
47
49
  end
@@ -75,10 +77,11 @@ module Specwrk
75
77
  base.unique_option :output, type: :string, default: ENV.fetch("SPECWRK_OUT", ".specwrk/"), aliases: ["-o"], desc: "Directory where worker output is stored. Overrides SPECWRK_OUT. Default '.specwrk/'."
76
78
  base.unique_option :group_by, values: %w[file timings], default: ENV.fetch("SPECWERK_SRV_GROUP_BY", "timings"), desc: "How examples will be grouped for workers; fallback to file if no timings are found. Overrides SPECWERK_SRV_GROUP_BY. Default timings."
77
79
  base.unique_option :single_run, type: :boolean, default: false, desc: "Act on shutdown requests from clients. Default: false."
80
+ base.unique_option :single_seed_per_run, type: :boolean, default: false, desc: "Only allow one seed per run. Useful for CI where many nodes may seed at the same time. Default: false."
78
81
  base.unique_option :verbose, type: :boolean, default: false, desc: "Run in verbose mode. Default false."
79
82
  end
80
83
 
81
- on_setup do |port:, bind:, output:, key:, single_run:, group_by:, verbose:, **|
84
+ on_setup do |port:, bind:, output:, key:, single_run:, single_seed_per_run:, group_by:, verbose:, **|
82
85
  ENV["SPECWRK_OUT"] = Pathname.new(output).expand_path(Dir.pwd).to_s
83
86
  FileUtils.mkdir_p(ENV["SPECWRK_OUT"])
84
87
 
@@ -88,6 +91,7 @@ module Specwrk
88
91
  ENV["SPECWRK_SRV_BIND"] = bind
89
92
  ENV["SPECWRK_SRV_KEY"] = key
90
93
  ENV["SPECWRK_SRV_SINGLE_RUN"] = "1" if single_run
94
+ ENV["SPECWRK_SRV_SINGLE_SEED_PER_RUN"] = "1" if single_seed_per_run
91
95
  ENV["SPECWRK_SRV_GROUP_BY"] = group_by
92
96
  end
93
97
  end
data/lib/specwrk/queue.rb CHANGED
@@ -19,7 +19,11 @@ module Specwrk
19
19
  end
20
20
 
21
21
  def synchronize(&blk)
22
- @mutex.synchronize { yield(@hash) }
22
+ if @mutex.owned?
23
+ yield(@hash)
24
+ else
25
+ @mutex.synchronize { yield(@hash) }
26
+ end
23
27
  end
24
28
 
25
29
  def method_missing(name, *args, &block)
@@ -70,7 +74,7 @@ module Specwrk
70
74
  end
71
75
 
72
76
  def merge_with_previous_run_times!(h2)
73
- @mutex.synchronize do
77
+ synchronize do
74
78
  h2.each { |_id, example| merge_example(example) }
75
79
 
76
80
  # Sort by exepcted run time, slowest to fastest
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Specwrk
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.2"
5
5
  end
@@ -58,8 +58,15 @@ module Specwrk
58
58
 
59
59
  class Seed < Base
60
60
  def response
61
- examples = payload.map { |hash| [hash[:id], hash] }.to_h
62
- pending_queue.merge_with_previous_run_times!(examples)
61
+ pending_queue.synchronize do |pending_queue_hash|
62
+ unless ENV["SPECWRK_SRV_SINGLE_SEED_PER_RUN"] && pending_queue_hash.length.positive?
63
+ examples = payload.map { |hash| [hash[:id], hash] }.to_h
64
+
65
+ pending_queue.merge_with_previous_run_times!(examples)
66
+
67
+ ok
68
+ end
69
+ end
63
70
 
64
71
  ok
65
72
  end
@@ -17,6 +17,7 @@ module Specwrk
17
17
  @running = true
18
18
  @client = Client.new
19
19
  @executor = Executor.new
20
+ @seed_waits = ENV.fetch("SPECWRK_SEED_WAITS", "10").to_i
20
21
  @heartbeat_thread ||= Thread.new do
21
22
  thump
22
23
  end
@@ -40,7 +41,7 @@ module Specwrk
40
41
  @seed_wait_count ||= 0
41
42
  @seed_wait_count += 1
42
43
 
43
- if @seed_wait_count <= 10
44
+ if @seed_wait_count <= @seed_waits
44
45
  warn "No examples seeded yet, waiting..."
45
46
  sleep 1
46
47
  else
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.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Westendorf