A vibe coded tangled fork which supports pijul.
at sl/spindle-adapters 40 lines 1.1 kB view raw
1package spindle 2 3import ( 4 "context" 5 6 "tangled.org/core/spindle/models" 7) 8 9// createPipeline creates a pipeline from given event. 10// It will call `EvaluateEvent` for all adapters, gather the triggered workflow 11// runs, and constuct a pipeline record from them. pipeline record. It will 12// return nil if no workflow run has triggered. 13// 14// NOTE: This method won't fail. If `adapter.EvaluateEvent` returns an error, 15// the error will be logged but won't bubble-up. 16// 17// NOTE: Adapters might create sub-event on its own for workflows triggered by 18// other workflow runs. 19func (s *Spindle) createPipeline(ctx context.Context, event models.Event) (*models.Pipeline2) { 20 l := s.l 21 22 pipeline := models.Pipeline2{ 23 Event: event, 24 } 25 26 // TODO: run in parallel 27 for id, adapter := range s.adapters { 28 runs, err := adapter.EvaluateEvent(ctx, event) 29 if err != nil { 30 l.Error("failed to process trigger from adapter '%s': %w", id, err) 31 } 32 pipeline.WorkflowRuns = append(pipeline.WorkflowRuns, runs...) 33 } 34 35 if len(pipeline.WorkflowRuns) == 0 { 36 return nil 37 } 38 39 return &pipeline 40}