back interdiff of round #1 and #0

spindle: make workflows engine-agnostic #423

merged
opened by winter.bsky.social targeting master from winter.bsky.social/core: push-luoyqwkpromz
ERROR
api/tangled/cbor_gen.go

Failed to calculate interdiff for this file.

ERROR
api/tangled/tangledpipeline.go

Failed to calculate interdiff for this file.

ERROR
cmd/gen.go

Failed to calculate interdiff for this file.

ERROR
lexicons/pipeline/pipeline.json

Failed to calculate interdiff for this file.

ERROR
nix/modules/spindle.nix

Failed to calculate interdiff for this file.

ERROR
spindle/config/config.go

Failed to calculate interdiff for this file.

ERROR
spindle/engine/engine.go

Failed to calculate interdiff for this file.

ERROR
spindle/engine/errors.go

Failed to calculate interdiff for this file.

REVERTED
spindle/engine/logger.go
··· 80 80 if err := w.logger.encoder.Encode(entry); err != nil { 81 81 return 0, err 82 82 } 83 + return len(w.step.Name), nil 83 - return len(w.step.Name()), nil 84 84 }
ERROR
spindle/engines/nixery/ansi_stripper.go

Failed to calculate interdiff for this file.

ERROR
spindle/engines/nixery/engine.go

Failed to calculate interdiff for this file.

ERROR
spindle/engines/nixery/envs.go

Failed to calculate interdiff for this file.

ERROR
spindle/engines/nixery/envs_test.go

Failed to calculate interdiff for this file.

ERROR
spindle/engines/nixery/errors.go

Failed to calculate interdiff for this file.

ERROR
spindle/engines/nixery/setup_steps.go

Failed to calculate interdiff for this file.

ERROR
spindle/models/models.go

Failed to calculate interdiff for this file.

ERROR
spindle/models/pipeline.go

Failed to calculate interdiff for this file.

ERROR
spindle/server.go

Failed to calculate interdiff for this file.

ERROR
spindle/stream.go

Failed to calculate interdiff for this file.

ERROR
spindle/xrpc/xrpc.go

Failed to calculate interdiff for this file.

ERROR
workflow/compile.go

Failed to calculate interdiff for this file.

ERROR
workflow/compile_test.go

Failed to calculate interdiff for this file.

ERROR
workflow/def.go

Failed to calculate interdiff for this file.

ERROR
workflow/def_test.go

Failed to calculate interdiff for this file.

NEW
spindle/models/engine.go
··· 1 + package models 2 + 3 + import ( 4 + "context" 5 + "time" 6 + 7 + "tangled.sh/tangled.sh/core/api/tangled" 8 + "tangled.sh/tangled.sh/core/spindle/secrets" 9 + ) 10 + 11 + type Engine interface { 12 + InitWorkflow(twf tangled.Pipeline_Workflow, tpl tangled.Pipeline) (*Workflow, error) 13 + SetupWorkflow(ctx context.Context, wid WorkflowId, wf *Workflow) error 14 + WorkflowTimeout() time.Duration 15 + DestroyWorkflow(ctx context.Context, wid WorkflowId) error 16 + RunStep(ctx context.Context, wid WorkflowId, w *Workflow, idx int, secrets []secrets.UnlockedSecret, wfLogger *WorkflowLogger) error 17 + }
NEW
spindle/models/logger.go
··· 1 - package engine 1 + package models 2 2 3 3 import ( 4 4 "encoding/json" ··· 7 7 "os" 8 8 "path/filepath" 9 9 "strings" 10 - 11 - "tangled.sh/tangled.sh/core/spindle/models" 12 10 ) 13 11 14 12 type WorkflowLogger struct { ··· 16 14 encoder *json.Encoder 17 15 } 18 16 19 - func NewWorkflowLogger(baseDir string, wid models.WorkflowId) (*WorkflowLogger, error) { 17 + func NewWorkflowLogger(baseDir string, wid WorkflowId) (*WorkflowLogger, error) { 20 18 path := LogFilePath(baseDir, wid) 21 19 22 20 file, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644) ··· 30 28 }, nil 31 29 } 32 30 33 - func LogFilePath(baseDir string, workflowID models.WorkflowId) string { 31 + func LogFilePath(baseDir string, workflowID WorkflowId) string { 34 32 logFilePath := filepath.Join(baseDir, fmt.Sprintf("%s.log", workflowID.String())) 35 33 return logFilePath 36 34 } ··· 47 45 } 48 46 } 49 47 50 - func (l *WorkflowLogger) ControlWriter(idx int, step models.Step) io.Writer { 48 + func (l *WorkflowLogger) ControlWriter(idx int, step Step) io.Writer { 51 49 return &controlWriter{ 52 50 logger: l, 53 51 idx: idx, ··· 62 60 63 61 func (w *dataWriter) Write(p []byte) (int, error) { 64 62 line := strings.TrimRight(string(p), "\r\n") 65 - entry := models.NewDataLogLine(line, w.stream) 63 + entry := NewDataLogLine(line, w.stream) 66 64 if err := w.logger.encoder.Encode(entry); err != nil { 67 65 return 0, err 68 66 } ··· 72 70 type controlWriter struct { 73 71 logger *WorkflowLogger 74 72 idx int 75 - step models.Step 73 + step Step 76 74 } 77 75 78 76 func (w *controlWriter) Write(_ []byte) (int, error) { 79 - entry := models.NewControlLogLine(w.idx, w.step) 77 + entry := NewControlLogLine(w.idx, w.step) 80 78 if err := w.logger.encoder.Encode(entry); err != nil { 81 79 return 0, err 82 80 } 83 - return len(w.step.Name), nil 81 + return len(w.step.Name()), nil 84 82 }