specwrk 0.4.1 → 0.4.3
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/lib/specwrk/cli.rb +4 -2
- data/lib/specwrk/queue.rb +6 -2
- data/lib/specwrk/version.rb +1 -1
- data/lib/specwrk/web/app.rb +7 -5
- data/lib/specwrk/web/auth.rb +5 -1
- data/lib/specwrk/web/endpoints.rb +15 -2
- 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: 52798ca674b5b11b238ba315c34ada0357a0d4c52df995a04f3dbbdeaeb523eb
|
4
|
+
data.tar.gz: cf488e8d531ca483d3f8a7e6ce80600c55693028f05cba5321da190e3fdec114
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d4fad41383ca3388bde45eebff774b9f052d2b830de7dca35774cc9f567236be56cdeb036207241617c8774684c07f9ec37d7e4d57eb75811117c29cbe78dae
|
7
|
+
data.tar.gz: 4f308d4b2c362981b2f88f4bdca0f6b271f96a354954dd911b3f1208fecd3c95f16e2fe84a44f0d2ba0e96dcfc38922228dd242f68ec7d49c0ea817d839fbf1c
|
data/lib/specwrk/cli.rb
CHANGED
@@ -16,7 +16,7 @@ module Specwrk
|
|
16
16
|
extend Hookable
|
17
17
|
|
18
18
|
on_included do |base|
|
19
|
-
base.unique_option :uri, type: :string, default: ENV.fetch("SPECWRK_SRV_URI", "http://localhost:#{ENV.fetch("SPECWRK_SRV_PORT", "5138")}"), desc: "HTTP URI of the server to pull jobs from. Overrides
|
19
|
+
base.unique_option :uri, type: :string, default: ENV.fetch("SPECWRK_SRV_URI", "http://localhost:#{ENV.fetch("SPECWRK_SRV_PORT", "5138")}"), desc: "HTTP URI of the server to pull jobs from. Overrides SPECWRK_SRV_URI. Default http://localhost:5138."
|
20
20
|
base.unique_option :key, type: :string, default: ENV.fetch("SPECWRK_SRV_KEY", ""), aliases: ["-k"], desc: "Authentication key clients must use for access. Overrides SPECWRK_SRV_KEY. Default ''."
|
21
21
|
base.unique_option :run, type: :string, default: ENV.fetch("SPECWRK_RUN", "main"), aliases: ["-r"], desc: "The run identifier for this job execution. Overrides SPECWRK_RUN. Default main."
|
22
22
|
base.unique_option :timeout, type: :integer, default: ENV.fetch("SPECWRK_TIMEOUT", "5"), aliases: ["-t"], desc: "The amount of time to wait for the server to respond. Overrides SPECWRK_TIMEOUT. Default 5."
|
@@ -77,10 +77,11 @@ module Specwrk
|
|
77
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/'."
|
78
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."
|
79
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."
|
80
81
|
base.unique_option :verbose, type: :boolean, default: false, desc: "Run in verbose mode. Default false."
|
81
82
|
end
|
82
83
|
|
83
|
-
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:, **|
|
84
85
|
ENV["SPECWRK_OUT"] = Pathname.new(output).expand_path(Dir.pwd).to_s
|
85
86
|
FileUtils.mkdir_p(ENV["SPECWRK_OUT"])
|
86
87
|
|
@@ -90,6 +91,7 @@ module Specwrk
|
|
90
91
|
ENV["SPECWRK_SRV_BIND"] = bind
|
91
92
|
ENV["SPECWRK_SRV_KEY"] = key
|
92
93
|
ENV["SPECWRK_SRV_SINGLE_RUN"] = "1" if single_run
|
94
|
+
ENV["SPECWRK_SRV_SINGLE_SEED_PER_RUN"] = "1" if single_seed_per_run
|
93
95
|
ENV["SPECWRK_SRV_GROUP_BY"] = group_by
|
94
96
|
end
|
95
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.
|
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
|
-
|
77
|
+
synchronize do
|
74
78
|
h2.each { |_id, example| merge_example(example) }
|
75
79
|
|
76
80
|
# Sort by exepcted run time, slowest to fastest
|
data/lib/specwrk/version.rb
CHANGED
data/lib/specwrk/web/app.rb
CHANGED
@@ -50,22 +50,24 @@ module Specwrk
|
|
50
50
|
Rack::Builder.new do
|
51
51
|
use Rack::Runtime
|
52
52
|
use Specwrk::Web::Logger, $stdout
|
53
|
-
use Specwrk::Web::Auth
|
54
|
-
run Specwrk::Web::App.new
|
53
|
+
use Specwrk::Web::Auth, %w[/health] # global auth check
|
54
|
+
run Specwrk::Web::App.new # your router
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
def call(env)
|
60
|
-
request
|
60
|
+
env[:request] ||= Rack::Request.new(env)
|
61
61
|
|
62
|
-
route(method: request.request_method, path: request.path_info)
|
63
|
-
.new(request)
|
62
|
+
route(method: env[:request].request_method, path: env[:request].path_info)
|
63
|
+
.new(env[:request])
|
64
64
|
.response
|
65
65
|
end
|
66
66
|
|
67
67
|
def route(method:, path:)
|
68
68
|
case [method, path]
|
69
|
+
when ["GET", "/health"]
|
70
|
+
Endpoints::Health
|
69
71
|
when ["GET", "/heartbeat"]
|
70
72
|
Endpoints::Heartbeat
|
71
73
|
when ["POST", "/pop"]
|
data/lib/specwrk/web/auth.rb
CHANGED
@@ -5,12 +5,16 @@ require "rack/auth/abstract/request"
|
|
5
5
|
module Specwrk
|
6
6
|
class Web
|
7
7
|
class Auth
|
8
|
-
def initialize(app)
|
8
|
+
def initialize(app, excluded_paths = [])
|
9
9
|
@app = app
|
10
|
+
@excluded_paths = excluded_paths
|
10
11
|
end
|
11
12
|
|
12
13
|
def call(env)
|
14
|
+
env[:request] ||= Rack::Request.new(env)
|
15
|
+
|
13
16
|
return @app.call(env) if [nil, ""].include? ENV["SPECWRK_SRV_KEY"]
|
17
|
+
return @app.call(env) if @excluded_paths.include? env[:request].path_info
|
14
18
|
|
15
19
|
auth = Rack::Auth::AbstractRequest.new(env)
|
16
20
|
|
@@ -50,6 +50,12 @@ module Specwrk
|
|
50
50
|
# Base default response is 404
|
51
51
|
NotFound = Class.new(Base)
|
52
52
|
|
53
|
+
class Health < Base
|
54
|
+
def response
|
55
|
+
ok
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
53
59
|
class Heartbeat < Base
|
54
60
|
def response
|
55
61
|
ok
|
@@ -58,8 +64,15 @@ module Specwrk
|
|
58
64
|
|
59
65
|
class Seed < Base
|
60
66
|
def response
|
61
|
-
|
62
|
-
|
67
|
+
pending_queue.synchronize do |pending_queue_hash|
|
68
|
+
unless ENV["SPECWRK_SRV_SINGLE_SEED_PER_RUN"] && pending_queue_hash.length.positive?
|
69
|
+
examples = payload.map { |hash| [hash[:id], hash] }.to_h
|
70
|
+
|
71
|
+
pending_queue.merge_with_previous_run_times!(examples)
|
72
|
+
|
73
|
+
ok
|
74
|
+
end
|
75
|
+
end
|
63
76
|
|
64
77
|
ok
|
65
78
|
end
|