minitest-distributed 0.2.7 → 0.2.8

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: 5dae86a5761e82ad0675cb289f945eeb29039bbb55c5be5d9e832e22bd5eb62c
4
- data.tar.gz: 56c65bd5817b033a9a912dc24a1dd8ef7276efa75828a9b3a5dd1dfc82387e0c
3
+ metadata.gz: c348812d40ad3e74d8ec854264225eb4f444e3b4a8736c25272bade733a5affc
4
+ data.tar.gz: 2be00ebffab4e0df5b71f29d22917fb69cad0177a77f676c5fc6b512147d9784
5
5
  SHA512:
6
- metadata.gz: 3a48ade567a3e8db5f70b7b2fe0f9b1f19e295eaf457f49df59030b997bf17de3b86253def06ec60741f9b6344447a15239f345b3af4197fe3588851c4e22473
7
- data.tar.gz: b2ce6e5bfb8a24a308f4409b4e61b75db00fd3f677e1ea335d8b25e0c0f128eeb49737898fc6f7540923e965239e6bdb76dbdb14c22b42bea12ab06d88a08e7a
6
+ metadata.gz: 1ae5332ea20d9cd9f8e9fbed8e3c111a653ea7684f98953cdd174cd34e287a8b453a9401eeafa8a9508c15b49a3ad1f36b236a4d075c2d50ad8fa14e9ada57ae
7
+ data.tar.gz: 44461dbf7adfbde8dc6ae9736ee459a1fc1b9ca35ba36f07f592d0482b3be10ca705bd176902b9866e1e1aa39babea8f9f1108d9ab14af505a564111cb1b2cfe
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: "[BUG]"
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the issue**
11
+ A clear and concise description of the issue you're facing.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behaviour:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behaviour**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **What team are you on?**
27
+ Please provide the name of your team.
28
+
29
+ **Helpful links (Logs, Link to Build, Repo, PR etc.)**
30
+ Please provide any helpful links for investigating the issue.
31
+
32
+ **Is there a Slack thread related to this bug?**
33
+ After submitting this issue, you can use: @spy github issues create_comment repo=minitest-distributed issue_id=$NEW_ISSUE_ID on any relevant Slack threads to save that information here.
34
+
35
+ **Additional context**
36
+ Add any other context about the problem here.
37
+
38
+ If possible, assign appropriate severity level, priority (high, medium, low) and difficulty (easy, normal, difficult) labels to the issue.
39
+ SEV-1 <24-72h - Critical issue that actively impacts multiple users/products.
40
+ SEV-2 <14 days - Limited impact app or major inconvenience to app users, workarounds available.
41
+ SEV-3 <60 days - Minor issue requiring action, but not affecting a users ability to use the app.
42
+ SEV-4 <180 days - Minimal impact but something the team wants to fix eventually.
43
+ SEV-5 No timeline - Cosmetic issue or bugs, no effect on user's ability to use tooling.
@@ -10,8 +10,25 @@ name: Ruby
10
10
  on: push
11
11
 
12
12
  jobs:
13
+ test_32:
14
+ runs-on: shopify-ubuntu-latest
15
+ container: ruby:3.2
16
+
17
+ services:
18
+ redis:
19
+ image: redis
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Install dependencies
24
+ run: gem install bundler && bundle install
25
+ - name: Run tests
26
+ run: bin/rake test
27
+ env:
28
+ REDIS_URL: redis://redis:6379
29
+
13
30
  test_31:
14
- runs-on: ubuntu-latest
31
+ runs-on: shopify-ubuntu-latest
15
32
  container: ruby:3.1
16
33
 
17
34
  services:
@@ -28,7 +45,7 @@ jobs:
28
45
  REDIS_URL: redis://redis:6379
29
46
 
30
47
  test_30:
31
- runs-on: ubuntu-latest
48
+ runs-on: shopify-ubuntu-latest
32
49
  container: ruby:3.0
33
50
 
34
51
  services:
@@ -45,7 +62,7 @@ jobs:
45
62
  REDIS_URL: redis://redis:6379
46
63
 
47
64
  test_27:
48
- runs-on: ubuntu-latest
65
+ runs-on: shopify-ubuntu-latest
49
66
  container: ruby:2.7
