rspec-mergify 0.0.1 → 0.0.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: ea10824d5251a6814614815a6a4810591e4ed3fe0980d731a5cfcf5c834fa6c8
4
- data.tar.gz: 28ca44cd61f5b92a280b3d4bf946cdd956316b99cc489dd767b28470e4b902b8
3
+ metadata.gz: 6620dc68c37035d9a03d498baaa8d190df7d27ab7d31fdab36b08ae7b937b382
4
+ data.tar.gz: c67c51eec28faf72ad4840571107b251bb6eff923e96274be2c3345fdd672d1d
5
5
  SHA512:
6
- metadata.gz: 3c7c2a9d250516364d3b051e019d35b97b873ce7dbe8d5200d9aad9f1ef832de1a6d7386f4cb9367fcad35ff66f088bc235bb8123e0b377f3dfb5cee07741985
7
- data.tar.gz: 2c5d31956e19e4d6c71463b75c26818e89e0e4c2de8cac4d92ca9997b50d87b1195783cfdcf375bcc70fa36a99e544ba91021aaf50e92042469f1eb0e40f31d3
6
+ metadata.gz: 485019cda8980abe528dcc4833eec21c662f209e2c7b7ae966ecc32ce284b06eb25e3c919496329d94eea8f70e1b7dc889a770e42e4cec40f6db3d9cd1763882
7
+ data.tar.gz: 9552f28c2d015ce6aa70f81cb50c021037c971619a3cafa19269654f997afb30540293426d18d3bcc8236e945aeaea2bc49d86ba43c57c71dff26e048112f260
@@ -16,6 +16,16 @@ module Mergify
16
16
  # Add formatter when in CI
17
17
  config.add_formatter(Mergify::RSpec::Formatter) if Utils.in_ci?
18
18
 
19
+ # Flaky detection: prepare session with all example IDs
20
+ config.before(:suite) do
21
+ ci = Mergify::RSpec.ci_insights
22
+ fd = ci&.flaky_detector
23
+ if fd
24
+ all_ids = ::RSpec.world.example_groups.flat_map(&:descendants).flat_map(&:examples).map(&:id)
25
+ fd.prepare_for_session(all_ids)
26
+ end
27
+ end
28
+
19
29
  # Quarantine: mark tests before execution
20
30
  config.before(:each) do |example|
21
31
  ci = Mergify::RSpec.ci_insights
@@ -32,14 +42,24 @@ module Mergify
32
42
 
33
43
  example.run
34
44
 
35
- next unless fd&.rerunning_test?(example.id)
45
+ # Feed metrics from the initial run so the detector can evaluate
46
+ if fd
47
+ run_time = example.execution_result.run_time || 0.0
48
+ status = example.execution_result.status
49
+ fd.fill_metrics_from_report(example.id, 'setup', 0.0, status)
50
+ fd.fill_metrics_from_report(example.id, 'call', run_time, status)
51
+ fd.fill_metrics_from_report(example.id, 'teardown', 0.0, status)
52
+ end
36
53
 
37
- fd.set_test_deadline(example.id)
38
- next if fd.test_too_slow?(example.id)
54
+ next unless fd&.rerunning_test?(example.id)
39
55
 
56
+ # Mark as flaky detection candidate (even if too slow to rerun)
40
57
  example.metadata[:mergify_flaky_detection] = true
41
58
  example.metadata[:mergify_new_test] = true if fd.mode == 'new'
42
59
 
60
+ fd.set_test_deadline(example.id)
61
+ next if fd.test_too_slow?(example.id)
62
+
43
63
  distinct_outcomes = Set.new
44
64
  distinct_outcomes.add(example.execution_result.status) if example.execution_result.status
45
65
 
@@ -189,13 +189,13 @@ module Mergify
189
189
  output.puts report if report
190
190
  end
191
191
 
192
- def flush_and_shutdown
192
+ def flush_and_shutdown # rubocop:disable Metrics/MethodLength
193
193
  return unless @ci_insights&.tracer_provider
194
194
 
195
195
  begin
196
196
  @ci_insights.tracer_provider.force_flush
197
197
  rescue StandardError => e
198
- output.puts "Error while exporting traces: #{e.message}"
198
+ print_export_error(e)
199
199
  end
200
200
 
201
201
  begin
@@ -204,6 +204,17 @@ module Mergify
204
204
  output.puts "Error while shutting down the tracer: #{e.message}"
205
205
  end
206
206
  end
207
+
208
+ def print_export_error(error)
209
+ output.puts "Error while exporting traces: #{error.message}"
210
+ output.puts ''
211
+ output.puts 'Common issues:'
212
+ output.puts ' - Your MERGIFY_TOKEN might not be set or could be invalid'
213
+ output.puts ' - CI Insights might not be enabled for this repository'
214
+ output.puts ' - There might be a network connectivity issue with the Mergify API'
215
+ output.puts ''
216
+ output.puts 'Documentation: https://docs.mergify.com/ci-insights/test-frameworks/'
217
+ end
207
218
  end
208
219
  # rubocop:enable Metrics/ClassLength
209
220
  end
@@ -2,8 +2,17 @@
2
2
 
3
3
  module Mergify
4
4
  module RSpec
5
- VERSION = `git describe --tags --match '*' 2>/dev/null`.then do |v|
6
- v.empty? ? '0.0.0.dev' : v.tr('-', '.')
5
+ VERSION = begin
6
+ v = `git describe --tags 2>/dev/null`.strip.delete_prefix('v')
7
+ if v.empty?
8
+ '0.0.0.dev'
9
+ elsif v.include?('-')
10
+ # e.g. "0.1.0-3-gabc123" -> "0.1.0.dev3"
11
+ parts = v.split('-')
12
+ "#{parts[0]}.dev#{parts[1]}"
13
+ else
14
+ v
15
+ end
7
16
  end
8
17
  end
9
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-mergify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mergify