chore: move core package to top folder.

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi.Wu
2022-09-03 17:09:40 +08:00
committed by Jason Song
parent 1148903d79
commit 8255915350
10 changed files with 8 additions and 8 deletions

24
core/scheduler.go Normal file
View File

@@ -0,0 +1,24 @@
package core
import (
"context"
runnerv1 "gitea.com/gitea/proto-go/runner/v1"
)
type Filter struct {
Kind string
Type string
OS string
Arch string
Kernel string
}
// Scheduler schedules Build stages for execution.
type Scheduler interface {
// Schedule schedules the stage for execution.
Schedule(context.Context, *runnerv1.Stage) error
// Request requests the next stage scheduled for execution.
Request(context.Context, Filter) (*runnerv1.Stage, error)
}

34
core/status.go Normal file
View File

@@ -0,0 +1,34 @@
package core
// BuildStatus represents a build status
type BuildStatus string
// enumerate all the statuses of bot build
const (
StatusSkipped BuildStatus = "skipped"
StatusBlocked BuildStatus = "blocked"
StatusDeclined BuildStatus = "declined"
StatusWaiting BuildStatus = "waiting_on_dependencies"
StatusPending BuildStatus = "pending"
StatusRunning BuildStatus = "running"
StatusPassing BuildStatus = "success"
StatusFailing BuildStatus = "failure"
StatusKilled BuildStatus = "killed"
StatusError BuildStatus = "error"
)
func (status BuildStatus) IsPending() bool {
return status == StatusPending
}
func (status BuildStatus) IsRunning() bool {
return status == StatusRunning
}
func (status BuildStatus) IsFailed() bool {
return status == StatusFailing || status == StatusKilled || status == StatusError
}
func (status BuildStatus) IsSuccess() bool {
return status == StatusPassing
}