-
-
Notifications
You must be signed in to change notification settings - Fork 30
Closed
Labels
Description
Coverage is decreasing, but the difference is 0%, so the test passes.
coverage:
if: true
acceptable: diff >= 0%
codeToTestRatio:
if: false
testExecutionTime:
if: false
diff:
datastores:
- artifact://${GITHUB_REPOSITORY}
comment:
if: is_pull_request
summary:
if: true
report:
if: is_default_branch
datastores:
- artifact://${GITHUB_REPOSITORY}
I think using big.Rat instead of float64 for current and prev will likely resolve the issue.
Line 247 in ca82aca
func coverageAcceptable(current, prev float64, cond string) error { |
I haven't been able to conduct detailed tests, but I think it would be something like this.
-func coverageAcceptable(current, prev float64, cond string) error {
+func coverageAcceptable(current, prev *big.Rat, cond string) error {
if cond == "" {
return nil
}
@@ -258,10 +259,11 @@ func CoverageAcceptable(current, prev float64, cond string) error {
cond = fmt.Sprintf("current %s", cond)
}
+ diff, _ := current.Sub(current, prev).Float64()
variables := map[string]any{
"current": current,
"prev": prev,
- "diff": current - prev,
+ "diff": diff,
}
fmt.Printf("%v\n", variables["diff"])
ok, err := expr.Eval(fmt.Sprintf("(%s) == true", cond), variables)
@@ -274,7 +276,8 @@ func CoverageAcceptable(current, prev float64, cond string) error {
return fmt.Errorf("invalid condition `%s`", cond)
}
if !tf {
- return fmt.Errorf("code coverage is %.1f%%. the condition in the `coverage.acceptable:` section is not met (`%s`)", floor1(current), org)
+ cf, _ := current.Float64()
+ return fmt.Errorf("code coverage is %.1f%%. the condition in the `coverage.acceptable:` section is not met (`%s`)", cf, org)
}
return nil
}
k1LoW