featureparity 0.0.42 → 0.0.43
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/fp/client.rb +4 -0
- data/lib/fp/commands/report.rb +78 -46
- data/lib/fp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0772bfae3ae0f193e6f8126d9d0618f9a5bbbff662a74d8f2b1ee65eb367aa27
|
|
4
|
+
data.tar.gz: 40941ce5c3983a4e5eee97116ac2b10949068d9734ae33d5e252c7bf2e78cb80
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 15d3efc2845b7aaa085c424adb1b7cabecf3a972dbf910e25dff6af6694531a1fe275a36e3068c12aaa7d3cbc5ff0b2d0667b572a71c5cc176f1923477a93990
|
|
7
|
+
data.tar.gz: dc034bc03abbe977cb589e64e20b5d51e86e76d1857fa404eff13b71afef1985cf0687c973776adbe5cc2c2d47603027e94101503b1d0cfd073f1883c088b8b1
|
data/lib/fp/client.rb
CHANGED
|
@@ -334,6 +334,10 @@ module Fp
|
|
|
334
334
|
post("/api/projects/#{project_id}/evidence", params)
|
|
335
335
|
end
|
|
336
336
|
|
|
337
|
+
def report_evidence_batch(project_id, receipts)
|
|
338
|
+
post("/api/projects/#{project_id}/evidence/batch", { receipts: receipts })
|
|
339
|
+
end
|
|
340
|
+
|
|
337
341
|
# POST /projects/:project_id/ci_results — the CI-only path.
|
|
338
342
|
#
|
|
339
343
|
# Unlike report_evidence (agents: present/stub), this hands the raw JUnit XML
|
data/lib/fp/commands/report.rb
CHANGED
|
@@ -303,24 +303,16 @@ module Fp
|
|
|
303
303
|
# tests in files this branch changed get them; the rest keep their own.
|
|
304
304
|
warn_if_not_production!
|
|
305
305
|
provenance = provenance_scope(opts, base_dir)
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
306
|
+
catalog = client.list_requirements(project_id: project_id)
|
|
307
|
+
unless catalog[:ok]
|
|
308
|
+
output.error(catalog[:error], status: catalog[:status])
|
|
309
|
+
exit 1
|
|
310
|
+
end
|
|
311
|
+
requirements_by_slug = (catalog[:data]['requirements'] || []).to_h { |r| [r['slug'], r] }
|
|
312
312
|
|
|
313
|
-
bindings.
|
|
313
|
+
skipped_unknown, known = bindings.partition { |binding| !requirements_by_slug.key?(binding.slug) }
|
|
314
|
+
receipts = known.map do |binding|
|
|
314
315
|
state = state_override || binding.state
|
|
315
|
-
|
|
316
|
-
# Verify the requirement exists before reporting (skip unknown slugs
|
|
317
|
-
# with a warning rather than aborting the whole batch).
|
|
318
|
-
req_result = requirement_cache[binding.slug] ||= client.find_requirement_by_slug(project_id, binding.slug)
|
|
319
|
-
unless req_result[:ok]
|
|
320
|
-
skipped_unknown << binding
|
|
321
|
-
next
|
|
322
|
-
end
|
|
323
|
-
|
|
324
316
|
params = {
|
|
325
317
|
project_id: project_id,
|
|
326
318
|
slug: binding.slug,
|
|
@@ -337,30 +329,17 @@ module Fp
|
|
|
337
329
|
params[:work_item_url] = opts[:work_item] if opts[:work_item] && stamped
|
|
338
330
|
params[:ci_url] = opts[:ci_url] if opts[:ci_url]
|
|
339
331
|
params[:title] = binding.title if binding.title
|
|
340
|
-
|
|
341
|
-
report_result = client.report_evidence(params)
|
|
342
|
-
|
|
343
|
-
# Evidence API may not exist yet (#1214). API Gateway returns 403
|
|
344
|
-
# (not 404) for unmatched routes.
|
|
345
|
-
if !report_result[:ok] && [403, 404].include?(report_result[:status])
|
|
346
|
-
api_unavailable = true
|
|
347
|
-
reported << { binding: binding, state: state, recorded: false }
|
|
348
|
-
next
|
|
349
|
-
end
|
|
350
|
-
|
|
351
|
-
unless report_result[:ok]
|
|
352
|
-
output.error("Failed to report '#{binding.slug}' (#{binding.surface}): #{report_result[:error]}", status: report_result[:status])
|
|
353
|
-
exit 1
|
|
354
|
-
end
|
|
355
|
-
|
|
356
|
-
reported << { binding: binding, state: state, recorded: true, stamped: stamped,
|
|
357
|
-
stored_status: stored_status_from(report_result),
|
|
358
|
-
stored_source: stored_source_from(report_result) }
|
|
332
|
+
{ binding: binding, state: state, stamped: stamped, params: params }
|
|
359
333
|
end
|
|
360
334
|
|
|
335
|
+
filed = file_receipts_in_batches(project_id, receipts) || file_receipts_one_by_one(receipts)
|
|
336
|
+
reported = filed[:reported]
|
|
337
|
+
skipped_unknown.concat(filed[:unknown])
|
|
338
|
+
api_unavailable = filed[:api_unavailable]
|
|
339
|
+
|
|
361
340
|
uploaded_media = []
|
|
362
341
|
if opts[:attach_media]
|
|
363
|
-
uploaded_media = upload_media(opts, media, base_dir,
|
|
342
|
+
uploaded_media = upload_media(opts, media, base_dir, requirements_by_slug)
|
|
364
343
|
end
|
|
365
344
|
|
|
366
345
|
emit_junit_summary(opts, reported, skipped_unknown, unmatched, api_unavailable, collisions,
|
|
@@ -440,22 +419,75 @@ module Fp
|
|
|
440
419
|
nil
|
|
441
420
|
end
|
|
442
421
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
422
|
+
BATCH_SIZE = 200
|
|
423
|
+
|
|
424
|
+
def file_receipts_in_batches(project_id, receipts)
|
|
425
|
+
reported = []
|
|
426
|
+
unknown = []
|
|
427
|
+
receipts.each_slice(BATCH_SIZE).with_index do |slice, slice_index|
|
|
428
|
+
result = client.report_evidence_batch(project_id, slice.map { |r| r[:params].except(:project_id) })
|
|
429
|
+
return nil if slice_index.zero? && !result[:ok] && [403, 404].include?(result[:status])
|
|
430
|
+
|
|
431
|
+
unless result[:ok]
|
|
432
|
+
output.error("Failed to report evidence: #{result[:error]}", status: result[:status])
|
|
433
|
+
exit 1
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
rows = result[:data].is_a?(Hash) ? Array(result[:data]['results']) : []
|
|
437
|
+
slice.each_with_index do |receipt, index|
|
|
438
|
+
row = rows.find { |r| r['index'] == index } || {}
|
|
439
|
+
case row['outcome']
|
|
440
|
+
when 'recorded'
|
|
441
|
+
reported << receipt.slice(:binding, :state, :stamped)
|
|
442
|
+
.merge(recorded: true, stored_status: row['status'], stored_source: row['source'])
|
|
443
|
+
when 'unknown_requirement'
|
|
444
|
+
unknown << receipt[:binding]
|
|
445
|
+
else
|
|
446
|
+
binding = receipt[:binding]
|
|
447
|
+
output.error("Failed to report '#{binding.slug}' (#{binding.surface}): #{row['error'] || 'the server returned no result for it'}",
|
|
448
|
+
status: row['error_status'])
|
|
449
|
+
exit 1
|
|
450
|
+
end
|
|
451
|
+
end
|
|
452
|
+
end
|
|
453
|
+
{ reported: reported, unknown: unknown, api_unavailable: false }
|
|
454
|
+
end
|
|
455
|
+
|
|
456
|
+
def file_receipts_one_by_one(receipts)
|
|
457
|
+
reported = []
|
|
458
|
+
api_unavailable = false
|
|
459
|
+
receipts.each do |receipt|
|
|
460
|
+
binding = receipt[:binding]
|
|
461
|
+
report_result = client.report_evidence(receipt[:params])
|
|
462
|
+
|
|
463
|
+
if !report_result[:ok] && [403, 404].include?(report_result[:status])
|
|
464
|
+
api_unavailable = true
|
|
465
|
+
reported << { binding: binding, state: receipt[:state], recorded: false }
|
|
466
|
+
next
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
unless report_result[:ok]
|
|
470
|
+
output.error("Failed to report '#{binding.slug}' (#{binding.surface}): #{report_result[:error]}", status: report_result[:status])
|
|
471
|
+
exit 1
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
reported << { binding: binding, state: receipt[:state], recorded: true, stamped: receipt[:stamped],
|
|
475
|
+
stored_status: stored_status_from(report_result),
|
|
476
|
+
stored_source: stored_source_from(report_result) }
|
|
477
|
+
end
|
|
478
|
+
{ reported: reported, unknown: [], api_unavailable: api_unavailable }
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
def upload_media(opts, media, base_dir, requirements_by_slug)
|
|
449
482
|
media.map do |m|
|
|
450
483
|
path = File.expand_path(m.path, base_dir)
|
|
451
|
-
|
|
484
|
+
requirement = requirements_by_slug[m.slug]
|
|
452
485
|
|
|
453
486
|
outcome = { slug: m.slug, surface: m.surface, path: m.path, example_title: m.example_title }
|
|
454
|
-
if
|
|
487
|
+
if requirement.nil?
|
|
455
488
|
outcome.merge(uploaded: false, reason: 'unknown requirement')
|
|
456
489
|
else
|
|
457
|
-
|
|
458
|
-
upload_one_media(requirement_id, path, m, opts).merge(
|
|
490
|
+
upload_one_media(requirement['id'], path, m, opts).merge(
|
|
459
491
|
slug: m.slug, surface: m.surface, path: m.path, example_title: m.example_title
|
|
460
492
|
)
|
|
461
493
|
end
|
data/lib/fp/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: featureparity
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.43
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stowzilla
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: net-http
|