Let workflows merge or discard their own tasks
This commit is contained in:
@@ -44,16 +44,6 @@ func (m *Manager) auditAll(ctx context.Context) {
|
||||
return
|
||||
}
|
||||
for _, p := range projects {
|
||||
tasks, err := m.store.ListTasks(ctx, p.Id)
|
||||
if err != nil {
|
||||
slog.Error("start audits", "project", p.Id, "err", err)
|
||||
continue
|
||||
}
|
||||
for _, t := range tasks {
|
||||
if t.Status == api.TaskStatusActive && t.Background && t.State == api.TaskStateDiscardSuggested {
|
||||
m.dismissAudit(t.Id)
|
||||
}
|
||||
}
|
||||
m.audit(p.Id)
|
||||
}
|
||||
}
|
||||
@@ -119,31 +109,5 @@ func auditBrief(branch, commit string) string {
|
||||
return fmt.Sprintf("Audit of %s at %s. This isn't a review of a change: check the whole codebase as it stands against the project's standards and expectations, and fix what falls short. "+
|
||||
"byre runs this task in the background: the human doesn't see it until you ask a question, call ready_for_merge or hit an error. "+
|
||||
"Finish your stage with finish_stage as usual, even when you found nothing. Once your stage has finished and its review has come back, byre asks whether the task is ready to merge;"+
|
||||
"if nothing needed changing, answer with suggest_discard, and byre discards the task without bothering the human.", branch, commit)
|
||||
}
|
||||
|
||||
func (m *Manager) dismissAudit(taskID string) {
|
||||
ctx := context.Background()
|
||||
task, err := m.store.GetTask(ctx, taskID)
|
||||
if err != nil {
|
||||
slog.Error("dismiss audit", "task", taskID, "err", err)
|
||||
return
|
||||
}
|
||||
if !task.Background || task.Status != api.TaskStatusActive || task.WorkflowStage == nil {
|
||||
return
|
||||
}
|
||||
output, _, err := m.store.StageResult(ctx, taskID)
|
||||
if err != nil {
|
||||
slog.Error("dismiss audit", "task", taskID, "err", err)
|
||||
return
|
||||
}
|
||||
if output == "" {
|
||||
return
|
||||
}
|
||||
_, err = m.Discard(ctx, task, "byre")
|
||||
if err != nil {
|
||||
slog.Error("dismiss audit", "task", taskID, "err", err)
|
||||
return
|
||||
}
|
||||
slog.Info("audit dismissed itself", "task", taskID)
|
||||
"if nothing needed changing, answer with suggest_discard.", branch, commit)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user