chore: remove Result from task and step

This commit is contained in:
Jason Song
2022-11-18 12:26:34 +08:00
parent dd417a3270
commit 0f5aab0c1a
6 changed files with 33 additions and 27 deletions

View File

@ -4,6 +4,8 @@
package bots
import runnerv1 "gitea.com/gitea/proto-go/runner/v1"
// Status represents the status of Run, RunJob, Task, or TaskStep
type Status int
@ -13,9 +15,9 @@ const (
StatusFailure // 2, consistent with runnerv1.Result_RESULT_FAILURE
StatusCancelled // 3, consistent with runnerv1.Result_RESULT_CANCELLED
StatusSkipped // 4, consistent with runnerv1.Result_RESULT_SKIPPED
StatusWaiting // 5
StatusRunning // 6
StatusBlocked // 7
StatusWaiting // 5, isn't a runnerv1.Result
StatusRunning // 6, isn't a runnerv1.Result
StatusBlocked // 7, isn't a runnerv1.Result
)
// String returns the string name of the Status
@ -33,6 +35,10 @@ func (s Status) HasRun() bool {
return s.In(StatusSuccess, StatusFailure)
}
func (s Status) IsUnknown() bool {
return s == StatusUnknown
}
func (s Status) IsSuccess() bool {
return s == StatusSuccess
}
@ -66,6 +72,13 @@ func (s Status) In(statuses ...Status) bool {
return false
}
func (s Status) AsResult() runnerv1.Result {
if s.IsDone() {
return runnerv1.Result(s)
}
return runnerv1.Result_RESULT_UNSPECIFIED
}
var statusNames = map[Status]string{
StatusUnknown: "unknown",
StatusWaiting: "waiting",