specwrk 0.4.2 → 0.4.4

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: 9d76f2f9716e7c7e613bc0b341f89e42caf9375dfe0d48083afb908146d1374b
4
- data.tar.gz: 36136d67829a41b39f4e9de4fff45ea1a614111f9556a523eefde1b35cceba51
3
+ metadata.gz: d304bcbd087ca40be6dba19ea7b82647e8316d63d2ded6b161b407d03807311a
4
+ data.tar.gz: dc842ff43d3adea11d6a8a13741b3551298cecb9e23045ba7501cab46bfeaa6c
5
5
  SHA512:
6
- metadata.gz: b7fd2a78d6019864949e6847f09474ad357b04614dd1a2cc3f563ec95f915e7958bfdf211c9d60213d61bea517e59e200ad3e7898963fe0cdd49df114941a786
7
- data.tar.gz: 6b1836bb1a50ba0d853689ec5b7f169c83883a39c134caf93b4a70637a81c3b4f6e4f8112285dca4b30065d0c6a816807e13e65ff748dc7b16d5c5d03064e52c
6
+ metadata.gz: c8e6cc61223f3fd78a7faafc0a8af659f893f463dd12935715c870f3224053bce8989ed48a502679315f35eeabdb2c4a5fdc2f7c670fb1e6f5c0be92bf48c7d5
7
+ data.tar.gz: f935dcc84042c776cfefb589432cc4c052d2a9985e6f6c8c998b1b56352fd4086a13a8b0ab942c2437be6c720235d1ea868749d207b720286381411970d80f17
data/README.md CHANGED
@@ -47,17 +47,18 @@ Arguments:
47
47
  DIR # Relative spec directory to run against
48
48
 
49
49
  Options:
50
- --uri=VALUE # HTTP URI of the server to pull jobs from. Overrides SPECWRK_SRV_PORT. Default 5138., default: "https://localhost:5138"
51
- --key=VALUE, -k VALUE # Authentication key clients must use for access. Overrides SPECWRK_SRV_KEY. Default ''., default: ""
52
- --run=VALUE, -r VALUE # The run identifier for this job execution. Overrides SPECWRK_RUN. Default main., default: "main"
53
- --timeout=VALUE, -t VALUE # The amount of time to wait for the server to respond. Overrides SPECWRK_TIMEOUT. Default 5., default: "5"
54
- --id=VALUE # The identifier for this worker. Default specwrk-worker(-COUNT_INDEX)., default: "specwrk-worker"
55
- --count=VALUE, -c VALUE # The number of worker processes you want to start. Default 1., default: 1
56
- --output=VALUE, -o VALUE # Directory where worker output is stored. Overrides SPECWRK_OUT. Default '.specwrk/'., default: ".specwrk/"
57
- --port=VALUE, -p VALUE # Server port. Overrides SPECWRK_SRV_PORT. Default 5138., default: "5138"
58
- --bind=VALUE, -b VALUE # Server bind address. Overrides SPECWRK_SRV_BIND. Default 127.0.0.1., default: "127.0.0.1"
59
- --group-by=VALUE # How examples will be grouped for workers; fallback to file if no timings are found. Overrides SPECWERK_SRV_GROUP_BY. Default timings.: (file/timings), default: "timings"
60
- --[no-]single-run # Act on shutdown requests from clients. Default: false., default: false
50
+ --uri=VALUE # HTTP URI of the server to pull jobs from. Overrides SPECWRK_SRV_URI, default: "http://localhost:5138"
51
+ --key=VALUE, -k VALUE # Authentication key clients must use for access. Overrides SPECWRK_SRV_KEY, default: ""
52
+ --run=VALUE, -r VALUE # The run identifier for this job execution. Overrides SPECWRK_RUN, default: "main"
53
+ --timeout=VALUE, -t VALUE # The amount of time to wait for the server to respond. Overrides SPECWRK_TIMEOUT, default: "5"
54
+ --id=VALUE # The identifier for this worker. Default specwrk-worker(-COUNT_INDEX), default: "specwrk-worker"
55
+ --count=VALUE, -c VALUE # The number of worker processes you want to start, default: 1
56
+ --output=VALUE, -o VALUE # Directory where worker output is stored. Overrides SPECWRK_OUT, default: ".specwrk/"
57
+ --seed-waits=VALUE, -w VALUE # Number of times the worker will wait for examples to be seeded to the server. 1sec between attempts. Overrides SPECWRK_SEED_WAITS, default: "10"
58
+ --port=VALUE, -p VALUE # Server port. Overrides SPECWRK_SRV_PORT, default: "5138"
59
+ --bind=VALUE, -b VALUE # Server bind address. Overrides SPECWRK_SRV_BIND, default: "127.0.0.1"
60
+ --group-by=VALUE # How examples will be grouped for workers; fallback to file if no timings are found. Overrides SPECWERK_SRV_GROUP_BY: (file/timings), default: "timings"
61
+ --[no-]single-seed-per-run # Only allow one seed per run. Useful for CI where many nodes may seed at the same time, default: false
61
62
  --[no-]verbose # Run in verbose mode. Default false., default: false
