rspec-mergify 0.1.2 → 0.1.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/mergify/rspec/ci_insights.rb +4 -1
- data/lib/mergify/rspec/flaky_detection.rb +21 -4
- 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: 968b0ced5510f59941eb189080af9e540dc8cd2799757bb16f0dbe746204471e
|
|
4
|
+
data.tar.gz: 307dff0317e1abf576472b0428a1e3f0f8d7f1b1b9257c84ecfd81f0fac9152c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 23673868ac2acd11145346748cea2e5c1cae71cb6c55371ad1440a2f9bdf3436ddf0ebaaef9ae2bfd7a56e5d435b67c3f449b3161201becbd3a7b864dea8d2ad
|
|
7
|
+
data.tar.gz: 2d676dd9fc25b6383db1013e42513d5f70208a6796f4fe4fa5544493d123736871b6d7617c9590c7f8fc8fd2fa4ffb99cf1b683c9cf6df0d124c6a8a27822c05
|
|
@@ -145,7 +145,6 @@ module Mergify
|
|
|
145
145
|
# rubocop:disable Metrics/MethodLength
|
|
146
146
|
def load_flaky_detector
|
|
147
147
|
return unless @token && @repo_name
|
|
148
|
-
return unless Utils.env_truthy?('_MERGIFY_TEST_NEW_FLAKY_DETECTION')
|
|
149
148
|
|
|
150
149
|
require_relative 'flaky_detection'
|
|
151
150
|
mode = @base_branch_name ? 'new' : 'unhealthy'
|
|
@@ -155,6 +154,10 @@ module Mergify
|
|
|
155
154
|
full_repository_name: @repo_name,
|
|
156
155
|
mode: mode
|
|
157
156
|
)
|
|
157
|
+
rescue FlakyDetectionDisabledError
|
|
158
|
+
# The repository has not opted into flaky detection, or has no baseline
|
|
159
|
+
# yet. Both are expected; skip without surfacing an error.
|
|
160
|
+
nil
|
|
158
161
|
rescue StandardError => e
|
|
159
162
|
@flaky_detector_error_message = "Could not load flaky detector: #{e.message}"
|
|
160
163
|
end
|
|
@@ -8,6 +8,12 @@ require_relative 'utils'
|
|
|
8
8
|
|
|
9
9
|
module Mergify
|
|
10
10
|
module RSpec
|
|
11
|
+
# Signals that flaky detection must not run for this session, and that this
|
|
12
|
+
# is expected rather than a failure: the repository has not opted in (the
|
|
13
|
+
# server responds with 404) or there is no baseline of recorded tests yet.
|
|
14
|
+
# Callers skip silently instead of surfacing an error banner.
|
|
15
|
+
class FlakyDetectionDisabledError < StandardError; end
|
|
16
|
+
|
|
11
17
|
# Manages intelligent test rerunning with budget constraints for flaky detection.
|
|
12
18
|
# rubocop:disable Metrics/ClassLength
|
|
13
19
|
class FlakyDetector
|
|
@@ -193,7 +199,7 @@ module Mergify
|
|
|
193
199
|
|
|
194
200
|
private
|
|
195
201
|
|
|
196
|
-
# rubocop:disable Metrics/AbcSize
|
|
202
|
+
# rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
197
203
|
def fetch_context
|
|
198
204
|
owner, repo = Utils.split_full_repo_name(@full_repository_name)
|
|
199
205
|
uri = URI("#{@url}/v1/ci/#{owner}/repositories/#{repo}/flaky-detection-context")
|
|
@@ -207,9 +213,18 @@ module Mergify
|
|
|
207
213
|
request['Authorization'] = "Bearer #{@token}"
|
|
208
214
|
|
|
209
215
|
response = http.request(request)
|
|
210
|
-
|
|
216
|
+
case response.code.to_i
|
|
217
|
+
when 200
|
|
218
|
+
parse_context(response.body)
|
|
219
|
+
when 404
|
|
220
|
+
# A 404 means the repository has not opted into flaky detection; this
|
|
221
|
+
# is the expected default, not an error.
|
|
222
|
+
raise FlakyDetectionDisabledError
|
|
223
|
+
else
|
|
224
|
+
raise "Mergify API returned HTTP #{response.code}"
|
|
225
|
+
end
|
|
211
226
|
end
|
|
212
|
-
# rubocop:enable Metrics/AbcSize
|
|
227
|
+
# rubocop:enable Metrics/AbcSize,Metrics/MethodLength
|
|
213
228
|
|
|
214
229
|
# rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
|
215
230
|
def parse_context(body)
|
|
@@ -231,7 +246,9 @@ module Mergify
|
|
|
231
246
|
def validate!
|
|
232
247
|
return unless @mode == 'new' && @context[:existing_test_names].empty?
|
|
233
248
|
|
|
234
|
-
|
|
249
|
+
# Without a baseline, `new` mode would treat every test as new and rerun
|
|
250
|
+
# the whole suite. Skip instead of surfacing an error.
|
|
251
|
+
raise FlakyDetectionDisabledError
|
|
235
252
|
end
|
|
236
253
|
|
|
237
254
|
def remaining_budget
|