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 +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +4 -0
- data/lib/specwrk/cli.rb +5 -2
- data/lib/specwrk/client.rb +6 -2
- data/lib/specwrk/store/pending_store.rb +11 -0
- data/lib/specwrk/version.rb +1 -1
- data/lib/specwrk/web/endpoints/seed.rb +4 -2
- data/lib/specwrk/worker.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 94a0d37170078c212f345df5e4a1b014b5322856ed8f36305014ce55fd690aba
|
|
4
|
+
data.tar.gz: 2fa1e62b735f22f1342ae7e56634c257db48e9d6f72842328568293d59ecb764
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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.
|
|
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
|
data/lib/specwrk/client.rb
CHANGED
|
@@ -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: {
|
|
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
|
data/lib/specwrk/version.rb
CHANGED
|
@@ -16,8 +16,10 @@ module Specwrk
|
|
|
16
16
|
|
|
17
17
|
pending.max_retries = payload.fetch(:max_retries, "0").to_i
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
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)
|
data/lib/specwrk/worker.rb
CHANGED
|
@@ -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
|