62
63
  --help, -h # Print this help
63
64
  ```
@@ -77,13 +78,14 @@ Description:
77
78
  Start a queue server
78
79
 
79
80
  Options:
80
- --port=VALUE, -p VALUE # Server port. Overrides SPECWRK_SRV_PORT. Default 5138., default: "5138"
81
- --bind=VALUE, -b VALUE # Server bind address. Overrides SPECWRK_SRV_BIND. Default 127.0.0.1., default: "127.0.0.1"
82
- --key=VALUE, -k VALUE # Authentication key clients must use for access. Overrides SPECWRK_SRV_KEY. Default ''., default: ""
83
- --output=VALUE, -o VALUE # Directory where worker output is stored. Overrides SPECWRK_OUT. Default '.specwrk/'., default: ".specwrk/"
84
- --group-by=VALUE # How examples will be grouped for workers; fallback to file if no timings are found. Overrides SPECWERK_SRV_GROUP_BY. Default timings.: (file/timings), default: "timings"
85
- --[no-]single-run # Act on shutdown requests from clients. Default: false., default: false
81
+ --port=VALUE, -p VALUE # Server port. Overrides SPECWRK_SRV_PORT, default: "5138"
82
+ --bind=VALUE, -b VALUE # Server bind address. Overrides SPECWRK_SRV_BIND, default: "127.0.0.1"
83
+ --key=VALUE, -k VALUE # Authentication key clients must use for access. Overrides SPECWRK_SRV_KEY, default: ""
84
+ --output=VALUE, -o VALUE # Directory where worker output is stored. Overrides SPECWRK_OUT, default: ".specwrk/"
85
+ --group-by=VALUE # How examples will be grouped for workers; fallback to file if no timings are found. Overrides SPECWERK_SRV_GROUP_BY: (file/timings), default: "timings"
86
+ --[no-]single-seed-per-run # Only allow one seed per run. Useful for CI where many nodes may seed at the same time, default: false
86
87
  --[no-]verbose # Run in verbose mode. Default false., default: false
88
+ --[no-]single-run # Act on shutdown requests from clients. Default: false., default: false
87
89
  --help, -h # Print this help
88
90
  ```
89
91
 
@@ -105,10 +107,10 @@ Arguments:
105
107
  DIR # Relative spec directory to run against
106
108
 
107
109
  Options:
108
- --uri=VALUE # HTTP URI of the server to pull jobs from. Overrides SPECWRK_SRV_PORT. Default 5138., default: "https://localhost:5138"
109
- --key=VALUE, -k VALUE # Authentication key clients must use for access. Overrides SPECWRK_SRV_KEY. Default ''., default: ""
110
- --run=VALUE, -r VALUE # The run identifier for this job execution. Overrides SPECWRK_RUN. Default main., default: "main"
111
- --timeout=VALUE, -t VALUE # The amount of time to wait for the server to respond. Overrides SPECWRK_TIMEOUT. Default 5., default: "5"
110
+ --uri=VALUE # HTTP URI of the server to pull jobs from. Overrides SPECWRK_SRV_URI, default: "http://localhost:5138"
111
+ --key=VALUE, -k VALUE # Authentication key clients must use for access. Overrides SPECWRK_SRV_KEY, default: ""
112
+ --run=VALUE, -r VALUE # The run identifier for this job execution. Overrides SPECWRK_RUN, default: "main"
113
+ --timeout=VALUE, -t VALUE # The amount of time to wait for the server to respond. Overrides SPECWRK_TIMEOUT, default: "5"
112
114
  --help, -h # Print this help
