more flow
Build and Publish / BuildAndDeployAmd64 (push) Failing after 4s
Build and Publish / BuildAndDeployArm64 (push) Failing after 5s

This commit is contained in:
2026-07-01 12:13:38 +02:00
parent 83986e7a35
commit 4a37cb479c
8 changed files with 85 additions and 9 deletions
+23
View File
@@ -242,6 +242,11 @@ func (e *Engine) Validate(def *Definition) error {
if _, ok := e.reg.hook(h.Type); !ok {
return fmt.Errorf("flow %q step %q: unknown hook %q", def.Name, s.Name, h.Type)
}
if h.When != "" {
if _, ok := e.reg.predicate(h.When); !ok {
return fmt.Errorf("flow %q step %q: hook %q: unknown predicate %q", def.Name, s.Name, h.Type, h.When)
}
}
}
}
}
@@ -337,8 +342,26 @@ func (e *Engine) compensate(ctx context.Context, res *Result, executed []Step, s
}
// fireHooks runs every hook for a phase, logging (never propagating) failures.
// Hooks with a When predicate are evaluated first; the hook is skipped when the
// predicate returns false.
func (e *Engine) fireHooks(ctx context.Context, st *State, refs []HookRef, info HookInfo) {
for _, ref := range refs {
if ref.When != "" {
pred, ok := e.reg.predicate(ref.When)
if !ok {
st.Logger.Error("flow hook skipped: unknown predicate", "hook", ref.Type, "predicate", ref.When, "step", info.Step)
continue
}
run, err := pred(ctx, st)
if err != nil {
st.Logger.Error("flow hook predicate error", "hook", ref.Type, "predicate", ref.When, "step", info.Step, "err", err)
continue
}
if !run {
st.Logger.Debug("flow hook skipped by predicate", "hook", ref.Type, "predicate", ref.When, "step", info.Step)
continue
}
}
h, ok := e.reg.hook(ref.Type)
if !ok {
st.Logger.Error("flow hook skipped: unknown type", "hook", ref.Type, "step", info.Step)