50
67
 
51
68
  services:
@@ -62,7 +79,7 @@ jobs:
62
79
  REDIS_URL: redis://redis:6379
63
80
 
64
81
  typecheck:
65
- runs-on: ubuntu-latest
82
+ runs-on: shopify-ubuntu-latest
66
83
  container: ruby:2.7
67
84
  steps:
68
85
  - uses: actions/checkout@v2
@@ -72,8 +89,8 @@ jobs:
72
89
  run: bin/srb tc
73
90
 
74
91
  lint:
75
- runs-on: ubuntu-latest
76
- container: ruby:2.7
92
+ runs-on: shopify-ubuntu-latest
93
+ container: ruby:3.2
77
94
  steps:
78
95
  - uses: actions/checkout@v2
79
96
  - name: Install dependencies
data/.rubocop.yml CHANGED
@@ -14,6 +14,7 @@ AllCops:
14
14
  CacheRootDirectory: tmp/rubocop
15
15
  Exclude:
16
16
  - minitest-distributed.gemspec
17
+ NewCops: disable
17
18
 
18
19
  # This cop is broken when using assignments
19
20
  Layout/RescueEnsureAlignment:
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [About this repo](#about-this-repo) | [Commands](#commands) | [How to use this repo](#how-to-use-this-repo) | [Contribute to this repo](#contribute-to-this-repo) | [License](#license)
6
6
 
7
7
  ## About this repo
8
- **Introduction:**
8
+ **Introduction:**
9
9
 
10
10
  `minitest-distributed` is a plugin for [minitest](https://github.com/seattlerb/minitest)
11
11
  for executing tests on a distributed set of unreliable workers.
@@ -87,11 +87,11 @@ them to fail.
87
87
  - `--worker-id=IDENTIFIER` or `ENV[MINITEST_WORKER_ID]`: The ID of the worker,
88
88
  which should be unique to the cluster. We will default to a UUID if this is
89
89
  not set, which generally is fine.
90
- - `--exclude-file=PATH_TO_FILE`: Specify a file of tests to be excluded
91
- from running. The file should include test identifiers seperated by
90
+ - `--exclude-file=PATH_TO_FILE`: Specify a file of tests to be excluded
91
+ from running. The file should include test identifiers seperated by
92
92
  newlines.
93
93
  - `--include-file=PATH_TO_FILE`: Specify a file of tests to be included in
94
- the test run. The file should include test identifiers seperated by
94
+ the test run. The file should include test identifiers seperated by
95
95
  newlines.
96
96
 
97
97
  **Limitations**
@@ -124,7 +124,7 @@ To bootstrap a local development environment:
124
124
  - Start a Redis server by running `redis-server`, assuming you have Redis
125
125
  installed locally and the binary is on your `PATH`. Alternatively, you can
126
126
  set the `REDIS_URL` environment variable to point to a Redis instance running
127
- elsewhere.
127
+ elsewhere. You can also use `docker-compose up` with the provided `docker-compose.yml`.
128
128
  - Now, run `bin/rake test` to run the tests, and verify everything is working.
129
129
  - You can also run `bin/console` for an interactive prompt that will allow you
130
130
  to experiment.
data/bin/rake CHANGED
@@ -9,8 +9,10 @@
9
9
  #
10
10
 
11
11
  require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
- Pathname.new(__FILE__).realpath)
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path(
13
+ "../../Gemfile",
14
+ Pathname.new(__FILE__).realpath,
15
+ )
14
16
 
15
17
  bundle_binstub = File.expand_path("../bundle", __FILE__)
16
18
 
data/bin/rubocop CHANGED
@@ -9,8 +9,10 @@
9
9
  #
10
10
 
11
11
  require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
- Pathname.new(__FILE__).realpath)
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path(
13
+ "../../Gemfile",
14
+ Pathname.new(__FILE__).realpath,
15
+ )
14
16
 
15
17
  bundle_binstub = File.expand_path("../bundle", __FILE__)
16
18
 
data/bin/srb CHANGED
@@ -9,8 +9,10 @@
9
9
  #
10
10
 
11
11
  require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
