diff --git a/pkg/cli/add_command_test.go b/pkg/cli/add_command_test.go index 928a9645978..c0354d05213 100644 --- a/pkg/cli/add_command_test.go +++ b/pkg/cli/add_command_test.go @@ -616,7 +616,7 @@ on: # Worker `), 0o644)) - compileDispatchWorkflowDependencies(context.Background(), mainPath, false, true, "", false, nil) + compileDispatchWorkflowDependenciesWithActionRef(context.Background(), mainPath, false, true, "", "", false, nil) lockPath := filepath.Join(workflowsDir, "worker.lock.yml") _, err := os.Stat(lockPath) @@ -651,7 +651,7 @@ safe-outputs: // Write an intentionally broken worker file (no frontmatter — compile will fail). require.NoError(t, os.WriteFile(workerPath, []byte(`not valid workflow content`), 0o644)) - err := compileCallWorkflowDependencies(context.Background(), mainPath, false, true, "", false, nil) + err := compileCallWorkflowDependenciesWithActionRef(context.Background(), mainPath, false, true, "", "", false, nil) require.Error(t, err, "worker compilation failure should propagate as an error") require.ErrorContains(t, err, "worker", "error should mention the worker name") } @@ -690,13 +690,13 @@ on: require.NoError(t, os.WriteFile(lockPath, []byte("# stale lock"), 0o644)) // Without force: stale lock is preserved. - err := compileCallWorkflowDependencies(context.Background(), mainPath, false, true, "", false, nil) + err := compileCallWorkflowDependenciesWithActionRef(context.Background(), mainPath, false, true, "", "", false, nil) require.NoError(t, err) content, _ := os.ReadFile(lockPath) assert.Equal(t, "# stale lock", string(content), "without force, stale lock should not be recompiled") // With force: stale lock gets recompiled. - err = compileCallWorkflowDependencies(context.Background(), mainPath, false, true, "", true, nil) + err = compileCallWorkflowDependenciesWithActionRef(context.Background(), mainPath, false, true, "", "", true, nil) require.NoError(t, err) recompiled, _ := os.ReadFile(lockPath) assert.NotEqual(t, "# stale lock", string(recompiled), "with force, stale lock should be recompiled") diff --git a/pkg/cli/add_workflow_compilation.go b/pkg/cli/add_workflow_compilation.go index 910db268368..c8cffa418c8 100644 --- a/pkg/cli/add_workflow_compilation.go +++ b/pkg/cli/add_workflow_compilation.go @@ -20,7 +20,7 @@ import ( var addWorkflowCompilationLog = logger.New("cli:add_workflow_compilation") // compileWorkflow compiles a workflow file without refreshing stop time. -// This is a convenience wrapper around compileWorkflowWithRefresh. +// This is a convenience wrapper around compileWorkflowWithActionRef. func compileWorkflow(ctx context.Context, filePath string, verbose bool, quiet bool, engineOverride string) error { return compileWorkflowWithActionRef(ctx, filePath, verbose, quiet, engineOverride, "") } @@ -29,12 +29,6 @@ func compileWorkflowWithActionRef(ctx context.Context, filePath string, verbose return compileWorkflowWithRefreshAndActionRef(ctx, filePath, verbose, quiet, engineOverride, actionRef, false, false) } -// compileWorkflowWithRefresh compiles a workflow file with optional stop time refresh. -// This function handles the compilation process and ensures .gitattributes is updated. -func compileWorkflowWithRefresh(ctx context.Context, filePath string, verbose bool, quiet bool, engineOverride string, refreshStopTime bool, approve bool) error { - return compileWorkflowWithRefreshAndActionRef(ctx, filePath, verbose, quiet, engineOverride, "", refreshStopTime, approve) -} - func compileWorkflowWithRefreshAndActionRef(ctx context.Context, filePath string, verbose bool, quiet bool, engineOverride, actionRef string, refreshStopTime bool, approve bool) error { addWorkflowCompilationLog.Printf("Compiling workflow: file=%s, refresh_stop_time=%v, engine=%s, approve=%v", filePath, refreshStopTime, engineOverride, approve) @@ -68,12 +62,6 @@ func compileWorkflowWithRefreshAndActionRef(ctx context.Context, filePath string return nil } -// compileWorkflowWithTracking compiles a workflow and tracks generated files. -// This is a convenience wrapper around compileWorkflowWithTrackingAndRefresh. -func compileWorkflowWithTracking(ctx context.Context, filePath string, verbose bool, quiet bool, engineOverride string, tracker *FileTracker) error { - return compileWorkflowWithTrackingAndActionRef(ctx, filePath, verbose, quiet, engineOverride, "", tracker) -} - func compileWorkflowWithTrackingAndActionRef(ctx context.Context, filePath string, verbose bool, quiet bool, engineOverride, actionRef string, tracker *FileTracker) error { return compileWorkflowWithTrackingAndRefreshAndActionRef(ctx, filePath, verbose, quiet, engineOverride, actionRef, tracker, false) } @@ -149,21 +137,13 @@ type compileDepsOptions struct { tracker *FileTracker } -// compileDispatchWorkflowDependencies compiles any dispatch-workflow .md dependencies of -// workflowFile that are present locally but lack a corresponding .lock.yml. This must be -// called before compiling the main workflow, because the dispatch-workflow validator -// requires every referenced .md workflow to have an up-to-date .lock.yml. -func compileDispatchWorkflowDependencies(ctx context.Context, workflowFile string, verbose, quiet bool, engineOverride string, force bool, tracker *FileTracker) { - compileDispatchWorkflowDependenciesWithActionRef(ctx, workflowFile, verbose, quiet, engineOverride, "", force, tracker) -} - func compileDispatchWorkflowDependenciesWithActionRef(ctx context.Context, workflowFile string, verbose, quiet bool, engineOverride, actionRef string, force bool, tracker *FileTracker) { compileSafeOutputsWorkflowDependencies(ctx, workflowFile, "dispatch-workflow dependency", dispatchWorkflowNamesForCompilation, compileDepsOptions{ verbose: verbose, quiet: quiet, engineOverride: engineOverride, actionRef: actionRef, force: force, propagateErrors: false, tracker: tracker, }) } -// compileCallWorkflowDependencies compiles any call-workflow .md worker dependencies of +// compileCallWorkflowDependenciesWithActionRef compiles any call-workflow .md worker dependencies of // workflowFile that are present locally but lack a corresponding .lock.yml. This must be // called before compiling the main workflow, because the call-workflow validator requires // every referenced .md worker to have an up-to-date .lock.yml. @@ -172,10 +152,6 @@ func compileDispatchWorkflowDependenciesWithActionRef(ctx context.Context, workf // the dynamic tool-generation path maps every worker .md to a .lock.yml reference, so a // worker whose lock cannot be produced would leave the orchestrator referencing a file that // does not exist. -func compileCallWorkflowDependencies(ctx context.Context, workflowFile string, verbose, quiet bool, engineOverride string, force bool, tracker *FileTracker) error { - return compileCallWorkflowDependenciesWithActionRef(ctx, workflowFile, verbose, quiet, engineOverride, "", force, tracker) -} - func compileCallWorkflowDependenciesWithActionRef(ctx context.Context, workflowFile string, verbose, quiet bool, engineOverride, actionRef string, force bool, tracker *FileTracker) error { return compileSafeOutputsWorkflowDependencies(ctx, workflowFile, "call-workflow worker", callWorkflowNamesForCompilation, compileDepsOptions{ verbose: verbose, quiet: quiet, engineOverride: engineOverride, actionRef: actionRef, force: force, propagateErrors: true, tracker: tracker, diff --git a/pkg/cli/file_tracker_test.go b/pkg/cli/file_tracker_test.go index 3494883ed1b..a7b0966f62e 100644 --- a/pkg/cli/file_tracker_test.go +++ b/pkg/cli/file_tracker_test.go @@ -298,7 +298,7 @@ This uses reaction. tracker := NewFileTracker() // Compile the workflow with tracking - if err := compileWorkflowWithTracking(context.Background(), workflowFileWithReaction, false, false, "", tracker); err != nil { + if err := compileWorkflowWithTrackingAndActionRef(context.Background(), workflowFileWithReaction, false, false, "", "", tracker); err != nil { t.Fatalf("Failed to compile workflow: %v", err) } @@ -340,7 +340,7 @@ This does NOT use ai-reaction. // (Note: Since reaction is now inline, this removal step is no longer needed) // Compile the workflow with tracking - if err := compileWorkflowWithTracking(context.Background(), workflowFileWithoutReaction, false, false, "", tracker2); err != nil { + if err := compileWorkflowWithTrackingAndActionRef(context.Background(), workflowFileWithoutReaction, false, false, "", "", tracker2); err != nil { t.Fatalf("Failed to compile workflow: %v", err) } diff --git a/pkg/cli/update_command_test.go b/pkg/cli/update_command_test.go index 5d82152839b..f1f14bb376a 100644 --- a/pkg/cli/update_command_test.go +++ b/pkg/cli/update_command_test.go @@ -1006,7 +1006,7 @@ This is a test workflow. // Test with refreshStopTime=false (should preserve existing stop time if lock exists) t.Run("compileWorkflowWithRefresh false", func(t *testing.T) { - err := compileWorkflowWithRefresh(context.Background(), workflowFile, false, false, "", false, false) + err := compileWorkflowWithRefreshAndActionRef(context.Background(), workflowFile, false, false, "", "", false, false) if err != nil { t.Logf("Compilation failed (expected in test environment): %v", err) // In a test environment without full setup, compilation may fail, @@ -1016,7 +1016,7 @@ This is a test workflow. // Test with refreshStopTime=true (should regenerate stop time) t.Run("compileWorkflowWithRefresh true", func(t *testing.T) { - err := compileWorkflowWithRefresh(context.Background(), workflowFile, false, false, "", true, false) + err := compileWorkflowWithRefreshAndActionRef(context.Background(), workflowFile, false, false, "", "", true, false) if err != nil { t.Logf("Compilation failed (expected in test environment): %v", err) // In a test environment without full setup, compilation may fail,