-
Notifications
You must be signed in to change notification settings - Fork 18
fix: treat 0/0 release targets as 100% pass rate in policy evaluation #1049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -196,8 +196,8 @@ func (t *ReleaseTargetJobTracker) GetSuccessPercentage() float32 { | |
|
|
||
| numRt := len(t.ReleaseTargets) | ||
| if numRt == 0 { | ||
| span.SetAttributes(attribute.Float64("success_percentage", 0.0)) | ||
| return 0.0 // If no targets, consider it 100% successful | ||
| span.SetAttributes(attribute.Float64("success_percentage", 100.0)) | ||
| return 100.0 // vacuous truth: 0/0 targets successful | ||
| } | ||
|
|
||
| // Build a set of release target keys for filtering | ||
|
|
@@ -242,7 +242,7 @@ func (t *ReleaseTargetJobTracker) GetSuccessPercentageSatisfiedAt( | |
| } | ||
| numRt := len(t.ReleaseTargets) | ||
| if numRt == 0 { | ||
| return time.Time{} | ||
| return t.Version.CreatedAt | ||
| } | ||
|
Comment on lines
244
to
246
|
||
|
|
||
| // Build a set of release target keys for filtering | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the 0-target success percentage to 100% will flip PassRateEvaluator behavior for the no-release-targets case. There is an existing unit test (TestPassRateEvaluator_NoReleaseTargets in passrate_test.go) that currently asserts the opposite and will fail, and the minimumSuccessPercentage==0 branch in PassRateEvaluator will now treat a 0-target environment as allowed but set satisfiedAt based on GetEarliestSuccess() (which is zero time when there are no jobs). Consider updating PassRateEvaluator to explicitly handle len(tracker.ReleaseTargets)==0 (e.g., allow and set satisfiedAt to tracker.Version.CreatedAt) and adjust the related tests accordingly.