- Pathname.new(__FILE__).realpath)
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path(
13
+ "../../Gemfile",
14
+ Pathname.new(__FILE__).realpath,
15
+ )
14
16
 
15
17
  bundle_binstub = File.expand_path("../bundle", __FILE__)
16
18
 
data/dev.yml ADDED
@@ -0,0 +1,7 @@
1
+ name: minitest-distributed
2
+
3
+ type: ruby
4
+
5
+ up:
6
+ - ruby: 3.2.0
7
+ - bundler
@@ -0,0 +1,6 @@
1
+ version: '2'
2
+ services:
3
+ redis:
4
+ image: redis:latest
5
+ ports:
6
+ - "6379:6379"
@@ -83,9 +83,18 @@ module Minitest
83
83
  sig { override.returns(ResultAggregate) }
84
84
  def combined_results
85
85
  @combined_results ||= begin
86
- stats_as_string = redis.mget(key("runs"), key("assertions"), key("passes"),
87
- key("failures"), key("errors"), key("skips"), key("requeues"), key("discards"),
88
- key("acks"), key("size"))
86
+ stats_as_string = redis.mget(
87
+ key("runs"),
88
+ key("assertions"),
89
+ key("passes"),
90
+ key("failures"),
91
+ key("errors"),
92
+ key("skips"),
93
+ key("requeues"),
94
+ key("discards"),
95
+ key("acks"),
96
+ key("size"),
97
+ )
89
98
 
90
99
  ResultAggregate.new(
91
100
  max_failures: configuration.max_failures,
@@ -279,8 +288,14 @@ module Minitest
279
288
 
280
289
  sig { params(block: Integer).returns(T::Array[EnqueuedRunnable]) }
281
290
  def claim_fresh_runnables(block:)
282
- result = redis.xreadgroup(group_name, configuration.worker_id, stream_key, ">",
283
- block: block, count: configuration.test_batch_size)
291
+ result = redis.xreadgroup(
292
+ group_name,
293
+ configuration.worker_id,
294
+ stream_key,
295
+ ">",
296
+ block: block,
297
+ count: configuration.test_batch_size,
298
+ )
284
299
  EnqueuedRunnable.from_redis_stream_claim(result.fetch(stream_key, []), configuration: configuration)
285
300
  end
286
301
 
@@ -293,8 +308,13 @@ module Minitest
293
308
  def xclaim_messages(pending_messages, max_idle_time_ms:)
294
309
  return [] if pending_messages.empty?
295
310
 
296
- claimed = redis.xclaim(stream_key, group_name, configuration.worker_id,
297
- max_idle_time_ms, pending_messages.keys)
311
+ claimed = redis.xclaim(
312
+ stream_key,
313
+ group_name,
314
+ configuration.worker_id,
315
+ max_idle_time_ms,
316
+ pending_messages.keys,
317
+ )
298
318
 
299
319
  EnqueuedRunnable.from_redis_stream_claim(claimed, pending_messages, configuration: configuration)
300
320
  end
@@ -421,10 +441,19 @@ module Minitest
421
441
  pipeline.incrby(key("size"), results.size)
422
442
  end
423
443
 
424
- @combined_results = ResultAggregate.new(max_failures: configuration.max_failures,
425
- runs: updated[0], assertions: updated[1], passes: updated[2],
426
- failures: updated[3], errors: updated[4], skips: updated[5], requeues: updated[6], discards: updated[7],
427
- acks: updated[8], size: updated[9])
444
+ @combined_results = ResultAggregate.new(
445
+ max_failures: configuration.max_failures,
446
+ runs: updated[0],
447
+ assertions: updated[1],
448
+ passes: updated[2],
449
+ failures: updated[3],
450
+ errors: updated[4],
451
+ skips: updated[5],
452
+ requeues: updated[6],
453
+ discards: updated[7],
454
+ acks: updated[8],
455
+ size: updated[9],
456
+ )
428
457
  end
429
458
 
430
459
  sig { params(name: String).returns(String) }
@@ -203,7 +203,7 @@ module Minitest
203
203
  sig do
204
204
  params(
205
205
  initial_result: Minitest::Result,
206
- block: T.proc.params(arg0: Minitest::Result).returns(EnqueuedRunnable::Result::Commit)
206
+ block: T.proc.params(arg0: Minitest::Result).returns(EnqueuedRunnable::Result::Commit),
207
207
  ).returns(EnqueuedRunnable::Result)
208
208
  end
209
209
  def commit_result(initial_result, &block)
@@ -78,11 +78,10 @@ module Minitest
78
78
  def add_tests_to(testsuites, suite, results)
79
79
  # TODO: make path relative to project root
80
80
  relative_path = T.must(results.first).source_location.first
81
- lineno = T.must(results.first).source_location.last
82
81
 
83
82
  testsuite = testsuites.add_element(
84
83
  "testsuite",
85
- { "name" => suite, "filepath" => relative_path }.merge(aggregate_suite_results(results))
84
+ { "name" => suite, "filepath" => relative_path }.merge(aggregate_suite_results(results)),
86
85
  )
87
86
 
88
87
  results.each do |test|
@@ -93,6 +92,7 @@ module Minitest
93
92
  "time" => test.time,
94
93
  # 'run-command' => ... # TODO
95
94
  }
