mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-11 17:50:58 +00:00
initial load of yaml working
This commit is contained in:
parent
113ebda3ff
commit
fbab49c68d
28 changed files with 522 additions and 393 deletions
40
cmd/graph.go
Normal file
40
cmd/graph.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/nektos/act/pkg/common"
|
||||
"github.com/nektos/act/pkg/model"
|
||||
)
|
||||
|
||||
func drawGraph(plan *model.Plan) error {
|
||||
|
||||
drawings := make([]*common.Drawing, 0)
|
||||
|
||||
jobPen := common.NewPen(common.StyleSingleLine, 96)
|
||||
arrowPen := common.NewPen(common.StyleNoLine, 97)
|
||||
for i, stage := range plan.Stages {
|
||||
if i > 0 {
|
||||
drawings = append(drawings, arrowPen.DrawArrow())
|
||||
}
|
||||
|
||||
ids := make([]string, 0)
|
||||
for _, r := range stage.Runs {
|
||||
ids = append(ids, fmt.Sprintf("%s/%s", r.Workflow.Name, r.JobID))
|
||||
}
|
||||
drawings = append(drawings, jobPen.DrawBoxes(ids...))
|
||||
}
|
||||
|
||||
maxWidth := 0
|
||||
for _, d := range drawings {
|
||||
if d.GetWidth() > maxWidth {
|
||||
maxWidth = d.GetWidth()
|
||||
}
|
||||
}
|
||||
|
||||
for _, d := range drawings {
|
||||
d.Draw(os.Stdout, maxWidth)
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue