mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-18 01:14:37 -04:00
Refactor commit status for Actions jobs (#23786)
Before: <img width="353" alt="xnip_230329_163852" src="https://user-images.githubusercontent.com/9418365/228479807-424452df-10fa-45cf-ae4b-09939c0ed54c.png"> After: <img width="508" alt="xnip_230329_163358" src="https://user-images.githubusercontent.com/9418365/228479923-537b54fe-9564-4105-a068-bcc75fa2a7ea.png"> Highlights: - Treat `StatusSkipped` as `CommitStatusSuccess` instead of `CommitStatusFailure`, so it fixed #23599. - Use the bot user `gitea-actions` instead of the trigger as the creator of commit status. - New format `<run_name> / <job_name> / (<event>)` for the context of commit status to avoid conflicts. - Add descriptions for commit status. - Add the missing calls to `CreateCommitStatus`. - Refactor `CreateCommitStatus` to make it easier to use.
This commit is contained in:
parent
e57e1144c5
commit
3e8db31a5b
7 changed files with 76 additions and 71 deletions
|
@ -64,12 +64,7 @@ func stopTasks(ctx context.Context, opts actions_model.FindTaskOptions) error {
|
|||
}
|
||||
}
|
||||
|
||||
for _, job := range jobs {
|
||||
if err := CreateCommitStatus(ctx, job); err != nil {
|
||||
log.Error("Update commit status for job %v failed: %v", job.ID, err)
|
||||
// go on
|
||||
}
|
||||
}
|
||||
CreateCommitStatus(ctx, jobs...)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -96,10 +91,7 @@ func CancelAbandonedJobs(ctx context.Context) error {
|
|||
log.Warn("cancel abandoned job %v: %v", job.ID, err)
|
||||
// go on
|
||||
}
|
||||
if err := CreateCommitStatus(ctx, job); err != nil {
|
||||
log.Error("Update commit status for job %v failed: %v", job.ID, err)
|
||||
// go on
|
||||
}
|
||||
CreateCommitStatus(ctx, job)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue