specwrk 0.20.1 → 0.20.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: f54d9828f2a51417c4956185d141b8a3a74876a1379df8701182885ad932c515
4
- data.tar.gz: a48f11d3a7977d02a5967e2d674ee68cf54a874a598e48db5b58ca3049ad80ac
3
+ metadata.gz: 94a0d37170078c212f345df5e4a1b014b5322856ed8f36305014ce55fd690aba
4
+ data.tar.gz: 2fa1e62b735f22f1342ae7e56634c257db48e9d6f72842328568293d59ecb764
5
5
  SHA512:
6
- metadata.gz: d013fd261c119d58e7b607c4c9aaddd02c020d45e2ae56776ea111ea3217c248808d1fab8e93b4e440322b1ef9096efdad19de22e79683fa9e5116275ed91ce3
7
- data.tar.gz: 2905267a34c6daab6e7f771b61d1bd0c4ffcef368646391ede9e9065e69452c047b4bd88695b930df953a3cbc0beab404cd73185d0f020556c1b09f6c14c5a25
6
+ metadata.gz: 298ce73183966b8e89ce38e7cee4ee4da184ee0bfccc114574a64ebf1fc55fe76bde02da0189060946db29913c9351e9fd84669ef23967433adb4f3b668a9fce
7
+ data.tar.gz: 74263602ada554af6970d5f58dc872e744c7517e9fd97141a8eb4ebec725f888440876dee810498be6a9230288325e85f38d8cf4db082a08d6fb94f0b1152f45
data/CHANGELOG.md CHANGED
@@ -1,7 +1,12 @@
1
1
  # Changelog
2
2
 
3
3
  ## Unreleased
