Monorepo for Tangled
0

Configure Feed

Select the types of activity you want to include in your feed.

core / appview / pipelines / ssh / cihelpers.go
785 B 43 lines
1package ssh 2 3import ( 4 "time" 5 6 "tangled.org/core/api/tangled" 7) 8 9// helper functions against generated code 10 11func workflowElapsed(wf *tangled.CiPipeline_Workflow, now time.Time) time.Duration { 12 if wf.StartedAt == nil { 13 return 0 14 } 15 started, err := time.Parse(time.RFC3339, *wf.StartedAt) 16 if err != nil { 17 return 0 18 } 19 if wf.FinishedAt == nil { 20 return now.Sub(started) 21 } 22 finished, err := time.Parse(time.RFC3339, *wf.FinishedAt) 23 if err != nil { 24 return 0 25 } 26 return finished.Sub(started) 27} 28 29var finishedStatuses = map[string]bool{ 30 "failed": true, 31 "timeout": true, 32 "cancelled": true, 33 "success": true, 34} 35 36func pipelineFinished(p *tangled.CiPipeline) bool { 37 for _, wf := range p.Workflows { 38 if !finishedStatuses[wf.Status] { 39 return false 40 } 41 } 42 return true 43}