mirror of
https://github.com/go-gitea/gitea.git
synced 2024-09-01 14:56:30 +00:00
fix: update run status
This commit is contained in:
parent
3d4d44dadf
commit
d6e100f6be
@ -84,7 +84,11 @@ func (run *Run) LoadAttributes(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (run *Run) TakeTime() time.Duration {
|
func (run *Run) TakeTime() time.Duration {
|
||||||
return run.Started.AsTime().Sub(run.Stopped.AsTime())
|
started := run.Started.AsTime()
|
||||||
|
if run.Status.IsDone() {
|
||||||
|
return run.Stopped.AsTime().Sub(started)
|
||||||
|
}
|
||||||
|
return time.Since(started)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error {
|
func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error {
|
||||||
|
@ -105,12 +105,20 @@ func UpdateRunJob(ctx context.Context, job *RunJob, cols ...string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if job.RunID == 0 {
|
||||||
|
var err error
|
||||||
|
if job, err = GetRunJobByID(ctx, job.ID); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
jobs, err := GetRunJobsByRunID(ctx, job.RunID)
|
jobs, err := GetRunJobsByRunID(ctx, job.RunID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
runStatus := aggregateJobStatus(jobs)
|
runStatus := aggregateJobStatus(jobs)
|
||||||
|
|
||||||
run := &Run{
|
run := &Run{
|
||||||
ID: job.RunID,
|
ID: job.RunID,
|
||||||
Status: runStatus,
|
Status: runStatus,
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
"code.gitea.io/gitea/modules/repository"
|
"code.gitea.io/gitea/modules/repository"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/timeutil"
|
||||||
|
|
||||||
"github.com/nektos/act/pkg/jobparser"
|
"github.com/nektos/act/pkg/jobparser"
|
||||||
)
|
)
|
||||||
@ -94,6 +95,7 @@ func notify(repo *repo_model.Repository, doer *user_model.User, payload, ref str
|
|||||||
Event: evt,
|
Event: evt,
|
||||||
EventPayload: payload,
|
EventPayload: payload,
|
||||||
Status: bots_model.StatusWaiting,
|
Status: bots_model.StatusWaiting,
|
||||||
|
Started: timeutil.TimeStampNow(),
|
||||||
}
|
}
|
||||||
if len(run.Title) > 255 {
|
if len(run.Title) > 255 {
|
||||||
run.Title = run.Title[:255]
|
run.Title = run.Title[:255]
|
||||||
|
Loading…
Reference in New Issue
Block a user