4
- [Compare](https://github.com/danielwestendorf/specwrk/compare/v0.20.1...main)
4
+ [Compare](https://github.com/danielwestendorf/specwrk/compare/v0.20.2...main)
5
+
6
+ ## v0.20.2 — 2026-08-27
7
+ [Compare](https://github.com/danielwestendorf/specwrk/compare/v0.20.1...v0.20.2)
8
+ - Add a seed option for configuring the target bucket timing duration — [#191](https://github.com/danielwestendorf/specwrk/pull/191) by [@danielwestendorf](https://github.com/danielwestendorf)
9
+ - Print an indicator while workers wait for outstanding examples to finish — [#192](https://github.com/danielwestendorf/specwrk/pull/192) by [@danielwestendorf](https://github.com/danielwestendorf)
5
10
 
6
11
  ## v0.20.1 — 2026-08-23
7
12
  [Compare](https://github.com/danielwestendorf/specwrk/compare/v0.20.0...v0.20.1)
data/README.md CHANGED
@@ -116,6 +116,7 @@ Options:
116
116
  --timeout=VALUE, -t VALUE # The amount of time to wait for the server to respond. Overrides SPECWRK_TIMEOUT, default: "5"
117
117
  --network-retries=VALUE # The number of times to retry in the event of a network failure. Overrides SPECWRK_NETWORK_RETRIES, default: "1"
118
118
  --max-retries=VALUE # Number of times an example will be re-run should it fail, default: 0
119
+ --target-bucket-timing-duration=VALUE # Target runtime duration per bucket in seconds, overriding the average timings calculation. Overrides SPECWRK_TARGET_BUCKET_TIMING_DURATION, default: "0"
119
120
  --help, -h # Print this help
120
121
  ```
121
122
 
@@ -172,6 +173,9 @@ adjustments to avoid conflicting port usage or database/state mutations.
172
173
 
173
174
  `specwrk` workers will have `TEST_ENV_NUMBER={i}` set to help you configure approriately.
174
175
 
176
+ Workers print `W` without a newline while waiting for outstanding examples to finish. Set
177
+ `SPECWRK_WAITING_OUTPUT=0` to disable this output.
178
+
175
179
  ### Rails
176
180
  Rails has had easy multi-process test setup for a while now by creating unique test databases per process. For my rails v7.2 app which uses PostgreSQL and Capybara, I made these changes to my `spec/rails_helper.rb`:
177
181
 
data/lib/specwrk/cli.rb CHANGED
@@ -167,9 +167,10 @@ module Specwrk
167
167
 
168
168
  desc "Seed the server with a list of specs for the run"
169
169
  option :max_retries, default: 0, desc: "Number of times an example will be re-run should it fail"
170
+ option :target_bucket_timing_duration, default: ENV.fetch("SPECWRK_TARGET_BUCKET_TIMING_DURATION", "0"), desc: "Target runtime duration per bucket in seconds, overriding the average timings calculation. Overrides SPECWRK_TARGET_BUCKET_TIMING_DURATION"
170
171
  argument :dir, type: :array, required: false, desc: "Relative spec directory to run against, default: spec/"
171
172
 
172
- def call(max_retries:, dir:, **args)
173
+ def call(max_retries:, dir:, target_bucket_timing_duration:, **args)
173
174
  dir = ["spec"] if dir.length.zero?
174
175
 
175
176
  self.class.setup(**args)
@@ -178,10 +179,12 @@ module Specwrk
178
179
  require "specwrk/client"
179
180
 
180
181
  ENV["SPECWRK_SEED"] = "1"
182
+ target_bucket_timing_duration = Float(target_bucket_timing_duration)
183
+ ENV["SPECWRK_TARGET_BUCKET_TIMING_DURATION"] = target_bucket_timing_duration.to_s
181
184
  examples = ListExamples.new(dir).examples
182
185
 
183
186
  Client.wait_for_server!
184
- Client.new.seed(examples, max_retries)
187
+ Client.new.seed(examples, max_retries, target_bucket_timing_duration: target_bucket_timing_duration)
185
188
  file_count = examples.group_by { |e| e[:file_path] }.keys.size
186
189
  puts "🌱 Seeded #{examples.size} examples across #{file_count} files"
187
190
  rescue Errno::ECONNREFUSED
@@ -119,8 +119,12 @@ module Specwrk
119
119
  end
120
120
  end
121
121
 
122
- def seed(examples, max_retries)
123
- response = post "/seed", body: {max_retries: max_retries, examples: examples}.to_json
122
+ def seed(examples, max_retries, target_bucket_timing_duration: 0)
123
+ response = post "/seed", body: {
124
+ max_retries: max_retries,
125
+ examples: examples,
126
+ target_bucket_timing_duration: target_bucket_timing_duration
127
+ }.to_json
124
128
 
125
129
  (response.code == "200") ? true : raise(UnhandledResponseError.new("#{response.code}: #{response.body}"))
126
130
  end
@@ -19,6 +19,17 @@ module Specwrk
19
19
  @run_time_bucket_maximum ||= self[RUN_TIME_BUCKET_MAXIMUM_KEY]
20
20
  end
21
21
 
22
+ def update_run_time_bucket_maximum(calculated_run_time_bucket_maximum, target_bucket_timing_duration: 0)
23
+ target_bucket_timing_duration = target_bucket_timing_duration.to_f
24
+
25
+ if target_bucket_timing_duration.positive?
26
+ self.run_time_bucket_maximum = target_bucket_timing_duration
27
+ else
28
+ run_time_bucket_maximums = [run_time_bucket_maximum, calculated_run_time_bucket_maximum.to_f].compact
29
+ self.run_time_bucket_maximum = run_time_bucket_maximums.sum.to_f / run_time_bucket_maximums.length.to_f
30
+ end
31
+ end
32
+
22
33
  def max_retries=(val)
23
34
  @max_retries = self[MAX_RETRIES_KEY] = val
24
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Specwrk
4
- VERSION = "0.20.1"
4
+ VERSION = "0.20.2"
5
5
  end
@@ -16,8 +16,10 @@ module Specwrk
16
16
 
17
17
  pending.max_retries = payload.fetch(:max_retries, "0").to_i
18
18
 
19
- new_run_time_bucket_maximums = [pending.run_time_bucket_maximum, @seeds_run_time_bucket_maximum.to_f].compact
20
- pending.run_time_bucket_maximum = new_run_time_bucket_maximums.sum.to_f / new_run_time_bucket_maximums.length.to_f
19
+ pending.update_run_time_bucket_maximum(
20
+ @seeds_run_time_bucket_maximum,
21
+ target_bucket_timing_duration: payload.fetch(:target_bucket_timing_duration, 0)
22
+ )
21
23
 
22
24
  with_lock do
23
25
  pending.merge!(examples_with_run_times)
@@ -40,6 +40,7 @@ module Specwrk
40
40
  # Wait for the other processes (workers) on the same host to finish
41
41
  # This will cause workers to 'hang' until all work has been completed
42
42
  # TODO: break here if all the other worker processes on this host are done executing examples
43
+ $stdout.printf "W" unless ENV.fetch("SPECWRK_WAITING_OUTPUT", "1") == "0"
43
44
  sleep 0.5
44
45
  rescue WaitingForSeedError
45
46
  @seed_wait_count ||= 0
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.20.1
4
+ version: 0.20.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Westendorf