feat: record job needs

This commit is contained in:
Jason Song
2022-11-04 11:40:39 +08:00
parent 234cdc67e1
commit cf40dca0c4
7 changed files with 17 additions and 14 deletions

View File

@ -14,10 +14,10 @@ import (
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/models/webhook"
"code.gitea.io/gitea/modules/timeutil"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/timeutil"
"xorm.io/builder"
"github.com/nektos/act/pkg/jobparser"
"golang.org/x/exp/slices"
)
@ -167,15 +167,19 @@ func InsertRun(run *Run, jobs []*jobparser.SingleWorkflow) error {
for _, v := range jobs {
id, job := v.Job()
payload, _ := v.Marshal()
needs := job.Needs()
status := StatusWaiting
if len(needs) > 0 {
status = StatusBlocked
}
runJobs = append(runJobs, &RunJob{
RunID: run.ID,
Name: job.Name,
Ready: true, // TODO: should be false if there are needs to satisfy
WorkflowPayload: payload,
JobID: id,
Needs: nil, // TODO: analyse needs
Needs: needs,
RunsOn: job.RunsOn(),
Status: StatusWaiting,
Status: status,
})
}
if err := db.Insert(ctx, runJobs); err != nil {