-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix actions skipped commit status indicator #34507
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
base: main
Are you sure you want to change the base?
Conversation
Seems good, but I wonder whether the other two missing statuses from action model should also be represented in commit status. Currently "blocked" and "unknown" are missing: gitea/models/actions/status.go Lines 15 to 24 in 14bb8f7
|
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.
Change is LGMT but we should review the other two potential missing states later.
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.
For consistency maybe add add
// IsSkipped represents if commit status state is skipped
func (css CommitStatusState) IsSkipped() bool {
return css == CommitStatusSkipped
}
@@ -18,6 +18,8 @@ const ( | |||
CommitStatusFailure CommitStatusState = "failure" | |||
// CommitStatusWarning is for when the CommitStatus is Warning | |||
CommitStatusWarning CommitStatusState = "warning" | |||
// CommitStatusSkipped is for when CommitStatus is Skipped | |||
CommitStatusSkipped CommitStatusState = "skipped" | |||
) | |||
|
|||
var commitStatusPriorities = map[CommitStatusState]int{ |
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.
Are commit statuses correctly merged with this change?
In Pull Request Status / Merged Commit Status Icon
I looked at other locations of the other constants.
e.g. assign skipped value 5
The compare method returns false in both directions if not part of commitStatusPriorities e.g. making a stable sort impossible.
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.
Thanks for pointing this out.
Im not sure if semantically skipped is "better than" success, anyhow ill assign 5 to it and we will see if anyone else has feedback.
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.
I can read and read over the nobetterthan function, somehow I tend to get confused
This is a "no better than" table, negation.... Error has value 0, because it is a better status than warning, pending, success.
e.g. if we start with skipped/success, we end with error if a single status is error
After reading my suggestion here seems to be not required, but I found something else about PRs.
NoBetterThan is never used inverted and having no value defined for skipped would have a similar outcome if every other value is already in this table.
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.
To make Pullrequests work correctly with required checks we might need to look at this proposed additional change:
diff --git a/modules/structs/commit_status.go b/modules/structs/commit_status.go
index fee0da214c..e600d8caf9 100644
--- a/modules/structs/commit_status.go
+++ b/modules/structs/commit_status.go
@@ -57,7 +57,7 @@ func (css CommitStatusState) IsPending() bool {
// IsSuccess represents if commit status state is success
func (css CommitStatusState) IsSuccess() bool {
- return css == CommitStatusSuccess
+ return css == CommitStatusSuccess || css == CommitStatusSkipped
}
// IsError represents if commit status state is error
diff --git a/services/pull/commit_status.go b/services/pull/commit_status.go
index 0bfff21746..2e2570d43a 100644
--- a/services/pull/commit_status.go
+++ b/services/pull/commit_status.go
@@ -58,7 +58,7 @@ func MergeRequiredContextsCommitStatus(commitStatuses []*git_model.CommitStatus,
}
}
- if matchedCount == 0 && returnedStatus == structs.CommitStatusSuccess {
+ if matchedCount == 0 && returnedStatus.IsSuccess() {
status := git_model.CalcCommitStatus(commitStatuses)
if status != nil {
return status.State
@@ -74,7 +74,7 @@ func IsCommitStatusContextSuccess(commitStatuses []*git_model.CommitStatus, requ
// If no specific context is required, require that last commit status is a success
if len(requiredContexts) == 0 {
status := git_model.CalcCommitStatus(commitStatuses)
- if status == nil || status.State != structs.CommitStatusSuccess {
+ if status == nil || !status.State.IsSuccess() {
return false
}
return true
@@ -84,7 +84,7 @@ func IsCommitStatusContextSuccess(commitStatuses []*git_model.CommitStatus, requ
var found bool
for _, commitStatus := range commitStatuses {
if commitStatus.Context == ctx {
- if commitStatus.State != structs.CommitStatusSuccess {
+ if !commitStatus.State.IsSuccess() {
return false
}
- The new Commit Status is not handled in the PullRequest UI
- My diff would change the IsSuccess function to return true for skipped as well to align with GitHub Actions (skipped <==> success)
- Code expecting Success status check within gitea is no longer working the same way
Maybe better wait for feedback of another maintainer instead of applying this, my knowledge confidence in this area of Gitea is not high...
@@ -18,6 +18,8 @@ const ( | |||
CommitStatusFailure CommitStatusState = "failure" | |||
// CommitStatusWarning is for when the CommitStatus is Warning | |||
CommitStatusWarning CommitStatusState = "warning" | |||
// CommitStatusSkipped is for when CommitStatus is Skipped | |||
CommitStatusSkipped CommitStatusState = "skipped" | |||
) | |||
|
|||
var commitStatusPriorities = map[CommitStatusState]int{ |
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.
I can read and read over the nobetterthan function, somehow I tend to get confused
This is a "no better than" table, negation.... Error has value 0, because it is a better status than warning, pending, success.
e.g. if we start with skipped/success, we end with error if a single status is error
After reading my suggestion here seems to be not required, but I found something else about PRs.
NoBetterThan is never used inverted and having no value defined for skipped would have a similar outcome if every other value is already in this table.
I don't think we can make |
-> I am not sure whether there is any problem in current implementation, but if we'd like to handle all statuses together, I recalled these two: Fix incomplete Actions status aggregations #32859 , Improve Actions status aggregations (#32860) , maybe related. |
We need to diff between
|
Yes this sounds good, the Pullrequest UI only consumes the combined status, if the function combine would then convert skipped to success this should work.
Current implementation of Gitea main is good, new problems only appear due to skipped mapped to a new commitstatusskipped. As far I understood the code.
Add IsSuccessOrSkipped and use it or inline are my other ideas here. EDIT lunny your suggestion could make the commit summary render a green checkmark instead of skipped if everything is skipped. Also replace IsSuccess with IsSuccessOrSkipped in the Pullrequest UI. At least this seems to be not like just add a new commit status and everything works. |
Addresses #34500