95
+ lineno = test.source_location.last
96
96
  attributes["lineno"] = lineno if lineno != -1
97
97
 
98
98
  testcase_tag = testsuite.add_element("testcase", attributes)
@@ -107,9 +107,11 @@ module Minitest
107
107
  # noop
108
108
  when ResultType::Error, ResultType::Failed
109
109
  failure = T.must(result.failure)
110
- failure_tag = testcase.add_element("failure",
110
+ failure_tag = testcase.add_element(
111
+ "failure",
111
112
  "type" => result_type.serialize,
112
- "message" => truncate_message(failure.message))
113
+ "message" => truncate_message(failure.message),
114
+ )
113
115
  failure_tag.add_text(REXML::CData.new(result.to_s))
114
116
  else
115
117
  T.absurd(result_type)
@@ -27,7 +27,9 @@ module Minitest
27
27
  "\n\nThe test took %0.3fs to run, longer than the test timeout which is configured to be %0.1fs.\n" \
28
28
  "Another worker likely claimed ownership of this test, and will commit the result instead.\n" \
29
29
  "For best results, make sure that all your tests finish within %0.1fs.",
30
- result.time, test_timeout_seconds, test_timeout_seconds
30
+ result.time,
31
+ test_timeout_seconds,
32
+ test_timeout_seconds,
31
33
  )
32
34
  end
33
35
 
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Minitest
5
5
  module Distributed
6
- VERSION = "0.2.7"
6
+ VERSION = "0.2.8"
7
7
  end
8
8
  end
@@ -8,10 +8,17 @@ module Minitest
8
8
  extend T::Sig
9
9
 
10
10
  def plugin_distributed_options(opts, options)
11
+ continuous_integration = ENV.fetch("CI", "false") == "true"
12
+ options[:disable_distributed] = !continuous_integration
13
+
11
14
  opts.on("--disable-distributed", "Disable the distributed plugin") do
12
15
  options[:disable_distributed] = true
13
16
  end
14
17
 
18
+ opts.on("--enable-distributed", "Enable the distributed plugin") do
19
+ options[:disable_distributed] = false
20
+ end
21
+
15
22
  options[:distributed] = Minitest::Distributed::Configuration.from_command_line_options(opts, options)
16
23
  end
17
24
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-distributed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willem van Bergen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-12 00:00:00.000000000 Z
11
+ date: 2023-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -80,6 +80,7 @@ executables: []
80
80
  extensions: []
81
81
  extra_rdoc_files: []
82
82
  files:
83
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
83
84
  - ".github/dependabot.yml"
84
85
  - ".github/workflows/ruby.yml"
85
86
  - ".gitignore"
@@ -96,6 +97,8 @@ files:
96
97
  - bin/rubocop
97
98
  - bin/setup
98
99
  - bin/srb
100
+ - dev.yml
101
+ - docker-compose.yml
99
102
  - lib/minitest/distributed.rb
100
103
  - lib/minitest/distributed/configuration.rb
101
104
  - lib/minitest/distributed/coordinators/coordinator_interface.rb