113
115
  ```
114
116
 
@@ -127,13 +129,14 @@ Description:
127
129
  Start one or more worker processes
128
130
 
129
131
  Options:
130
- --id=VALUE # The identifier for this worker. Default specwrk-worker(-COUNT_INDEX)., default: "specwrk-worker"
131
- --count=VALUE, -c VALUE # The number of worker processes you want to start. Default 1., default: 1
132
- --output=VALUE, -o VALUE # Directory where worker output is stored. Overrides SPECWRK_OUT. Default '.specwrk/'., default: ".specwrk/"
133
- --uri=VALUE # HTTP URI of the server to pull jobs from. Overrides SPECWRK_SRV_PORT. Default 5138., default: "https://localhost:5138"
134
- --key=VALUE, -k VALUE # Authentication key clients must use for access. Overrides SPECWRK_SRV_KEY. Default ''., default: ""
135
- --run=VALUE, -r VALUE # The run identifier for this job execution. Overrides SPECWRK_RUN. Default main., default: "main"
136
- --timeout=VALUE, -t VALUE # The amount of time to wait for the server to respond. Overrides SPECWRK_TIMEOUT. Default 5., default: "5"
132
+ --id=VALUE # The identifier for this worker. Default specwrk-worker(-COUNT_INDEX), default: "specwrk-worker"
133
+ --count=VALUE, -c VALUE # The number of worker processes you want to start, default: 1
134
+ --output=VALUE, -o VALUE # Directory where worker output is stored. Overrides SPECWRK_OUT, default: ".specwrk/"
135
+ --seed-waits=VALUE, -w VALUE # Number of times the worker will wait for examples to be seeded to the server. 1sec between attempts. Overrides SPECWRK_SEED_WAITS, default: "10"
136
+ --uri=VALUE # HTTP URI of the server to pull jobs from. Overrides SPECWRK_SRV_URI, default: "http://localhost:5138"
137
+ --key=VALUE, -k VALUE # Authentication key clients must use for access. Overrides SPECWRK_SRV_KEY, default: ""
138
+ --run=VALUE, -r VALUE # The run identifier for this job execution. Overrides SPECWRK_RUN, default: "main"
139
+ --timeout=VALUE, -t VALUE # The amount of time to wait for the server to respond. Overrides SPECWRK_TIMEOUT, default: "5"
137
140
  --help, -h # Print this help
138
141
  ```
139
142
 
