pronto-rustcov 0.1.2 → 0.1.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pronto/rustcov.rb +57 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6215e6c0bfaf4c7115ea27c903505b5ff89b57cbe03557691cfece35e3fa0e74
4
- data.tar.gz: 4eb59d1bbb8ef99c8c0906d270eddaf6b834e9f235c3769e738d8ef046382848
3
+ metadata.gz: 63740536f0a7afad0d8d7072898fb5c90ffe7d73902cb234a6e6058c1733e221
4
+ data.tar.gz: acafff7d282c63394f8f4d0424ba14e3999cd23097da1d5443460e5b26d5310d
5
5
  SHA512:
6
- metadata.gz: ad94c2948cc78ea005437934b97245e0d95d166a48e5a434cba86b7b9c9f92622247f620b83bf56e5346bb1575c4b5fc719c5ae7450c729dd463289fd527848f
7
- data.tar.gz: a41ed3908e683e310d4019f7769f7bd14a88225875df16c762a6b530c900069cef802bb13cfbd35da115213182fe0dd44f3b42f2919cd02cf80d5338cf046481
6
+ metadata.gz: 66878eaab3af2cda55d7c6d74d569e5aaa8f9ddb21e9eca532eabb11248f6e737698f7ecbf872681849941908c450e7233ac704e949fb1578e3b4ae386818c7f
7
+ data.tar.gz: 2620f0434925e9b940ccb60fc8bea6ade2ba074980f78c90e45f3f8135bc6c7d3f3dd7eb4a0141e91dfa7ec3c4cd438339cd0ed3c701a8f1416fceefac1a8262
@@ -3,13 +3,68 @@ require 'pronto'
3
3
  module Pronto
4
4
  class Rustcov < Runner
5
5
  def run
6
+ if ENV['PRONTO_RUSTCOV_URL']
7
+ one_message_per_file_markdown('target/lcov.info', ENV['PRONTO_RUSTCOV_URL'])
8
+ else
9
+ one_message_per_file('target/lcov.info')
10
+ end
11
+ end
12
+
13
+ def messages_limit
14
+ ENV['PRONTO_RUSTCOV_MESSAGES_LIMIT']&.to_i || 10
15
+ end
16
+
17
+ def one_message_per_file_markdown(lcov_path, base_url)
18
+ base_url = base_url.delete_suffix('/')
19
+
20
+ return [] unless @patches
21
+
22
+ lcov = parse_lcov(lcov_path)
23
+
24
+ grouped = Hash.new { |h, k| h[k] = [] }
25
+
26
+ @patches.sort_by { |patch| -patch.added_lines.count }.take(messages_limit).each do |patch|
27
+ next unless patch.added_lines.any?
28
+ file_path = patch.new_file_full_path.to_s
29
+ uncovered = lcov[file_path]
30
+ next unless uncovered
31
+
32
+ patch.added_lines.each do |line|
33
+ if uncovered.include?(line.new_lineno)
34
+ grouped[patch].push(line)
35
+ end
36
+ end
37
+ end
38
+
39
+ grouped.map do |patch, lines|
40
+ linenos = lines.map(&:new_lineno).sort
41
+ ranges = linenos.chunk_while { |i, j| j == i + 1 }
42
+ .map { |group| group.size > 1 ? "#{group.first}–#{group.last}" : group.first.to_s }
43
+
44
+ url = "#{base_url}/#{patch.new_file_path}.html#L#{linenos.first}"
45
+ first_range_link = "[#{ranges.first}](#{url})"
46
+ message_text = "⚠️ Test coverage is missing for lines: #{first_range_link}, #{ranges[1..].join(', ')}"
47
+
48
+ # Attach the message to the first uncovered line
49
+ Pronto::Message.new(
50
+ patch.new_file_path,
51
+ lines.first,
52
+ :warning,
53
+ message_text,
54
+ nil,
55
+ self.class
56
+ )
57
+ end
58
+ end
59
+
60
+ def one_message_per_file(lcov_path)
6
61
  return [] unless @patches
7
62
 
8
- lcov = parse_lcov('target/lcov.info')
63
+ lcov = parse_lcov(lcov_path)
9
64
 
10
65
  grouped = Hash.new { |h, k| h[k] = [] }
11
66
 
12
- @patches.each do |patch|
67
+ @patches.sort_by { |patch| -patch.added_lines.count }.take(messages_limit).each do |patch|
13
68
  next unless patch.added_lines.any?
14
69
  file_path = patch.new_file_full_path.to_s
15
70
  uncovered = lcov[file_path]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto-rustcov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Lazureykis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-13 00:00:00.000000000 Z
11
+ date: 2025-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pronto