feat: update task status

This commit is contained in:
Jason Song
2022-10-20 18:27:27 +08:00
parent a8f74d4ec8
commit feab4b1601
11 changed files with 186 additions and 42 deletions

38
models/bots/status.go Normal file
View File

@ -0,0 +1,38 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package bots
// Status represents the status of Run, RunJob, Task, or TaskStep
type Status int
const (
StatusUnknown Status = iota // 0, consistent with runnerv1.Result_RESULT_UNSPECIFIED
StatusSuccess // 1, consistent with runnerv1.Result_RESULT_SUCCESS
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
)
// String returns the string name of the Status
func (s Status) String() string {
return statusNames[s]
}
// IsDone returns whether the Status is final
func (s Status) IsDone() bool {
return s > StatusUnknown && s <= StatusSkipped
}
var statusNames = map[Status]string{
StatusUnknown: "unknown",
StatusWaiting: "waiting",
StatusRunning: "running",
StatusSuccess: "success",
StatusFailure: "failure",
StatusCancelled: "cancelled",
StatusSkipped: "skipped",
}