mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-01 20:59:45 +09:00
enhance(actions): add pending job status and align job statuses with GitHub (#39376)
This commit is contained in:
@@ -178,10 +178,19 @@ func TestToActionWorkflowJob_StepStatusIsIndependentOfJobStatus(t *testing.T) {
|
||||
assert.Equal(t, "failure", apiJob.Steps[1].Conclusion, "step 1 conclusion")
|
||||
}
|
||||
|
||||
func TestToActionsStatus_Cancelling(t *testing.T) {
|
||||
action, conclusion := ToActionsStatus(actions_model.StatusCancelling)
|
||||
assert.Equal(t, "in_progress", action)
|
||||
assert.Empty(t, conclusion)
|
||||
func TestToActionsStatus(t *testing.T) {
|
||||
for status, expected := range map[actions_model.Status]string{
|
||||
actions_model.StatusWaiting: "queued",
|
||||
actions_model.StatusBlocked: "pending",
|
||||
actions_model.StatusPending: "requested",
|
||||
actions_model.StatusCancelling: "in_progress",
|
||||
} {
|
||||
action, conclusion := ToActionsStatus(status)
|
||||
assert.Equal(t, expected, action, status.String())
|
||||
assert.Empty(t, conclusion)
|
||||
}
|
||||
action, _ := ToRunActionsStatus(&actions_model.ActionRun{NeedApproval: true}, actions_model.StatusBlocked)
|
||||
assert.Equal(t, "waiting", action)
|
||||
}
|
||||
|
||||
func TestToWorkflowRunAction_Cancelling(t *testing.T) {
|
||||
|
||||
@@ -273,7 +273,7 @@ func ToActionWorkflowRun(ctx context.Context, run *actions_model.ActionRun, atte
|
||||
}
|
||||
|
||||
runAttempt := int64(0)
|
||||
status, conclusion := ToActionsStatus(run.Status)
|
||||
status, conclusion := ToRunActionsStatus(run, run.Status)
|
||||
startedAt := run.Started.AsLocalTime()
|
||||
completedAt := run.Stopped.AsLocalTime()
|
||||
actor := run.TriggerUser // The username of the user that triggered the initial workflow run.
|
||||
@@ -289,7 +289,7 @@ func ToActionWorkflowRun(ctx context.Context, run *actions_model.ActionRun, atte
|
||||
return nil, err
|
||||
}
|
||||
runAttempt = attempt.Attempt
|
||||
status, conclusion = ToActionsStatus(attempt.Status)
|
||||
status, conclusion = ToRunActionsStatus(run, attempt.Status)
|
||||
startedAt = attempt.Started.AsLocalTime()
|
||||
completedAt = attempt.Stopped.AsLocalTime()
|
||||
triggerUser = attempt.TriggerUser
|
||||
@@ -435,12 +435,21 @@ func ToWorkflowRunAction(status actions_model.Status) (action string) {
|
||||
return action
|
||||
}
|
||||
|
||||
func ToRunActionsStatus(run *actions_model.ActionRun, status actions_model.Status) (action, conclusion string) {
|
||||
if status.IsBlocked() && run.NeedApproval {
|
||||
return "waiting", ""
|
||||
}
|
||||
return ToActionsStatus(status)
|
||||
}
|
||||
|
||||
func ToActionsStatus(status actions_model.Status) (action, conclusion string) {
|
||||
switch status {
|
||||
case actions_model.StatusWaiting:
|
||||
action = "queued" // "waiting" is a naming conflict of the webhook between Gitea and GitHub Actions
|
||||
action = "queued"
|
||||
case actions_model.StatusBlocked:
|
||||
action = "waiting" // naming conflict (as above)
|
||||
action = "pending"
|
||||
case actions_model.StatusPending:
|
||||
action = "requested"
|
||||
case actions_model.StatusRunning, actions_model.StatusCancelling:
|
||||
action = "in_progress"
|
||||
default:
|
||||
@@ -469,7 +478,7 @@ func ToActionWorkflowJob(ctx context.Context, repo *repo_model.Repository, task
|
||||
return nil, err
|
||||
}
|
||||
|
||||
status, conclusion := ToActionsStatus(job.Status)
|
||||
status, conclusion := ToRunActionsStatus(job.Run, job.Status)
|
||||
var runnerID int64
|
||||
var runnerName string
|
||||
var steps []*api.ActionWorkflowStep
|
||||
|
||||
Reference in New Issue
Block a user