Skip to content

Commit 1ed0dba

Browse files
committed
update docs
1 parent bbd1b29 commit 1ed0dba

File tree

4 files changed

+52
-12
lines changed

4 files changed

+52
-12
lines changed

.testcoverage.example.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,31 @@ exclude:
4141
- \.pb\.go$ # excludes all protobuf generated files
4242
- ^pkg/bar # exclude package `pkg/bar`
4343

44-
# File name of go-test-coverage breakdown file, which can be used to
45-
# analyze coverage difference.
44+
# If specified, saves the current test coverage breakdown to this file.
45+
#
46+
# Typically, this breakdown is generated only for main (base) branches and
47+
# stored as an artifact. Later, this file can be used in feature branches
48+
# to compare test coverage against the base branch.
4649
breakdown-file-name: ''
4750

4851
diff:
49-
# File name of go-test-coverage breakdown file which will be used to
50-
# report coverage difference.
51-
base-breakdown-file-name: ''
52+
# Path to the test coverage breakdown file from the base branch.
53+
#
54+
# This file is usually generated and stored in the main (base) branch,
55+
# controled via `breakdown-file-name` property.
56+
# When set in a feature branch, it allows the tool to compute and report
57+
# the coverage difference between the current (feature) branch and the base.
58+
base-breakdown-file-name: ''
59+
60+
# Allowed threshold for the test coverage difference (in percentage)
61+
# between the feature branch and the base branch.
62+
#
63+
# By default, this is disabled (set to nil). Valid values range from
64+
# -100.0 to +100.0.
65+
#
66+
# Example:
67+
# If set to 0.5, an error will be reported if the feature branch has
68+
# less than 0.5% more coverage than the base.
69+
#
70+
# If set to -0.5, the check allows up to 0.5% less coverage than the base.
71+
threshold: nil

README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,34 @@ exclude:
125125
- \.pb\.go$ # excludes all protobuf generated files
126126
- ^pkg/bar # exclude package `pkg/bar`
127127

128-
# File name of go-test-coverage breakdown file, which can be used to
129-
# analyze coverage difference.
128+
# If specified, saves the current test coverage breakdown to this file.
129+
#
130+
# Typically, this breakdown is generated only for main (base) branches and
131+
# stored as an artifact. Later, this file can be used in feature branches
132+
# to compare test coverage against the base branch.
130133
breakdown-file-name: ''
131134

132135
diff:
133-
# File name of go-test-coverage breakdown file which will be used to
134-
# report coverage difference.
136+
# Path to the test coverage breakdown file from the base branch.
137+
#
138+
# This file is usually generated and stored in the main (base) branch,
139+
# controled via `breakdown-file-name` property.
140+
# When set in a feature branch, it allows the tool to compute and report
141+
# the coverage difference between the current (feature) branch and the base.
135142
base-breakdown-file-name: ''
143+
144+
# Allowed threshold for the test coverage difference (in percentage)
145+
# between the feature branch and the base branch.
146+
#
147+
# By default, this is disabled (set to nil). Valid values range from
148+
# -100.0 to +100.0.
149+
#
150+
# Example:
151+
# If set to 0.5, an error will be reported if the feature branch has
152+
# less than 0.5% more coverage than the base.
153+
#
154+
# If set to -0.5, the check allows up to 0.5% less coverage than the base.
155+
threshold: nil
136156
```
137157

138158
### Exclude Code from Coverage

pkg/testcoverage/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type Exclude struct {
5454

5555
type Diff struct {
5656
BaseBreakdownFileName string `yaml:"base-breakdown-file-name"`
57-
Threshold *float64 `yaml:"threshold"`
57+
Threshold *float64 `yaml:"threshold,omitempty"`
5858
}
5959

6060
type Badge struct {

pkg/testcoverage/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func nonZeroConfig() Config {
240240
BreakdownFileName: "breakdown.testcoverage",
241241
Diff: Diff{
242242
BaseBreakdownFileName: "breakdown.testcoverage",
243-
Threshold: ptr(-1.1),
243+
Threshold: ptr(-1.01),
244244
},
245245
GithubActionOutput: true,
246246
}
@@ -263,7 +263,7 @@ exclude:
263263
breakdown-file-name: 'breakdown.testcoverage'
264264
diff:
265265
base-breakdown-file-name: 'breakdown.testcoverage'
266-
threshold: -1.1
266+
threshold: -1.01
267267
github-action-output: true`
268268
}
269269

0 commit comments

Comments
 (0)