refactor: rename model

This commit is contained in:
Jason Song 2022-12-06 13:48:09 +08:00
parent f2c7bbb0bc
commit c07d0c1768
No known key found for this signature in database
GPG Key ID: 8402EEEE4511A8B5
21 changed files with 180 additions and 180 deletions

View File

@ -21,8 +21,8 @@ import (
"xorm.io/builder" "xorm.io/builder"
) )
// BotRun represents a run of a workflow file // ActionRun represents a run of a workflow file
type BotRun struct { type ActionRun struct {
ID int64 ID int64
Title string Title string
RepoID int64 `xorm:"index unique(repo_index)"` RepoID int64 `xorm:"index unique(repo_index)"`
@ -45,16 +45,16 @@ type BotRun struct {
} }
func init() { func init() {
db.RegisterModel(new(BotRun)) db.RegisterModel(new(ActionRun))
db.RegisterModel(new(BotRunIndex)) db.RegisterModel(new(ActionRunIndex))
} }
func (run *BotRun) HTMLURL() string { func (run *ActionRun) HTMLURL() string {
return fmt.Sprintf("%s/bots/runs/%d", run.Repo.HTMLURL(), run.Index) return fmt.Sprintf("%s/bots/runs/%d", run.Repo.HTMLURL(), run.Index)
} }
// LoadAttributes load Repo TriggerUser if not loaded // LoadAttributes load Repo TriggerUser if not loaded
func (run *BotRun) LoadAttributes(ctx context.Context) error { func (run *ActionRun) LoadAttributes(ctx context.Context) error {
if run == nil { if run == nil {
return nil return nil
} }
@ -81,7 +81,7 @@ func (run *BotRun) LoadAttributes(ctx context.Context) error {
return nil return nil
} }
func (run *BotRun) TakeTime() time.Duration { func (run *ActionRun) TakeTime() time.Duration {
if run.Started == 0 { if run.Started == 0 {
return 0 return 0
} }
@ -93,7 +93,7 @@ func (run *BotRun) TakeTime() time.Duration {
return time.Since(started).Truncate(time.Second) return time.Since(started).Truncate(time.Second)
} }
func (run *BotRun) GetPushEventPayload() (*api.PushPayload, error) { func (run *ActionRun) GetPushEventPayload() (*api.PushPayload, error) {
if run.Event == webhook.HookEventPush { if run.Event == webhook.HookEventPush {
var payload api.PushPayload var payload api.PushPayload
if err := json.Unmarshal([]byte(run.EventPayload), &payload); err != nil { if err := json.Unmarshal([]byte(run.EventPayload), &payload); err != nil {
@ -129,7 +129,7 @@ func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) err
} }
// InsertRun inserts a bot run // InsertRun inserts a bot run
func InsertRun(run *BotRun, jobs []*jobparser.SingleWorkflow) error { func InsertRun(run *ActionRun, jobs []*jobparser.SingleWorkflow) error {
ctx, commiter, err := db.TxContext(db.DefaultContext) ctx, commiter, err := db.TxContext(db.DefaultContext)
if err != nil { if err != nil {
return err return err
@ -162,7 +162,7 @@ func InsertRun(run *BotRun, jobs []*jobparser.SingleWorkflow) error {
return err return err
} }
runJobs := make([]*BotRunJob, 0, len(jobs)) runJobs := make([]*ActionRunJob, 0, len(jobs))
for _, v := range jobs { for _, v := range jobs {
id, job := v.Job() id, job := v.Job()
needs := job.Needs() needs := job.Needs()
@ -172,7 +172,7 @@ func InsertRun(run *BotRun, jobs []*jobparser.SingleWorkflow) error {
if len(needs) > 0 { if len(needs) > 0 {
status = StatusBlocked status = StatusBlocked
} }
runJobs = append(runJobs, &BotRunJob{ runJobs = append(runJobs, &ActionRunJob{
RunID: run.ID, RunID: run.ID,
RepoID: run.RepoID, RepoID: run.RepoID,
OwnerID: run.OwnerID, OwnerID: run.OwnerID,
@ -207,8 +207,8 @@ func (err ErrRunNotExist) Error() string {
return fmt.Sprintf("run [%d] is not exist", err.ID) return fmt.Sprintf("run [%d] is not exist", err.ID)
} }
func GetRunByID(ctx context.Context, id int64) (*BotRun, error) { func GetRunByID(ctx context.Context, id int64) (*ActionRun, error) {
var run BotRun var run ActionRun
has, err := db.GetEngine(ctx).Where("id=?", id).Get(&run) has, err := db.GetEngine(ctx).Where("id=?", id).Get(&run)
if err != nil { if err != nil {
return nil, err return nil, err
@ -221,8 +221,8 @@ func GetRunByID(ctx context.Context, id int64) (*BotRun, error) {
return &run, nil return &run, nil
} }
func GetRunByIndex(ctx context.Context, repoID, index int64) (*BotRun, error) { func GetRunByIndex(ctx context.Context, repoID, index int64) (*ActionRun, error) {
run := &BotRun{ run := &ActionRun{
RepoID: repoID, RepoID: repoID,
Index: index, Index: index,
} }
@ -239,7 +239,7 @@ func GetRunByIndex(ctx context.Context, repoID, index int64) (*BotRun, error) {
return run, nil return run, nil
} }
func UpdateRun(ctx context.Context, run *BotRun, cols ...string) error { func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error {
sess := db.GetEngine(ctx).ID(run.ID) sess := db.GetEngine(ctx).ID(run.ID)
if len(cols) > 0 { if len(cols) > 0 {
sess.Cols(cols...) sess.Cols(cols...)
@ -268,4 +268,4 @@ func UpdateRun(ctx context.Context, run *BotRun, cols ...string) error {
return err return err
} }
type BotRunIndex db.ResourceIndex type ActionRunIndex db.ResourceIndex

View File

@ -15,14 +15,14 @@ import (
"xorm.io/builder" "xorm.io/builder"
) )
// BotRunJob represents a job of a run // ActionRunJob represents a job of a run
type BotRunJob struct { type ActionRunJob struct {
ID int64 ID int64
RunID int64 `xorm:"index"` RunID int64 `xorm:"index"`
Run *BotRun `xorm:"-"` Run *ActionRun `xorm:"-"`
RepoID int64 `xorm:"index"` RepoID int64 `xorm:"index"`
OwnerID int64 `xorm:"index"` OwnerID int64 `xorm:"index"`
CommitSHA string `xorm:"index"` CommitSHA string `xorm:"index"`
IsForkPullRequest bool IsForkPullRequest bool
Name string Name string
Attempt int64 Attempt int64
@ -39,10 +39,10 @@ type BotRunJob struct {
} }
func init() { func init() {
db.RegisterModel(new(BotRunJob)) db.RegisterModel(new(ActionRunJob))
} }
func (job *BotRunJob) TakeTime() time.Duration { func (job *ActionRunJob) TakeTime() time.Duration {
if job.Started == 0 { if job.Started == 0 {
return 0 return 0
} }
@ -54,7 +54,7 @@ func (job *BotRunJob) TakeTime() time.Duration {
return time.Since(started).Truncate(time.Second) return time.Since(started).Truncate(time.Second)
} }
func (job *BotRunJob) LoadRun(ctx context.Context) error { func (job *ActionRunJob) LoadRun(ctx context.Context) error {
if job.Run == nil { if job.Run == nil {
run, err := GetRunByID(ctx, job.RunID) run, err := GetRunByID(ctx, job.RunID)
if err != nil { if err != nil {
@ -66,7 +66,7 @@ func (job *BotRunJob) LoadRun(ctx context.Context) error {
} }
// LoadAttributes load Run if not loaded // LoadAttributes load Run if not loaded
func (job *BotRunJob) LoadAttributes(ctx context.Context) error { func (job *ActionRunJob) LoadAttributes(ctx context.Context) error {
if job == nil { if job == nil {
return nil return nil
} }
@ -87,8 +87,8 @@ func (err ErrRunJobNotExist) Error() string {
return fmt.Sprintf("run job [%d] is not exist", err.ID) return fmt.Sprintf("run job [%d] is not exist", err.ID)
} }
func GetRunJobByID(ctx context.Context, id int64) (*BotRunJob, error) { func GetRunJobByID(ctx context.Context, id int64) (*ActionRunJob, error) {
var job BotRunJob var job ActionRunJob
has, err := db.GetEngine(ctx).Where("id=?", id).Get(&job) has, err := db.GetEngine(ctx).Where("id=?", id).Get(&job)
if err != nil { if err != nil {
return nil, err return nil, err
@ -101,15 +101,15 @@ func GetRunJobByID(ctx context.Context, id int64) (*BotRunJob, error) {
return &job, nil return &job, nil
} }
func GetRunJobsByRunID(ctx context.Context, runID int64) ([]*BotRunJob, error) { func GetRunJobsByRunID(ctx context.Context, runID int64) ([]*ActionRunJob, error) {
var jobs []*BotRunJob var jobs []*ActionRunJob
if err := db.GetEngine(ctx).Where("run_id=?", runID).OrderBy("id").Find(&jobs); err != nil { if err := db.GetEngine(ctx).Where("run_id=?", runID).OrderBy("id").Find(&jobs); err != nil {
return nil, err return nil, err
} }
return jobs, nil return jobs, nil
} }
func UpdateRunJob(ctx context.Context, job *BotRunJob, cond builder.Cond, cols ...string) (int64, error) { func UpdateRunJob(ctx context.Context, job *ActionRunJob, cond builder.Cond, cols ...string) (int64, error) {
e := db.GetEngine(ctx) e := db.GetEngine(ctx)
sess := e.ID(job.ID) sess := e.ID(job.ID)
@ -144,7 +144,7 @@ func UpdateRunJob(ctx context.Context, job *BotRunJob, cond builder.Cond, cols .
runStatus := aggregateJobStatus(jobs) runStatus := aggregateJobStatus(jobs)
run := &BotRun{ run := &ActionRun{
ID: job.RunID, ID: job.RunID,
Status: runStatus, Status: runStatus,
} }
@ -154,7 +154,7 @@ func UpdateRunJob(ctx context.Context, job *BotRunJob, cond builder.Cond, cols .
return affected, UpdateRun(ctx, run) return affected, UpdateRun(ctx, run)
} }
func aggregateJobStatus(jobs []*BotRunJob) Status { func aggregateJobStatus(jobs []*ActionRunJob) Status {
allDone := true allDone := true
allWaiting := true allWaiting := true
hasFailure := false hasFailure := false

View File

@ -12,9 +12,9 @@ import (
"xorm.io/builder" "xorm.io/builder"
) )
type RunJobList []*BotRunJob type ActionJobList []*ActionRunJob
func (jobs RunJobList) GetRunIDs() []int64 { func (jobs ActionJobList) GetRunIDs() []int64 {
runIDsMap := make(map[int64]struct{}) runIDsMap := make(map[int64]struct{})
for _, j := range jobs { for _, j := range jobs {
if j.RunID == 0 { if j.RunID == 0 {
@ -29,9 +29,9 @@ func (jobs RunJobList) GetRunIDs() []int64 {
return runIDs return runIDs
} }
func (jobs RunJobList) LoadRuns(ctx context.Context, withRepo bool) error { func (jobs ActionJobList) LoadRuns(ctx context.Context, withRepo bool) error {
runIDs := jobs.GetRunIDs() runIDs := jobs.GetRunIDs()
runs := make(map[int64]*BotRun, len(runIDs)) runs := make(map[int64]*ActionRun, len(runIDs))
if err := db.GetEngine(ctx).In("id", runIDs).Find(&runs); err != nil { if err := db.GetEngine(ctx).In("id", runIDs).Find(&runs); err != nil {
return err return err
} }
@ -41,7 +41,7 @@ func (jobs RunJobList) LoadRuns(ctx context.Context, withRepo bool) error {
} }
} }
if withRepo { if withRepo {
var runsList RunList = make([]*BotRun, 0, len(runs)) var runsList RunList = make([]*ActionRun, 0, len(runs))
for _, r := range runs { for _, r := range runs {
runsList = append(runsList, r) runsList = append(runsList, r)
} }
@ -50,7 +50,7 @@ func (jobs RunJobList) LoadRuns(ctx context.Context, withRepo bool) error {
return nil return nil
} }
func (jobs RunJobList) LoadAttributes(ctx context.Context, withRepo bool) error { func (jobs ActionJobList) LoadAttributes(ctx context.Context, withRepo bool) error {
return jobs.LoadRuns(ctx, withRepo) return jobs.LoadRuns(ctx, withRepo)
} }
@ -87,16 +87,16 @@ func (opts FindRunJobOptions) toConds() builder.Cond {
return cond return cond
} }
func FindRunJobs(ctx context.Context, opts FindRunJobOptions) (RunJobList, int64, error) { func FindRunJobs(ctx context.Context, opts FindRunJobOptions) (ActionJobList, int64, error) {
e := db.GetEngine(ctx).Where(opts.toConds()) e := db.GetEngine(ctx).Where(opts.toConds())
if opts.PageSize > 0 && opts.Page >= 1 { if opts.PageSize > 0 && opts.Page >= 1 {
e.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize) e.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize)
} }
var tasks RunJobList var tasks ActionJobList
total, err := e.FindAndCount(&tasks) total, err := e.FindAndCount(&tasks)
return tasks, total, err return tasks, total, err
} }
func CountRunJobs(ctx context.Context, opts FindRunJobOptions) (int64, error) { func CountRunJobs(ctx context.Context, opts FindRunJobOptions) (int64, error) {
return db.GetEngine(ctx).Where(opts.toConds()).Count(new(BotRunJob)) return db.GetEngine(ctx).Where(opts.toConds()).Count(new(ActionRunJob))
} }

View File

@ -14,7 +14,7 @@ import (
"xorm.io/builder" "xorm.io/builder"
) )
type RunList []*BotRun type RunList []*ActionRun
// GetUserIDs returns a slice of user's id // GetUserIDs returns a slice of user's id
func (runs RunList) GetUserIDs() []int64 { func (runs RunList) GetUserIDs() []int64 {
@ -110,5 +110,5 @@ func FindRuns(ctx context.Context, opts FindRunOptions) (RunList, int64, error)
} }
func CountRuns(ctx context.Context, opts FindRunOptions) (int64, error) { func CountRuns(ctx context.Context, opts FindRunOptions) (int64, error) {
return db.GetEngine(ctx).Where(opts.toConds()).Count(new(BotRun)) return db.GetEngine(ctx).Where(opts.toConds()).Count(new(ActionRun))
} }

View File

@ -33,8 +33,8 @@ func (err ErrRunnerNotExist) Error() string {
return fmt.Sprintf("Bot runner token [%s] is not exist", err.Token) return fmt.Sprintf("Bot runner token [%s] is not exist", err.Token)
} }
// BotRunner represents runner machines // ActionRunner represents runner machines
type BotRunner struct { type ActionRunner struct {
ID int64 ID int64
UUID string `xorm:"CHAR(36) UNIQUE"` UUID string `xorm:"CHAR(36) UNIQUE"`
Name string `xorm:"VARCHAR(32)"` Name string `xorm:"VARCHAR(32)"`
@ -64,7 +64,7 @@ type BotRunner struct {
Deleted timeutil.TimeStamp `xorm:"deleted"` Deleted timeutil.TimeStamp `xorm:"deleted"`
} }
func (r *BotRunner) OwnType() string { func (r *ActionRunner) OwnType() string {
if r.OwnerID == 0 { if r.OwnerID == 0 {
return "Global" return "Global"
} }
@ -75,7 +75,7 @@ func (r *BotRunner) OwnType() string {
return r.Repo.FullName() return r.Repo.FullName()
} }
func (r *BotRunner) Status() runnerv1.RunnerStatus { func (r *ActionRunner) Status() runnerv1.RunnerStatus {
if time.Since(r.LastOnline.AsTime()) > time.Minute { if time.Since(r.LastOnline.AsTime()) > time.Minute {
return runnerv1.RunnerStatus_RUNNER_STATUS_OFFLINE return runnerv1.RunnerStatus_RUNNER_STATUS_OFFLINE
} }
@ -85,11 +85,11 @@ func (r *BotRunner) Status() runnerv1.RunnerStatus {
return runnerv1.RunnerStatus_RUNNER_STATUS_ACTIVE return runnerv1.RunnerStatus_RUNNER_STATUS_ACTIVE
} }
func (r *BotRunner) StatusName() string { func (r *ActionRunner) StatusName() string {
return strings.ToLower(strings.TrimPrefix(r.Status().String(), "RUNNER_STATUS_")) return strings.ToLower(strings.TrimPrefix(r.Status().String(), "RUNNER_STATUS_"))
} }
func (r *BotRunner) IsOnline() bool { func (r *ActionRunner) IsOnline() bool {
status := r.Status() status := r.Status()
if status == runnerv1.RunnerStatus_RUNNER_STATUS_IDLE || status == runnerv1.RunnerStatus_RUNNER_STATUS_ACTIVE { if status == runnerv1.RunnerStatus_RUNNER_STATUS_IDLE || status == runnerv1.RunnerStatus_RUNNER_STATUS_ACTIVE {
return true return true
@ -98,12 +98,12 @@ func (r *BotRunner) IsOnline() bool {
} }
// AllLabels returns agent and custom labels // AllLabels returns agent and custom labels
func (r *BotRunner) AllLabels() []string { func (r *ActionRunner) AllLabels() []string {
return append(r.AgentLabels, r.CustomLabels...) return append(r.AgentLabels, r.CustomLabels...)
} }
// Editable checks if the runner is editable by the user // Editable checks if the runner is editable by the user
func (r *BotRunner) Editable(ownerID, repoID int64) bool { func (r *ActionRunner) Editable(ownerID, repoID int64) bool {
if ownerID == 0 && repoID == 0 { if ownerID == 0 && repoID == 0 {
return true return true
} }
@ -114,7 +114,7 @@ func (r *BotRunner) Editable(ownerID, repoID int64) bool {
} }
// LoadAttributes loads the attributes of the runner // LoadAttributes loads the attributes of the runner
func (r *BotRunner) LoadAttributes(ctx context.Context) error { func (r *ActionRunner) LoadAttributes(ctx context.Context) error {
if r.OwnerID > 0 { if r.OwnerID > 0 {
var user user_model.User var user user_model.User
has, err := db.GetEngine(ctx).ID(r.OwnerID).Get(&user) has, err := db.GetEngine(ctx).ID(r.OwnerID).Get(&user)
@ -138,13 +138,13 @@ func (r *BotRunner) LoadAttributes(ctx context.Context) error {
return nil return nil
} }
func (r *BotRunner) GenerateToken() (err error) { func (r *ActionRunner) GenerateToken() (err error) {
r.Token, r.TokenSalt, r.TokenHash, _, err = generateSaltedToken() r.Token, r.TokenSalt, r.TokenHash, _, err = generateSaltedToken()
return err return err
} }
func init() { func init() {
db.RegisterModel(&BotRunner{}) db.RegisterModel(&ActionRunner{})
} }
type FindRunnerOptions struct { type FindRunnerOptions struct {
@ -195,7 +195,7 @@ func (opts FindRunnerOptions) toOrder() string {
func CountRunners(opts FindRunnerOptions) (int64, error) { func CountRunners(opts FindRunnerOptions) (int64, error) {
return db.GetEngine(db.DefaultContext). return db.GetEngine(db.DefaultContext).
Table(BotRunner{}). Table(ActionRunner{}).
Where(opts.toCond()). Where(opts.toCond()).
OrderBy(opts.toOrder()). OrderBy(opts.toOrder()).
Count() Count()
@ -212,8 +212,8 @@ func FindRunners(opts FindRunnerOptions) (runners RunnerList, err error) {
} }
// GetUsableRunner returns the usable runner // GetUsableRunner returns the usable runner
func GetUsableRunner(opts FindRunnerOptions) (*BotRunner, error) { func GetUsableRunner(opts FindRunnerOptions) (*ActionRunner, error) {
var runner BotRunner var runner ActionRunner
has, err := db.GetEngine(db.DefaultContext). has, err := db.GetEngine(db.DefaultContext).
Where(opts.toCond()). Where(opts.toCond()).
Asc("last_online"). Asc("last_online").
@ -229,8 +229,8 @@ func GetUsableRunner(opts FindRunnerOptions) (*BotRunner, error) {
} }
// GetRunnerByUUID returns a bot runner via uuid // GetRunnerByUUID returns a bot runner via uuid
func GetRunnerByUUID(uuid string) (*BotRunner, error) { func GetRunnerByUUID(uuid string) (*ActionRunner, error) {
var runner BotRunner var runner ActionRunner
has, err := db.GetEngine(db.DefaultContext).Where("uuid=?", uuid).Get(&runner) has, err := db.GetEngine(db.DefaultContext).Where("uuid=?", uuid).Get(&runner)
if err != nil { if err != nil {
return nil, err return nil, err
@ -243,8 +243,8 @@ func GetRunnerByUUID(uuid string) (*BotRunner, error) {
} }
// GetRunnerByID returns a bot runner via id // GetRunnerByID returns a bot runner via id
func GetRunnerByID(id int64) (*BotRunner, error) { func GetRunnerByID(id int64) (*ActionRunner, error) {
var runner BotRunner var runner ActionRunner
has, err := db.GetEngine(db.DefaultContext).Where("id=?", id).Get(&runner) has, err := db.GetEngine(db.DefaultContext).Where("id=?", id).Get(&runner)
if err != nil { if err != nil {
return nil, err return nil, err
@ -257,7 +257,7 @@ func GetRunnerByID(id int64) (*BotRunner, error) {
} }
// UpdateRunner updates runner's information. // UpdateRunner updates runner's information.
func UpdateRunner(ctx context.Context, r *BotRunner, cols ...string) error { func UpdateRunner(ctx context.Context, r *ActionRunner, cols ...string) error {
e := db.GetEngine(ctx) e := db.GetEngine(ctx)
var err error var err error
if len(cols) == 0 { if len(cols) == 0 {
@ -269,15 +269,15 @@ func UpdateRunner(ctx context.Context, r *BotRunner, cols ...string) error {
} }
// DeleteRunner deletes a runner by given ID. // DeleteRunner deletes a runner by given ID.
func DeleteRunner(ctx context.Context, r *BotRunner) error { func DeleteRunner(ctx context.Context, r *ActionRunner) error {
e := db.GetEngine(ctx) e := db.GetEngine(ctx)
_, err := e.Delete(r) _, err := e.Delete(r)
return err return err
} }
// FindRunnersByRepoID returns all workers for the repository // FindRunnersByRepoID returns all workers for the repository
func FindRunnersByRepoID(repoID int64) ([]*BotRunner, error) { func FindRunnersByRepoID(repoID int64) ([]*ActionRunner, error) {
var runners []*BotRunner var runners []*ActionRunner
err := db.GetEngine(db.DefaultContext).Where("repo_id=? OR repo_id=0", repoID). err := db.GetEngine(db.DefaultContext).Where("repo_id=? OR repo_id=0", repoID).
Find(&runners) Find(&runners)
if err != nil { if err != nil {
@ -288,7 +288,7 @@ func FindRunnersByRepoID(repoID int64) ([]*BotRunner, error) {
} }
// NewRunner creates new runner. // NewRunner creates new runner.
func NewRunner(ctx context.Context, t *BotRunner) error { func NewRunner(ctx context.Context, t *ActionRunner) error {
_, err := db.GetEngine(ctx).Insert(t) _, err := db.GetEngine(ctx).Insert(t)
return err return err
} }

View File

@ -12,7 +12,7 @@ import (
"code.gitea.io/gitea/modules/container" "code.gitea.io/gitea/modules/container"
) )
type RunnerList []*BotRunner type RunnerList []*ActionRunner
// GetUserIDs returns a slice of user's id // GetUserIDs returns a slice of user's id
func (runners RunnerList) GetUserIDs() []int64 { func (runners RunnerList) GetUserIDs() []int64 {

View File

@ -23,8 +23,8 @@ func (err ErrRunnerTokenNotExist) Error() string {
return fmt.Sprintf("runner token [%s] is not exist", err.Token) return fmt.Sprintf("runner token [%s] is not exist", err.Token)
} }
// BotRunnerToken represents runner tokens // ActionRunnerToken represents runner tokens
type BotRunnerToken struct { type ActionRunnerToken struct {
ID int64 ID int64
Token string `xorm:"UNIQUE"` Token string `xorm:"UNIQUE"`
OwnerID int64 `xorm:"index"` // org level runner, 0 means system OwnerID int64 `xorm:"index"` // org level runner, 0 means system
@ -39,12 +39,12 @@ type BotRunnerToken struct {
} }
func init() { func init() {
db.RegisterModel(new(BotRunnerToken)) db.RegisterModel(new(ActionRunnerToken))
} }
// GetRunnerToken returns a bot runner via token // GetRunnerToken returns a bot runner via token
func GetRunnerToken(token string) (*BotRunnerToken, error) { func GetRunnerToken(token string) (*ActionRunnerToken, error) {
var runnerToken BotRunnerToken var runnerToken ActionRunnerToken
has, err := db.GetEngine(db.DefaultContext).Where("token=?", token).Get(&runnerToken) has, err := db.GetEngine(db.DefaultContext).Where("token=?", token).Get(&runnerToken)
if err != nil { if err != nil {
return nil, err return nil, err
@ -57,7 +57,7 @@ func GetRunnerToken(token string) (*BotRunnerToken, error) {
} }
// UpdateRunnerToken updates runner token information. // UpdateRunnerToken updates runner token information.
func UpdateRunnerToken(ctx context.Context, r *BotRunnerToken, cols ...string) (err error) { func UpdateRunnerToken(ctx context.Context, r *ActionRunnerToken, cols ...string) (err error) {
e := db.GetEngine(ctx) e := db.GetEngine(ctx)
if len(cols) == 0 { if len(cols) == 0 {
@ -69,12 +69,12 @@ func UpdateRunnerToken(ctx context.Context, r *BotRunnerToken, cols ...string) (
} }
// NewRunnerToken creates a new runner token // NewRunnerToken creates a new runner token
func NewRunnerToken(ownerID, repoID int64) (*BotRunnerToken, error) { func NewRunnerToken(ownerID, repoID int64) (*ActionRunnerToken, error) {
token, err := util.CryptoRandomString(40) token, err := util.CryptoRandomString(40)
if err != nil { if err != nil {
return nil, err return nil, err
} }
runnerToken := &BotRunnerToken{ runnerToken := &ActionRunnerToken{
OwnerID: ownerID, OwnerID: ownerID,
RepoID: repoID, RepoID: repoID,
IsActive: false, IsActive: false,
@ -85,8 +85,8 @@ func NewRunnerToken(ownerID, repoID int64) (*BotRunnerToken, error) {
} }
// GetUnactivatedRunnerToken returns a unactivated runner token // GetUnactivatedRunnerToken returns a unactivated runner token
func GetUnactivatedRunnerToken(ownerID, repoID int64) (*BotRunnerToken, error) { func GetUnactivatedRunnerToken(ownerID, repoID int64) (*ActionRunnerToken, error) {
var runnerToken BotRunnerToken var runnerToken ActionRunnerToken
has, err := db.GetEngine(db.DefaultContext).Where("owner_id=? AND repo_id=? AND is_active=?", ownerID, repoID, false).OrderBy("id DESC").Get(&runnerToken) has, err := db.GetEngine(db.DefaultContext).Where("owner_id=? AND repo_id=? AND is_active=?", ownerID, repoID, false).OrderBy("id DESC").Get(&runnerToken)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -5,7 +5,7 @@ package actions
import runnerv1 "code.gitea.io/actions-proto-go/runner/v1" import runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
// Status represents the status of BotRun, BotRunJob, BotTask, or BotTaskStep // Status represents the status of ActionRun, ActionRunJob, ActionTask, or ActionTaskStep
type Status int type Status int
const ( const (

View File

@ -28,12 +28,12 @@ import (
"xorm.io/builder" "xorm.io/builder"
) )
// BotTask represents a distribution of job // ActionTask represents a distribution of job
type BotTask struct { type ActionTask struct {
ID int64 ID int64
JobID int64 JobID int64
Job *BotRunJob `xorm:"-"` Job *ActionRunJob `xorm:"-"`
Steps []*BotTaskStep `xorm:"-"` Steps []*ActionTaskStep `xorm:"-"`
Attempt int64 Attempt int64
RunnerID int64 `xorm:"index"` RunnerID int64 `xorm:"index"`
Status Status `xorm:"index"` Status Status `xorm:"index"`
@ -64,7 +64,7 @@ type BotTask struct {
var successfulTokenTaskCache *lru.Cache var successfulTokenTaskCache *lru.Cache
func init() { func init() {
db.RegisterModel(new(BotTask), func() error { db.RegisterModel(new(ActionTask), func() error {
if setting.SuccessfulTokensCacheSize > 0 { if setting.SuccessfulTokensCacheSize > 0 {
var err error var err error
successfulTokenTaskCache, err = lru.New(setting.SuccessfulTokensCacheSize) successfulTokenTaskCache, err = lru.New(setting.SuccessfulTokensCacheSize)
@ -78,7 +78,7 @@ func init() {
}) })
} }
func (task *BotTask) TakeTime() time.Duration { func (task *ActionTask) TakeTime() time.Duration {
if task.Started == 0 { if task.Started == 0 {
return 0 return 0
} }
@ -90,15 +90,15 @@ func (task *BotTask) TakeTime() time.Duration {
return time.Since(started).Truncate(time.Second) return time.Since(started).Truncate(time.Second)
} }
func (task *BotTask) IsStopped() bool { func (task *ActionTask) IsStopped() bool {
return task.Stopped > 0 return task.Stopped > 0
} }
func (task *BotTask) GetRepo() string { func (task *ActionTask) GetRepo() string {
return "xxxx" return "xxxx"
} }
func (task *BotTask) GetCommitSHA() string { func (task *ActionTask) GetCommitSHA() string {
if task.Job == nil { if task.Job == nil {
return "" return ""
} }
@ -109,7 +109,7 @@ func (task *BotTask) GetCommitSHA() string {
return task.Job.Run.CommitSHA return task.Job.Run.CommitSHA
} }
func (task *BotTask) GetCommitSHAShort() string { func (task *ActionTask) GetCommitSHAShort() string {
commitSHA := task.GetCommitSHA() commitSHA := task.GetCommitSHA()
if len(commitSHA) > 8 { if len(commitSHA) > 8 {
return commitSHA[:8] return commitSHA[:8]
@ -117,14 +117,14 @@ func (task *BotTask) GetCommitSHAShort() string {
return commitSHA return commitSHA
} }
func (task *BotTask) GetBuildViewLink() string { func (task *ActionTask) GetBuildViewLink() string {
if task.Job == nil || task.Job.Run == nil || task.Job.Run.Repo == nil { if task.Job == nil || task.Job.Run == nil || task.Job.Run.Repo == nil {
return "" return ""
} }
return task.Job.Run.Repo.Link() + "/bots/runs/" + strconv.FormatInt(task.ID, 10) return task.Job.Run.Repo.Link() + "/bots/runs/" + strconv.FormatInt(task.ID, 10)
} }
func (task *BotTask) GetCommitLink() string { func (task *ActionTask) GetCommitLink() string {
if task.Job == nil || task.Job.Run == nil || task.Job.Run.Repo == nil { if task.Job == nil || task.Job.Run == nil || task.Job.Run.Repo == nil {
return "" return ""
} }
@ -134,21 +134,21 @@ func (task *BotTask) GetCommitLink() string {
return "" return ""
} }
func (task *BotTask) GetRepoName() string { func (task *ActionTask) GetRepoName() string {
if task.Job == nil || task.Job.Run == nil || task.Job.Run.Repo == nil { if task.Job == nil || task.Job.Run == nil || task.Job.Run.Repo == nil {
return "" return ""
} }
return task.Job.Run.Repo.FullName() return task.Job.Run.Repo.FullName()
} }
func (task *BotTask) GetRepoLink() string { func (task *ActionTask) GetRepoLink() string {
if task.Job == nil || task.Job.Run == nil || task.Job.Run.Repo == nil { if task.Job == nil || task.Job.Run == nil || task.Job.Run.Repo == nil {
return "" return ""
} }
return task.Job.Run.Repo.Link() return task.Job.Run.Repo.Link()
} }
func (task *BotTask) LoadJob(ctx context.Context) error { func (task *ActionTask) LoadJob(ctx context.Context) error {
if task.Job == nil { if task.Job == nil {
job, err := GetRunJobByID(ctx, task.JobID) job, err := GetRunJobByID(ctx, task.JobID)
if err != nil { if err != nil {
@ -160,7 +160,7 @@ func (task *BotTask) LoadJob(ctx context.Context) error {
} }
// LoadAttributes load Job Steps if not loaded // LoadAttributes load Job Steps if not loaded
func (task *BotTask) LoadAttributes(ctx context.Context) error { func (task *ActionTask) LoadAttributes(ctx context.Context) error {
if task == nil { if task == nil {
return nil return nil
} }
@ -183,7 +183,7 @@ func (task *BotTask) LoadAttributes(ctx context.Context) error {
return nil return nil
} }
func (task *BotTask) GenerateToken() (err error) { func (task *ActionTask) GenerateToken() (err error) {
task.Token, task.TokenSalt, task.TokenHash, task.TokenLastEight, err = generateSaltedToken() task.Token, task.TokenSalt, task.TokenHash, task.TokenLastEight, err = generateSaltedToken()
return err return err
} }
@ -213,8 +213,8 @@ func (indexes *LogIndexes) ToDB() ([]byte, error) {
return buf[:i], nil return buf[:i], nil
} }
func GetTaskByID(ctx context.Context, id int64) (*BotTask, error) { func GetTaskByID(ctx context.Context, id int64) (*ActionTask, error) {
var task BotTask var task ActionTask
has, err := db.GetEngine(ctx).Where("id=?", id).Get(&task) has, err := db.GetEngine(ctx).Where("id=?", id).Get(&task)
if err != nil { if err != nil {
return nil, err return nil, err
@ -225,7 +225,7 @@ func GetTaskByID(ctx context.Context, id int64) (*BotTask, error) {
return &task, nil return &task, nil
} }
func GetRunningTaskByToken(ctx context.Context, token string) (*BotTask, error) { func GetRunningTaskByToken(ctx context.Context, token string) (*ActionTask, error) {
errNotExist := fmt.Errorf("task with token %q: %w", token, util.ErrNotExist) errNotExist := fmt.Errorf("task with token %q: %w", token, util.ErrNotExist)
if token == "" { if token == "" {
return nil, errNotExist return nil, errNotExist
@ -243,7 +243,7 @@ func GetRunningTaskByToken(ctx context.Context, token string) (*BotTask, error)
lastEight := token[len(token)-8:] lastEight := token[len(token)-8:]
if id := getTaskIDFromCache(token); id > 0 { if id := getTaskIDFromCache(token); id > 0 {
task := &BotTask{ task := &ActionTask{
TokenLastEight: lastEight, TokenLastEight: lastEight,
} }
// Re-get the task from the db in case it has been deleted in the intervening period // Re-get the task from the db in case it has been deleted in the intervening period
@ -257,7 +257,7 @@ func GetRunningTaskByToken(ctx context.Context, token string) (*BotTask, error)
successfulTokenTaskCache.Remove(token) successfulTokenTaskCache.Remove(token)
} }
var tasks []*BotTask var tasks []*ActionTask
err := db.GetEngine(ctx).Where("token_last_eight = ? AND status = ?", lastEight, StatusRunning).Find(&tasks) err := db.GetEngine(ctx).Where("token_last_eight = ? AND status = ?", lastEight, StatusRunning).Find(&tasks)
if err != nil { if err != nil {
return nil, err return nil, err
@ -277,7 +277,7 @@ func GetRunningTaskByToken(ctx context.Context, token string) (*BotTask, error)
return nil, errNotExist return nil, errNotExist
} }
func CreateTaskForRunner(ctx context.Context, runner *BotRunner) (*BotTask, bool, error) { func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask, bool, error) {
dbCtx, commiter, err := db.TxContext(ctx) dbCtx, commiter, err := db.TxContext(ctx)
if err != nil { if err != nil {
return nil, false, err return nil, false, err
@ -297,13 +297,13 @@ func CreateTaskForRunner(ctx context.Context, runner *BotRunner) (*BotTask, bool
jobCond = builder.In("run_id", builder.Select("id").From("bot_run").Where(jobCond)) jobCond = builder.In("run_id", builder.Select("id").From("bot_run").Where(jobCond))
} }
var jobs []*BotRunJob var jobs []*ActionRunJob
if err := e.Where("task_id=? AND status=?", 0, StatusWaiting).And(jobCond).Asc("id").Find(&jobs); err != nil { if err := e.Where("task_id=? AND status=?", 0, StatusWaiting).And(jobCond).Asc("id").Find(&jobs); err != nil {
return nil, false, err return nil, false, err
} }
// TODO: a more efficient way to filter labels // TODO: a more efficient way to filter labels
var job *BotRunJob var job *ActionRunJob
labels := runner.AgentLabels labels := runner.AgentLabels
labels = append(labels, runner.CustomLabels...) labels = append(labels, runner.CustomLabels...)
log.Trace("runner labels: %v", labels) log.Trace("runner labels: %v", labels)
@ -325,7 +325,7 @@ func CreateTaskForRunner(ctx context.Context, runner *BotRunner) (*BotTask, bool
job.Started = now job.Started = now
job.Status = StatusRunning job.Status = StatusRunning
task := &BotTask{ task := &ActionTask{
JobID: job.ID, JobID: job.ID,
Attempt: job.Attempt, Attempt: job.Attempt,
RunnerID: runner.ID, RunnerID: runner.ID,
@ -358,9 +358,9 @@ func CreateTaskForRunner(ctx context.Context, runner *BotRunner) (*BotTask, bool
return nil, false, err return nil, false, err
} }
steps := make([]*BotTaskStep, len(workflowJob.Steps)) steps := make([]*ActionTaskStep, len(workflowJob.Steps))
for i, v := range workflowJob.Steps { for i, v := range workflowJob.Steps {
steps[i] = &BotTaskStep{ steps[i] = &ActionTaskStep{
Name: v.String(), Name: v.String(),
TaskID: task.ID, TaskID: task.ID,
Number: int64(i), Number: int64(i),
@ -397,7 +397,7 @@ func CreateTaskForRunner(ctx context.Context, runner *BotRunner) (*BotTask, bool
return task, true, nil return task, true, nil
} }
func UpdateTask(ctx context.Context, task *BotTask, cols ...string) error { func UpdateTask(ctx context.Context, task *ActionTask, cols ...string) error {
sess := db.GetEngine(ctx).ID(task.ID) sess := db.GetEngine(ctx).ID(task.ID)
if len(cols) > 0 { if len(cols) > 0 {
sess.Cols(cols...) sess.Cols(cols...)
@ -406,7 +406,7 @@ func UpdateTask(ctx context.Context, task *BotTask, cols ...string) error {
return err return err
} }
func UpdateTaskByState(state *runnerv1.TaskState) (*BotTask, error) { func UpdateTaskByState(state *runnerv1.TaskState) (*ActionTask, error) {
stepStates := map[int64]*runnerv1.StepState{} stepStates := map[int64]*runnerv1.StepState{}
for _, v := range state.Steps { for _, v := range state.Steps {
stepStates[v.Id] = v stepStates[v.Id] = v
@ -420,7 +420,7 @@ func UpdateTaskByState(state *runnerv1.TaskState) (*BotTask, error) {
e := db.GetEngine(ctx) e := db.GetEngine(ctx)
task := &BotTask{} task := &ActionTask{}
if has, err := e.ID(state.Id).Get(task); err != nil { if has, err := e.ID(state.Id).Get(task); err != nil {
return nil, err return nil, err
} else if !has { } else if !has {
@ -430,7 +430,7 @@ func UpdateTaskByState(state *runnerv1.TaskState) (*BotTask, error) {
if state.Result != runnerv1.Result_RESULT_UNSPECIFIED { if state.Result != runnerv1.Result_RESULT_UNSPECIFIED {
task.Status = Status(state.Result) task.Status = Status(state.Result)
task.Stopped = timeutil.TimeStamp(state.StoppedAt.AsTime().Unix()) task.Stopped = timeutil.TimeStamp(state.StoppedAt.AsTime().Unix())
if _, err := UpdateRunJob(ctx, &BotRunJob{ if _, err := UpdateRunJob(ctx, &ActionRunJob{
ID: task.JobID, ID: task.JobID,
Status: task.Status, Status: task.Status,
Stopped: task.Stopped, Stopped: task.Stopped,
@ -482,7 +482,7 @@ func StopTask(ctx context.Context, taskID int64, status Status) error {
} }
e := db.GetEngine(ctx) e := db.GetEngine(ctx)
task := &BotTask{} task := &ActionTask{}
if has, err := e.ID(taskID).Get(task); err != nil { if has, err := e.ID(taskID).Get(task); err != nil {
return err return err
} else if !has { } else if !has {
@ -495,7 +495,7 @@ func StopTask(ctx context.Context, taskID int64, status Status) error {
now := timeutil.TimeStampNow() now := timeutil.TimeStampNow()
task.Status = status task.Status = status
task.Stopped = now task.Stopped = now
if _, err := UpdateRunJob(ctx, &BotRunJob{ if _, err := UpdateRunJob(ctx, &ActionRunJob{
ID: task.JobID, ID: task.JobID,
Status: task.Status, Status: task.Status,
Stopped: task.Stopped, Stopped: task.Stopped,

View File

@ -12,7 +12,7 @@ import (
"xorm.io/builder" "xorm.io/builder"
) )
type TaskList []*BotTask type TaskList []*ActionTask
func (tasks TaskList) GetJobIDs() []int64 { func (tasks TaskList) GetJobIDs() []int64 {
jobIDsMap := make(map[int64]struct{}) jobIDsMap := make(map[int64]struct{})
@ -31,7 +31,7 @@ func (tasks TaskList) GetJobIDs() []int64 {
func (tasks TaskList) LoadJobs(ctx context.Context) error { func (tasks TaskList) LoadJobs(ctx context.Context) error {
jobIDs := tasks.GetJobIDs() jobIDs := tasks.GetJobIDs()
jobs := make(map[int64]*BotRunJob, len(jobIDs)) jobs := make(map[int64]*ActionRunJob, len(jobIDs))
if err := db.GetEngine(ctx).In("id", jobIDs).Find(&jobs); err != nil { if err := db.GetEngine(ctx).In("id", jobIDs).Find(&jobs); err != nil {
return err return err
} }
@ -41,7 +41,7 @@ func (tasks TaskList) LoadJobs(ctx context.Context) error {
} }
} }
var jobsList RunJobList = make([]*BotRunJob, 0, len(jobs)) var jobsList ActionJobList = make([]*ActionRunJob, 0, len(jobs))
for _, j := range jobs { for _, j := range jobs {
jobsList = append(jobsList, j) jobsList = append(jobsList, j)
} }
@ -104,5 +104,5 @@ func FindTasks(ctx context.Context, opts FindTaskOptions) (TaskList, int64, erro
} }
func CountTasks(ctx context.Context, opts FindTaskOptions) (int64, error) { func CountTasks(ctx context.Context, opts FindTaskOptions) (int64, error) {
return db.GetEngine(ctx).Where(opts.toConds()).Count(new(BotTask)) return db.GetEngine(ctx).Where(opts.toConds()).Count(new(ActionTask))
} }

View File

@ -11,8 +11,8 @@ import (
"code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/timeutil"
) )
// BotTaskStep represents a step of BotTask // ActionTaskStep represents a step of ActionTask
type BotTaskStep struct { type ActionTaskStep struct {
ID int64 ID int64
Name string Name string
TaskID int64 `xorm:"index unique(task_number)"` TaskID int64 `xorm:"index unique(task_number)"`
@ -27,7 +27,7 @@ type BotTaskStep struct {
Updated timeutil.TimeStamp `xorm:"updated"` Updated timeutil.TimeStamp `xorm:"updated"`
} }
func (step *BotTaskStep) TakeTime() time.Duration { func (step *ActionTaskStep) TakeTime() time.Duration {
if step.Started == 0 { if step.Started == 0 {
return 0 return 0
} }
@ -40,10 +40,10 @@ func (step *BotTaskStep) TakeTime() time.Duration {
} }
func init() { func init() {
db.RegisterModel(new(BotTaskStep)) db.RegisterModel(new(ActionTaskStep))
} }
func GetTaskStepsByTaskID(ctx context.Context, taskID int64) ([]*BotTaskStep, error) { func GetTaskStepsByTaskID(ctx context.Context, taskID int64) ([]*ActionTaskStep, error) {
var steps []*BotTaskStep var steps []*ActionTaskStep
return steps, db.GetEngine(ctx).Where("task_id=?", taskID).OrderBy("number").Find(&steps) return steps, db.GetEngine(ctx).Where("task_id=?", taskID).OrderBy("number").Find(&steps)
} }

View File

@ -13,7 +13,7 @@ const (
) )
// FullSteps returns steps with "Set up job" and "Complete job" // FullSteps returns steps with "Set up job" and "Complete job"
func FullSteps(task *actions_model.BotTask) []*actions_model.BotTaskStep { func FullSteps(task *actions_model.ActionTask) []*actions_model.ActionTaskStep {
if len(task.Steps) == 0 { if len(task.Steps) == 0 {
return fullStepsOfEmptySteps(task) return fullStepsOfEmptySteps(task)
} }
@ -21,7 +21,7 @@ func FullSteps(task *actions_model.BotTask) []*actions_model.BotTaskStep {
firstStep := task.Steps[0] firstStep := task.Steps[0]
var logIndex int64 var logIndex int64
preStep := &actions_model.BotTaskStep{ preStep := &actions_model.ActionTaskStep{
Name: preStepName, Name: preStepName,
LogLength: task.LogLength, LogLength: task.LogLength,
Started: task.Started, Started: task.Started,
@ -38,7 +38,7 @@ func FullSteps(task *actions_model.BotTask) []*actions_model.BotTaskStep {
} }
logIndex += preStep.LogLength logIndex += preStep.LogLength
var lastHasRunStep *actions_model.BotTaskStep var lastHasRunStep *actions_model.ActionTaskStep
for _, step := range task.Steps { for _, step := range task.Steps {
if step.Status.HasRun() { if step.Status.HasRun() {
lastHasRunStep = step lastHasRunStep = step
@ -49,7 +49,7 @@ func FullSteps(task *actions_model.BotTask) []*actions_model.BotTaskStep {
lastHasRunStep = preStep lastHasRunStep = preStep
} }
postStep := &actions_model.BotTaskStep{ postStep := &actions_model.ActionTaskStep{
Name: postStepName, Name: postStepName,
Status: actions_model.StatusWaiting, Status: actions_model.StatusWaiting,
} }
@ -60,7 +60,7 @@ func FullSteps(task *actions_model.BotTask) []*actions_model.BotTaskStep {
postStep.Started = lastHasRunStep.Stopped postStep.Started = lastHasRunStep.Stopped
postStep.Stopped = task.Stopped postStep.Stopped = task.Stopped
} }
ret := make([]*actions_model.BotTaskStep, 0, len(task.Steps)+2) ret := make([]*actions_model.ActionTaskStep, 0, len(task.Steps)+2)
ret = append(ret, preStep) ret = append(ret, preStep)
ret = append(ret, task.Steps...) ret = append(ret, task.Steps...)
ret = append(ret, postStep) ret = append(ret, postStep)
@ -68,8 +68,8 @@ func FullSteps(task *actions_model.BotTask) []*actions_model.BotTaskStep {
return ret return ret
} }
func fullStepsOfEmptySteps(task *actions_model.BotTask) []*actions_model.BotTaskStep { func fullStepsOfEmptySteps(task *actions_model.ActionTask) []*actions_model.ActionTaskStep {
preStep := &actions_model.BotTaskStep{ preStep := &actions_model.ActionTaskStep{
Name: preStepName, Name: preStepName,
LogLength: task.LogLength, LogLength: task.LogLength,
Started: task.Started, Started: task.Started,
@ -77,7 +77,7 @@ func fullStepsOfEmptySteps(task *actions_model.BotTask) []*actions_model.BotTask
Status: actions_model.StatusRunning, Status: actions_model.StatusRunning,
} }
postStep := &actions_model.BotTaskStep{ postStep := &actions_model.ActionTaskStep{
Name: postStepName, Name: postStepName,
LogIndex: task.LogLength, LogIndex: task.LogLength,
Started: task.Stopped, Started: task.Stopped,
@ -94,7 +94,7 @@ func fullStepsOfEmptySteps(task *actions_model.BotTask) []*actions_model.BotTask
} }
} }
return []*actions_model.BotTaskStep{ return []*actions_model.ActionTaskStep{
preStep, preStep,
postStep, postStep,
} }

View File

@ -14,13 +14,13 @@ import (
func TestFullSteps(t *testing.T) { func TestFullSteps(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
task *actions_model.BotTask task *actions_model.ActionTask
want []*actions_model.BotTaskStep want []*actions_model.ActionTaskStep
}{ }{
{ {
name: "regular", name: "regular",
task: &actions_model.BotTask{ task: &actions_model.ActionTask{
Steps: []*actions_model.BotTaskStep{ Steps: []*actions_model.ActionTaskStep{
{Status: actions_model.StatusSuccess, LogIndex: 10, LogLength: 80, Started: 10010, Stopped: 10090}, {Status: actions_model.StatusSuccess, LogIndex: 10, LogLength: 80, Started: 10010, Stopped: 10090},
}, },
Status: actions_model.StatusSuccess, Status: actions_model.StatusSuccess,
@ -28,7 +28,7 @@ func TestFullSteps(t *testing.T) {
Stopped: 10100, Stopped: 10100,
LogLength: 100, LogLength: 100,
}, },
want: []*actions_model.BotTaskStep{ want: []*actions_model.ActionTaskStep{
{Name: preStepName, Status: actions_model.StatusSuccess, LogIndex: 0, LogLength: 10, Started: 10000, Stopped: 10010}, {Name: preStepName, Status: actions_model.StatusSuccess, LogIndex: 0, LogLength: 10, Started: 10000, Stopped: 10010},
{Status: actions_model.StatusSuccess, LogIndex: 10, LogLength: 80, Started: 10010, Stopped: 10090}, {Status: actions_model.StatusSuccess, LogIndex: 10, LogLength: 80, Started: 10010, Stopped: 10090},
{Name: postStepName, Status: actions_model.StatusSuccess, LogIndex: 90, LogLength: 10, Started: 10090, Stopped: 10100}, {Name: postStepName, Status: actions_model.StatusSuccess, LogIndex: 90, LogLength: 10, Started: 10090, Stopped: 10100},
@ -36,8 +36,8 @@ func TestFullSteps(t *testing.T) {
}, },
{ {
name: "failed step", name: "failed step",
task: &actions_model.BotTask{ task: &actions_model.ActionTask{
Steps: []*actions_model.BotTaskStep{ Steps: []*actions_model.ActionTaskStep{
{Status: actions_model.StatusSuccess, LogIndex: 10, LogLength: 20, Started: 10010, Stopped: 10020}, {Status: actions_model.StatusSuccess, LogIndex: 10, LogLength: 20, Started: 10010, Stopped: 10020},
{Status: actions_model.StatusFailure, LogIndex: 30, LogLength: 60, Started: 10020, Stopped: 10090}, {Status: actions_model.StatusFailure, LogIndex: 30, LogLength: 60, Started: 10020, Stopped: 10090},
{Status: actions_model.StatusCancelled, LogIndex: 0, LogLength: 0, Started: 0, Stopped: 0}, {Status: actions_model.StatusCancelled, LogIndex: 0, LogLength: 0, Started: 0, Stopped: 0},
@ -47,7 +47,7 @@ func TestFullSteps(t *testing.T) {
Stopped: 10100, Stopped: 10100,
LogLength: 100, LogLength: 100,
}, },
want: []*actions_model.BotTaskStep{ want: []*actions_model.ActionTaskStep{
{Name: preStepName, Status: actions_model.StatusSuccess, LogIndex: 0, LogLength: 10, Started: 10000, Stopped: 10010}, {Name: preStepName, Status: actions_model.StatusSuccess, LogIndex: 0, LogLength: 10, Started: 10000, Stopped: 10010},
{Status: actions_model.StatusSuccess, LogIndex: 10, LogLength: 20, Started: 10010, Stopped: 10020}, {Status: actions_model.StatusSuccess, LogIndex: 10, LogLength: 20, Started: 10010, Stopped: 10020},
{Status: actions_model.StatusFailure, LogIndex: 30, LogLength: 60, Started: 10020, Stopped: 10090}, {Status: actions_model.StatusFailure, LogIndex: 30, LogLength: 60, Started: 10020, Stopped: 10090},
@ -57,8 +57,8 @@ func TestFullSteps(t *testing.T) {
}, },
{ {
name: "first step is running", name: "first step is running",
task: &actions_model.BotTask{ task: &actions_model.ActionTask{
Steps: []*actions_model.BotTaskStep{ Steps: []*actions_model.ActionTaskStep{
{Status: actions_model.StatusRunning, LogIndex: 10, LogLength: 80, Started: 10010, Stopped: 0}, {Status: actions_model.StatusRunning, LogIndex: 10, LogLength: 80, Started: 10010, Stopped: 0},
}, },
Status: actions_model.StatusRunning, Status: actions_model.StatusRunning,
@ -66,7 +66,7 @@ func TestFullSteps(t *testing.T) {
Stopped: 10100, Stopped: 10100,
LogLength: 100, LogLength: 100,
}, },
want: []*actions_model.BotTaskStep{ want: []*actions_model.ActionTaskStep{
{Name: preStepName, Status: actions_model.StatusSuccess, LogIndex: 0, LogLength: 10, Started: 10000, Stopped: 10010}, {Name: preStepName, Status: actions_model.StatusSuccess, LogIndex: 0, LogLength: 10, Started: 10000, Stopped: 10010},
{Status: actions_model.StatusRunning, LogIndex: 10, LogLength: 80, Started: 10010, Stopped: 0}, {Status: actions_model.StatusRunning, LogIndex: 10, LogLength: 80, Started: 10010, Stopped: 0},
{Name: postStepName, Status: actions_model.StatusWaiting, LogIndex: 0, LogLength: 0, Started: 0, Stopped: 0}, {Name: postStepName, Status: actions_model.StatusWaiting, LogIndex: 0, LogLength: 0, Started: 0, Stopped: 0},
@ -74,8 +74,8 @@ func TestFullSteps(t *testing.T) {
}, },
{ {
name: "first step has canceled", name: "first step has canceled",
task: &actions_model.BotTask{ task: &actions_model.ActionTask{
Steps: []*actions_model.BotTaskStep{ Steps: []*actions_model.ActionTaskStep{
{Status: actions_model.StatusCancelled, LogIndex: 0, LogLength: 0, Started: 0, Stopped: 0}, {Status: actions_model.StatusCancelled, LogIndex: 0, LogLength: 0, Started: 0, Stopped: 0},
}, },
Status: actions_model.StatusFailure, Status: actions_model.StatusFailure,
@ -83,7 +83,7 @@ func TestFullSteps(t *testing.T) {
Stopped: 10100, Stopped: 10100,
LogLength: 100, LogLength: 100,
}, },
want: []*actions_model.BotTaskStep{ want: []*actions_model.ActionTaskStep{
{Name: preStepName, Status: actions_model.StatusFailure, LogIndex: 0, LogLength: 100, Started: 10000, Stopped: 10100}, {Name: preStepName, Status: actions_model.StatusFailure, LogIndex: 0, LogLength: 100, Started: 10000, Stopped: 10100},
{Status: actions_model.StatusCancelled, LogIndex: 0, LogLength: 0, Started: 0, Stopped: 0}, {Status: actions_model.StatusCancelled, LogIndex: 0, LogLength: 0, Started: 0, Stopped: 0},
{Name: postStepName, Status: actions_model.StatusFailure, LogIndex: 100, LogLength: 0, Started: 10100, Stopped: 10100}, {Name: postStepName, Status: actions_model.StatusFailure, LogIndex: 100, LogLength: 0, Started: 10100, Stopped: 10100},
@ -91,14 +91,14 @@ func TestFullSteps(t *testing.T) {
}, },
{ {
name: "empty steps", name: "empty steps",
task: &actions_model.BotTask{ task: &actions_model.ActionTask{
Steps: []*actions_model.BotTaskStep{}, Steps: []*actions_model.ActionTaskStep{},
Status: actions_model.StatusSuccess, Status: actions_model.StatusSuccess,
Started: 10000, Started: 10000,
Stopped: 10100, Stopped: 10100,
LogLength: 100, LogLength: 100,
}, },
want: []*actions_model.BotTaskStep{ want: []*actions_model.ActionTaskStep{
{Name: preStepName, Status: actions_model.StatusSuccess, LogIndex: 0, LogLength: 100, Started: 10000, Stopped: 10100}, {Name: preStepName, Status: actions_model.StatusSuccess, LogIndex: 0, LogLength: 100, Started: 10000, Stopped: 10100},
{Name: postStepName, Status: actions_model.StatusSuccess, LogIndex: 100, LogLength: 0, Started: 10100, Stopped: 10100}, {Name: postStepName, Status: actions_model.StatusSuccess, LogIndex: 100, LogLength: 0, Started: 10100, Stopped: 10100},
}, },

View File

@ -16,7 +16,7 @@ import (
"code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/models/unit"
user_model "code.gitea.io/gitea/models/user" user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/models/webhook" "code.gitea.io/gitea/models/webhook"
actions_module "code.gitea.io/gitea/modules/actions" bots_module "code.gitea.io/gitea/modules/actions"
"code.gitea.io/gitea/modules/convert" "code.gitea.io/gitea/modules/convert"
"code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/json"
@ -117,7 +117,7 @@ func notify(ctx context.Context, input *notifyInput) error {
return fmt.Errorf("gitRepo.GetCommit: %v", err) return fmt.Errorf("gitRepo.GetCommit: %v", err)
} }
workflows, err := actions_module.DetectWorkflows(commit, input.Event) workflows, err := bots_module.DetectWorkflows(commit, input.Event)
if err != nil { if err != nil {
return fmt.Errorf("DetectWorkflows: %v", err) return fmt.Errorf("DetectWorkflows: %v", err)
} }
@ -133,7 +133,7 @@ func notify(ctx context.Context, input *notifyInput) error {
} }
for id, content := range workflows { for id, content := range workflows {
run := actions_model.BotRun{ run := actions_model.ActionRun{
Title: commit.Message(), Title: commit.Message(),
RepoID: input.Repo.ID, RepoID: input.Repo.ID,
OwnerID: input.Repo.OwnerID, OwnerID: input.Repo.OwnerID,

View File

@ -52,7 +52,7 @@ func (s *Service) Register(
} }
// create new runner // create new runner
runner := &actions_model.BotRunner{ runner := &actions_model.ActionRunner{
UUID: gouuid.New().String(), UUID: gouuid.New().String(),
Name: req.Msg.Name, Name: req.Msg.Name,
OwnerID: runnerToken.OwnerID, OwnerID: runnerToken.OwnerID,
@ -231,7 +231,7 @@ func (s *Service) UpdateLog(
return res, nil return res, nil
} }
func pickTask(ctx context.Context, runner *actions_model.BotRunner) (*runnerv1.Task, bool, error) { func pickTask(ctx context.Context, runner *actions_model.ActionRunner) (*runnerv1.Task, bool, error) {
t, ok, err := actions_model.CreateTaskForRunner(ctx, runner) t, ok, err := actions_model.CreateTaskForRunner(ctx, runner)
if err != nil { if err != nil {
return nil, false, fmt.Errorf("CreateTaskForRunner: %w", err) return nil, false, fmt.Errorf("CreateTaskForRunner: %w", err)
@ -249,7 +249,7 @@ func pickTask(ctx context.Context, runner *actions_model.BotRunner) (*runnerv1.T
return task, true, nil return task, true, nil
} }
func getSecretsOfTask(ctx context.Context, task *actions_model.BotTask) map[string]string { func getSecretsOfTask(ctx context.Context, task *actions_model.ActionTask) map[string]string {
// Returning an error is worse than returning empty secrets. // Returning an error is worse than returning empty secrets.
secrets := map[string]string{} secrets := map[string]string{}
@ -289,7 +289,7 @@ func getSecretsOfTask(ctx context.Context, task *actions_model.BotTask) map[stri
return secrets return secrets
} }
func generateTaskContext(t *actions_model.BotTask) *structpb.Struct { func generateTaskContext(t *actions_model.ActionTask) *structpb.Struct {
event := map[string]interface{}{} event := map[string]interface{}{}
_ = json.Unmarshal([]byte(t.Job.Run.EventPayload), &event) _ = json.Unmarshal([]byte(t.Job.Run.EventPayload), &event)

View File

@ -67,9 +67,9 @@ func getMethodName(req connect.AnyRequest) string {
type runnerCtxKey struct{} type runnerCtxKey struct{}
func GetRunner(ctx context.Context) *actions_model.BotRunner { func GetRunner(ctx context.Context) *actions_model.ActionRunner {
if v := ctx.Value(runnerCtxKey{}); v != nil { if v := ctx.Value(runnerCtxKey{}); v != nil {
if r, ok := v.(*actions_model.BotRunner); ok { if r, ok := v.(*actions_model.ActionRunner); ok {
return r return r
} }
} }

View File

@ -36,7 +36,7 @@ func RunnersList(ctx *context.Context, tplName base.TplName, opts actions_model.
} }
// ownid=0,repo_id=0,means this token is used for global // ownid=0,repo_id=0,means this token is used for global
var token *actions_model.BotRunnerToken var token *actions_model.ActionRunnerToken
token, err = actions_model.GetUnactivatedRunnerToken(opts.OwnerID, opts.RepoID) token, err = actions_model.GetUnactivatedRunnerToken(opts.OwnerID, opts.RepoID)
if _, ok := err.(actions_model.ErrRunnerTokenNotExist); ok { if _, ok := err.(actions_model.ErrRunnerTokenNotExist); ok {
token, err = actions_model.NewRunnerToken(opts.OwnerID, opts.RepoID) token, err = actions_model.NewRunnerToken(opts.OwnerID, opts.RepoID)

View File

@ -125,7 +125,7 @@ func ViewPost(ctx *context_module.Context) {
}, },
} }
var task *actions_model.BotTask var task *actions_model.ActionTask
if current.TaskID > 0 { if current.TaskID > 0 {
var err error var err error
task, err = actions_model.GetTaskByID(ctx, current.TaskID) task, err = actions_model.GetTaskByID(ctx, current.TaskID)
@ -268,7 +268,7 @@ func Cancel(ctx *context_module.Context) {
// getRunJobs gets the jobs of runIndex, and returns jobs[jobIndex], jobs. // getRunJobs gets the jobs of runIndex, and returns jobs[jobIndex], jobs.
// Any error will be written to the ctx. // Any error will be written to the ctx.
// It never returns a nil job of an empty jobs, if the jobIndex is out of range, it will be treated as 0. // It never returns a nil job of an empty jobs, if the jobIndex is out of range, it will be treated as 0.
func getRunJobs(ctx *context_module.Context, runIndex, jobIndex int64) (*actions_model.BotRunJob, []*actions_model.BotRunJob) { func getRunJobs(ctx *context_module.Context, runIndex, jobIndex int64) (*actions_model.ActionRunJob, []*actions_model.ActionRunJob) {
run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex) run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex)
if err != nil { if err != nil {
if _, ok := err.(actions_model.ErrRunNotExist); ok { if _, ok := err.(actions_model.ErrRunNotExist); ok {

View File

@ -13,7 +13,7 @@ import (
repo_model "code.gitea.io/gitea/models/repo" repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user" user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/models/webhook" "code.gitea.io/gitea/models/webhook"
actions_module "code.gitea.io/gitea/modules/actions" bots_module "code.gitea.io/gitea/modules/actions"
"code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/queue" "code.gitea.io/gitea/modules/queue"
@ -33,19 +33,19 @@ func DeleteResourceOfRepository(ctx context.Context, repo *repo_model.Repository
if err := db.WithTx(ctx, func(ctx context.Context) error { if err := db.WithTx(ctx, func(ctx context.Context) error {
e := db.GetEngine(ctx) e := db.GetEngine(ctx)
if _, err := e.Delete(&actions_model.BotTaskStep{RepoID: repo.ID}); err != nil { if _, err := e.Delete(&actions_model.ActionTaskStep{RepoID: repo.ID}); err != nil {
return fmt.Errorf("delete bots task steps of repo %d: %w", repo.ID, err) return fmt.Errorf("delete bots task steps of repo %d: %w", repo.ID, err)
} }
if _, err := e.Delete(&actions_model.BotTask{RepoID: repo.ID}); err != nil { if _, err := e.Delete(&actions_model.ActionTask{RepoID: repo.ID}); err != nil {
return fmt.Errorf("delete bots tasks of repo %d: %w", repo.ID, err) return fmt.Errorf("delete bots tasks of repo %d: %w", repo.ID, err)
} }
if _, err := e.Delete(&actions_model.BotRunJob{RepoID: repo.ID}); err != nil { if _, err := e.Delete(&actions_model.ActionRunJob{RepoID: repo.ID}); err != nil {
return fmt.Errorf("delete bots run jobs of repo %d: %w", repo.ID, err) return fmt.Errorf("delete bots run jobs of repo %d: %w", repo.ID, err)
} }
if _, err := e.Delete(&actions_model.BotRun{RepoID: repo.ID}); err != nil { if _, err := e.Delete(&actions_model.ActionRun{RepoID: repo.ID}); err != nil {
return fmt.Errorf("delete bots runs of repo %d: %w", repo.ID, err) return fmt.Errorf("delete bots runs of repo %d: %w", repo.ID, err)
} }
if _, err := e.Delete(&actions_model.BotRunner{RepoID: repo.ID}); err != nil { if _, err := e.Delete(&actions_model.ActionRunner{RepoID: repo.ID}); err != nil {
return fmt.Errorf("delete bots runner of repo %d: %w", repo.ID, err) return fmt.Errorf("delete bots runner of repo %d: %w", repo.ID, err)
} }
return nil return nil
@ -55,7 +55,7 @@ func DeleteResourceOfRepository(ctx context.Context, repo *repo_model.Repository
// remove logs file after tasks have been deleted, to avoid new log files // remove logs file after tasks have been deleted, to avoid new log files
for _, task := range tasks { for _, task := range tasks {
err := actions_module.RemoveLogs(ctx, task.LogInStorage, task.LogFilename) err := bots_module.RemoveLogs(ctx, task.LogInStorage, task.LogFilename)
if err != nil { if err != nil {
log.Error("remove log file %q: %v", task.LogFilename, err) log.Error("remove log file %q: %v", task.LogFilename, err)
// go on // go on
@ -65,7 +65,7 @@ func DeleteResourceOfRepository(ctx context.Context, repo *repo_model.Repository
return nil return nil
} }
func CreateCommitStatus(ctx context.Context, job *actions_model.BotRunJob) error { func CreateCommitStatus(ctx context.Context, job *actions_model.ActionRunJob) error {
if err := job.LoadAttributes(ctx); err != nil { if err := job.LoadAttributes(ctx); err != nil {
return fmt.Errorf("load run: %w", err) return fmt.Errorf("load run: %w", err)
} }

View File

@ -50,7 +50,7 @@ func checkJobsOfRun(ctx context.Context, runID int64) error {
if err != nil { if err != nil {
return err return err
} }
idToJobs := make(map[string][]*actions_model.BotRunJob, len(jobs)) idToJobs := make(map[string][]*actions_model.ActionRunJob, len(jobs))
for _, job := range jobs { for _, job := range jobs {
idToJobs[job.JobID] = append(idToJobs[job.JobID], job) idToJobs[job.JobID] = append(idToJobs[job.JobID], job)
} }
@ -75,8 +75,8 @@ type jobStatusResolver struct {
needs map[int64][]int64 needs map[int64][]int64
} }
func newJobStatusResolver(jobs actions_model.RunJobList) *jobStatusResolver { func newJobStatusResolver(jobs actions_model.ActionJobList) *jobStatusResolver {
idToJobs := make(map[string][]*actions_model.BotRunJob, len(jobs)) idToJobs := make(map[string][]*actions_model.ActionRunJob, len(jobs))
for _, job := range jobs { for _, job := range jobs {
idToJobs[job.JobID] = append(idToJobs[job.JobID], job) idToJobs[job.JobID] = append(idToJobs[job.JobID], job)
} }

View File

@ -14,12 +14,12 @@ import (
func Test_jobStatusResolver_Resolve(t *testing.T) { func Test_jobStatusResolver_Resolve(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
jobs actions_model.RunJobList jobs actions_model.ActionJobList
want map[int64]actions_model.Status want map[int64]actions_model.Status
}{ }{
{ {
name: "no blocked", name: "no blocked",
jobs: actions_model.RunJobList{ jobs: actions_model.ActionJobList{
{ID: 1, JobID: "1", Status: actions_model.StatusWaiting, Needs: []string{}}, {ID: 1, JobID: "1", Status: actions_model.StatusWaiting, Needs: []string{}},
{ID: 2, JobID: "2", Status: actions_model.StatusWaiting, Needs: []string{}}, {ID: 2, JobID: "2", Status: actions_model.StatusWaiting, Needs: []string{}},
{ID: 3, JobID: "3", Status: actions_model.StatusWaiting, Needs: []string{}}, {ID: 3, JobID: "3", Status: actions_model.StatusWaiting, Needs: []string{}},
@ -28,7 +28,7 @@ func Test_jobStatusResolver_Resolve(t *testing.T) {
}, },
{ {
name: "single blocked", name: "single blocked",
jobs: actions_model.RunJobList{ jobs: actions_model.ActionJobList{
{ID: 1, JobID: "1", Status: actions_model.StatusSuccess, Needs: []string{}}, {ID: 1, JobID: "1", Status: actions_model.StatusSuccess, Needs: []string{}},
{ID: 2, JobID: "2", Status: actions_model.StatusBlocked, Needs: []string{"1"}}, {ID: 2, JobID: "2", Status: actions_model.StatusBlocked, Needs: []string{"1"}},
{ID: 3, JobID: "3", Status: actions_model.StatusWaiting, Needs: []string{}}, {ID: 3, JobID: "3", Status: actions_model.StatusWaiting, Needs: []string{}},
@ -39,7 +39,7 @@ func Test_jobStatusResolver_Resolve(t *testing.T) {
}, },
{ {
name: "multiple blocked", name: "multiple blocked",
jobs: actions_model.RunJobList{ jobs: actions_model.ActionJobList{
{ID: 1, JobID: "1", Status: actions_model.StatusSuccess, Needs: []string{}}, {ID: 1, JobID: "1", Status: actions_model.StatusSuccess, Needs: []string{}},
{ID: 2, JobID: "2", Status: actions_model.StatusBlocked, Needs: []string{"1"}}, {ID: 2, JobID: "2", Status: actions_model.StatusBlocked, Needs: []string{"1"}},
{ID: 3, JobID: "3", Status: actions_model.StatusBlocked, Needs: []string{"1"}}, {ID: 3, JobID: "3", Status: actions_model.StatusBlocked, Needs: []string{"1"}},
@ -51,7 +51,7 @@ func Test_jobStatusResolver_Resolve(t *testing.T) {
}, },
{ {
name: "chain blocked", name: "chain blocked",
jobs: actions_model.RunJobList{ jobs: actions_model.ActionJobList{
{ID: 1, JobID: "1", Status: actions_model.StatusFailure, Needs: []string{}}, {ID: 1, JobID: "1", Status: actions_model.StatusFailure, Needs: []string{}},
{ID: 2, JobID: "2", Status: actions_model.StatusBlocked, Needs: []string{"1"}}, {ID: 2, JobID: "2", Status: actions_model.StatusBlocked, Needs: []string{"1"}},
{ID: 3, JobID: "3", Status: actions_model.StatusBlocked, Needs: []string{"2"}}, {ID: 3, JobID: "3", Status: actions_model.StatusBlocked, Needs: []string{"2"}},
@ -63,7 +63,7 @@ func Test_jobStatusResolver_Resolve(t *testing.T) {
}, },
{ {
name: "loop need", name: "loop need",
jobs: actions_model.RunJobList{ jobs: actions_model.ActionJobList{
{ID: 1, JobID: "1", Status: actions_model.StatusBlocked, Needs: []string{"3"}}, {ID: 1, JobID: "1", Status: actions_model.StatusBlocked, Needs: []string{"3"}},
{ID: 2, JobID: "2", Status: actions_model.StatusBlocked, Needs: []string{"1"}}, {ID: 2, JobID: "2", Status: actions_model.StatusBlocked, Needs: []string{"1"}},
{ID: 3, JobID: "3", Status: actions_model.StatusBlocked, Needs: []string{"2"}}, {ID: 3, JobID: "3", Status: actions_model.StatusBlocked, Needs: []string{"2"}},