couve 0.8.0 → 0.9.0
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/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +6 -6
- data/couve.gemspec +31 -0
- data/lib/couve/parser.rb +6 -6
- data/lib/couve/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4f4a216f249b8b99c5faf04dfef0f043f41c935955c2e0f4beedffe1aae99032
|
|
4
|
+
data.tar.gz: 124582fed81b0b3197a5a34219829b5f222a798e0afea8c3dc74f2d7bbc9d93b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e195aa5e380cc001ddb50475e3ee46c97e60b8b160363a9f72f2563a22daa6c216b9f60327998ffd12efcf7eab34a0966ddb71080126c12081c36d11cd1d4d3
|
|
7
|
+
data.tar.gz: 957caf172202bc89862cb4e68c69975b157010846246615bbc7e9477eb27004c55f80a61a196206aa2cbf99a66117bf066a1d0d47ed398a03fb1ba29fa13e0f2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.9.0] - 2026-06-09
|
|
4
|
+
|
|
5
|
+
- **Breaking:** raise the green threshold to 100%, so 🟢 now means the file is fully covered and `--fail-on-low-coverage` exits `1` for any reported file below 100% (previously 66.66%).
|
|
6
|
+
- Rate files and evaluate the coverage gate on the unrounded percentage, so a file at e.g. 99.996% no longer rounds up to 100% and slips past the gate.
|
|
7
|
+
- Display percentages with two decimal places in all cases (e.g. `60.00%`), flooring instead of rounding, so a partially covered file never displays as `100.00%`.
|
|
8
|
+
|
|
3
9
|
## [0.8.0] - 2026-06-05
|
|
4
10
|
|
|
5
11
|
- Add `--fail-on-low-coverage` flag to exit with a non-zero status when any reported file is below 100% coverage.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -46,15 +46,15 @@ $ couve path/to/coverage.json path/to/report.html # HTML report
|
|
|
46
46
|
$ couve path/to/coverage.json path/to/report.md # Markdown report
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
The Markdown report renders as a GitHub-flavored table, with a colored rating indicator
|
|
49
|
+
The Markdown report renders as a GitHub-flavored table, with a colored rating indicator reflecting each file's coverage level — 🔴 below 33.33%, 🟡 from there up to (but not including) 100%, and 🟢 only for fully covered files:
|
|
50
50
|
|
|
51
51
|
```markdown
|
|
52
52
|
## Coverage problems
|
|
53
53
|
|
|
54
54
|
| Rating | Coverage | File | Not covered lines |
|
|
55
55
|
| :---: | ---: | :--- | :--- |
|
|
56
|
-
| 🔴 | 30% | app/models/foo.rb | 3, 8, 21 |
|
|
57
|
-
| 🟡 | 50% | app/services/bar.rb | 5, 6 |
|
|
56
|
+
| 🔴 | 30.00% | app/models/foo.rb | 3, 8, 21 |
|
|
57
|
+
| 🟡 | 50.00% | app/services/bar.rb | 5, 6 |
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
A typical CI setup keeps the HTML report as an artifact and posts the Markdown report to the pull request, e.g. with the GitHub CLI:
|
|
@@ -83,7 +83,7 @@ Only files that appear both in the list and in the coverage data are shown; the
|
|
|
83
83
|
|
|
84
84
|
### Failing the build on low coverage
|
|
85
85
|
|
|
86
|
-
By default couve always exits `0` — it only generates the report. Pass `--fail-on-low-coverage` to make couve exit `1` when any **reported** file is below
|
|
86
|
+
By default couve always exits `0` — it only generates the report. Pass `--fail-on-low-coverage` to make couve exit `1` when any **reported** file is below 100% coverage, i.e. rated 🔴 or 🟡:
|
|
87
87
|
|
|
88
88
|
```sh
|
|
89
89
|
couve coverage.json report.md --fail-on-low-coverage
|
|
@@ -92,10 +92,10 @@ couve coverage.json report.md --fail-on-low-coverage
|
|
|
92
92
|
The report is written **before** couve exits, so the offending files stay visible in the report (and in any PR comment built from it). The offending files are also printed to standard error:
|
|
93
93
|
|
|
94
94
|
```
|
|
95
|
-
couve: coverage below
|
|
95
|
+
couve: coverage below 100% in app/models/foo.rb, app/services/bar.rb
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
-
The threshold is the
|
|
98
|
+
The threshold is fixed at 100%; there is nothing to configure. Note that the default report only lists files below 100%, so project-wide the flag fails whenever the report is non-empty. In practice you'll want it together with `--changed-files`: when you only report the files you changed, only those files are evaluated, so a fully covered (or empty) changed-file set passes the build even if untouched files elsewhere are poorly covered.
|
|
99
99
|
|
|
100
100
|
```sh
|
|
101
101
|
# Post the report to the PR, then redden the build if a changed file is under-covered:
|
data/couve.gemspec
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/couve/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "couve"
|
|
7
|
+
spec.version = Couve::VERSION
|
|
8
|
+
spec.authors = ["Cezinha"]
|
|
9
|
+
spec.email = ["cesar@asseinfo.com.br"]
|
|
10
|
+
spec.metadata = { "rubygems_mfa_required" => "true" }
|
|
11
|
+
|
|
12
|
+
spec.summary = "Generate a human readable report for CodeClimate test-reporter gem."
|
|
13
|
+
|
|
14
|
+
# Specify which files should be added to the gem when it is released.
|
|
15
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
16
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
17
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
18
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
spec.bindir = "exe"
|
|
22
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
23
|
+
spec.require_paths = ["lib", "lib/couve"]
|
|
24
|
+
spec.required_ruby_version = ">= 3"
|
|
25
|
+
|
|
26
|
+
# Uncomment to register a new dependency of your gem
|
|
27
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
|
28
|
+
|
|
29
|
+
# For more information and examples about making a new gem, checkout our
|
|
30
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
|
31
|
+
end
|
data/lib/couve/parser.rb
CHANGED
|
@@ -5,7 +5,7 @@ require "json"
|
|
|
5
5
|
module Couve
|
|
6
6
|
class Parser # rubocop:disable Metrics/ClassLength
|
|
7
7
|
RED_THRESHOLD = 33.33
|
|
8
|
-
GREEN_THRESHOLD =
|
|
8
|
+
GREEN_THRESHOLD = 100
|
|
9
9
|
|
|
10
10
|
def initialize(coverage, changed_files: nil)
|
|
11
11
|
@coverage = JSON.parse(coverage, symbolize_names: true)
|
|
@@ -49,8 +49,8 @@ module Couve
|
|
|
49
49
|
|
|
50
50
|
def to_markdown
|
|
51
51
|
rows = @coverage[:source_files].map do |source_file|
|
|
52
|
-
percentage = source_file[:covered_percent].
|
|
53
|
-
indicator = percentage_indicator(
|
|
52
|
+
percentage = format("%.2f", source_file[:covered_percent].floor(2))
|
|
53
|
+
indicator = percentage_indicator(source_file[:covered_percent])
|
|
54
54
|
|
|
55
55
|
"| #{indicator} | #{percentage}% | #{source_file[:name]} | #{not_covered_lines(source_file)} |"
|
|
56
56
|
end
|
|
@@ -66,7 +66,7 @@ module Couve
|
|
|
66
66
|
|
|
67
67
|
def low_coverage_files
|
|
68
68
|
@coverage[:source_files]
|
|
69
|
-
.select { |source_file| source_file[:covered_percent]
|
|
69
|
+
.select { |source_file| source_file[:covered_percent] < GREEN_THRESHOLD }
|
|
70
70
|
.map { |source_file| source_file[:name] }
|
|
71
71
|
end
|
|
72
72
|
|
|
@@ -82,8 +82,8 @@ module Couve
|
|
|
82
82
|
html = ["<tbody>"]
|
|
83
83
|
|
|
84
84
|
@coverage[:source_files].each do |source_file|
|
|
85
|
-
percentage = source_file[:covered_percent].
|
|
86
|
-
bg_color = percentage_bar_color(
|
|
85
|
+
percentage = format("%.2f", source_file[:covered_percent].floor(2))
|
|
86
|
+
bg_color = percentage_bar_color(source_file[:covered_percent])
|
|
87
87
|
|
|
88
88
|
html << " <tr>"
|
|
89
89
|
html << " <td class=\"col-1\">"
|
data/lib/couve/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: couve
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cezinha
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email:
|
|
@@ -32,6 +32,7 @@ files:
|
|
|
32
32
|
- bin/guard
|
|
33
33
|
- bin/rubocop
|
|
34
34
|
- bin/setup
|
|
35
|
+
- couve.gemspec
|
|
35
36
|
- exe/couve
|
|
36
37
|
- lib/couve.rb
|
|
37
38
|
- lib/couve/parser.rb
|