@@ -158,9 +161,11 @@ Rails has had easy multi-process test setup for a while now by creating unique t
158
161
  ```
159
162
 
160
163
  ## CI
161
- 1 server N nodes with N processes => 🏎️
164
+ Run `specwrk` in CI in either a single-node or multi-node configuration.
165
+
166
+ ### Single-node, multi-process
167
+ Single-node + multi-process is the easiest way to get started. Add it to your existing configuration
162
168
 
163
- TODO!
164
169
 
165
170
  ## Contributing
166
171
 
data/lib/specwrk/cli.rb CHANGED
@@ -16,10 +16,10 @@ 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 SPECWRK_SRV_PORT. Default 5138."
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
- 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
- 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."
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"
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"
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"
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"
23
23
  end
24
24
 
25
25
  on_setup do |uri:, key:, run:, timeout:, **|
@@ -34,10 +34,10 @@ module Specwrk
34
34
  extend Hookable
35
35
 
36
36
  on_included do |base|
37
- base.unique_option :id, type: :string, default: "specwrk-worker", desc: "The identifier for this worker. Default specwrk-worker(-COUNT_INDEX)."
38
- base.unique_option :count, type: :integer, default: 1, aliases: ["-c"], desc: "The number of worker processes you want to start. Default 1."
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'."
37
+ base.unique_option :id, type: :string, default: "specwrk-worker", desc: "The identifier for this worker. Default specwrk-worker(-COUNT_INDEX)"
38
+ base.unique_option :count, type: :integer, default: 1, aliases: ["-c"], desc: "The number of worker processes you want to start"
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"
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"
41
41
  end
42
42
 
43
43
  on_setup do |id:, count:, output:, seed_waits:, **|
@@ -71,17 +71,16 @@ module Specwrk
71
71
  extend Hookable
72
72
 
73
73
  on_included do |base|
74
- base.unique_option :port, type: :integer, default: ENV.fetch("SPECWRK_SRV_PORT", "5138"), aliases: ["-p"], desc: "Server port. Overrides SPECWRK_SRV_PORT. Default 5138."
75
- base.unique_option :bind, type: :string, default: ENV.fetch("SPECWRK_SRV_BIND", "127.0.0.1"), aliases: ["-b"], desc: "Server bind address. Overrides SPECWRK_SRV_BIND. Default 127.0.0.1."
76
- base.unique_option :key, type: :string, aliases: ["-k"], default: ENV.fetch("SPECWRK_SRV_KEY", ""), desc: "Authentication key clients must use for access. Overrides SPECWRK_SRV_KEY. Default ''."
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
- 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
- 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."
74
+ base.unique_option :port, type: :integer, default: ENV.fetch("SPECWRK_SRV_PORT", "5138"), aliases: ["-p"], desc: "Server port. Overrides SPECWRK_SRV_PORT"
75
+ base.unique_option :bind, type: :string, default: ENV.fetch("SPECWRK_SRV_BIND", "127.0.0.1"), aliases: ["-b"], desc: "Server bind address. Overrides SPECWRK_SRV_BIND"
76
+ base.unique_option :key, type: :string, aliases: ["-k"], default: ENV.fetch("SPECWRK_SRV_KEY", ""), desc: "Authentication key clients must use for access. Overrides SPECWRK_SRV_KEY"
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"
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"
79
+ 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"
81
80
  base.unique_option :verbose, type: :boolean, default: false, desc: "Run in verbose mode. Default false."
82
81
  end
83
82
 
84
- on_setup do |port:, bind:, output:, key:, single_run:, single_seed_per_run:, group_by:, verbose:, **|
83
+ on_setup do |port:, bind:, output:, key:, single_seed_per_run:, group_by:, verbose:, **|
85
84
  ENV["SPECWRK_OUT"] = Pathname.new(output).expand_path(Dir.pwd).to_s
86
85
  FileUtils.mkdir_p(ENV["SPECWRK_OUT"])
87
86
 
@@ -90,7 +89,6 @@ module Specwrk
90
89
  ENV["SPECWRK_SRV_PORT"] = port
91
90
  ENV["SPECWRK_SRV_BIND"] = bind
92
91
  ENV["SPECWRK_SRV_KEY"] = key
93
- ENV["SPECWRK_SRV_SINGLE_RUN"] = "1" if single_run
94
92
  ENV["SPECWRK_SRV_SINGLE_SEED_PER_RUN"] = "1" if single_seed_per_run
95
93
  ENV["SPECWRK_SRV_GROUP_BY"] = group_by
96
94
  end
@@ -159,8 +157,11 @@ module Specwrk
159
157
  include Servable
160
158
 
161
159
  desc "Start a queue server"
160
+ option :single_run, type: :boolean, default: false, desc: "Act on shutdown requests from clients. Default: false."
161
+
162
+ def call(single_run:, **args)
163
+ ENV["SPECWRK_SRV_SINGLE_RUN"] = "1" if single_run
162
164
 
163
- def call(**args)
164
165
  self.class.setup(**args)
165
166
 
166
167
  require "specwrk/web"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Specwrk
4
- VERSION = "0.4.2"
4
+ VERSION = "0.4.4"
5
5
  end
@@ -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 # global auth check
54
- run Specwrk::Web::App.new # your router
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 = Rack::Request.new(env)
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"]
@@ -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
@@ -76,12 +82,14 @@ module Specwrk
76
82
  def response
77
83
  processing_queue.synchronize do |processing_queue_hash|
78
84
  payload.each do |example|
85
+ next unless processing_queue_hash.key?(example[:id])
86
+
79
87
  processing_queue_hash.delete(example[:id])
80
88
  completed_queue[example[:id]] = example
81
89
  end
82
90
  end
83
91
 
84
- if pending_queue.length.zero? && processing_queue.length.zero? && ENV["SPECWRK_SRV_OUTPUT"]
92
+ if pending_queue.length.zero? && processing_queue.length.zero? && completed_queue.length.positive? && ENV["SPECWRK_SRV_OUTPUT"]
85
93
  completed_queue.dump_and_write(ENV["SPECWRK_SRV_OUTPUT"])
86
94
  end
87
95
 
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.2
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Westendorf