-
Notifications
You must be signed in to change notification settings - Fork 317
fix: trial command missing remote dependency fetching for imports #23165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bb7b7b8
3e7d941
bb013a0
616e8b8
9837664
ef2dda4
c8d8c72
0cc8f15
c877da6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -442,3 +442,46 @@ func fetchAndSaveRemoteIncludes(content string, spec *WorkflowSpec, targetDir st | |
|
|
||
| return nil | ||
| } | ||
|
|
||
| // fetchAllRemoteDependencies fetches all remote dependencies for a workflow: | ||
| // includes (@include directives), frontmatter imports, dispatch workflows, and resources. | ||
| // This is the single entry point shared by both the add and trial commands. | ||
| // | ||
| // Error handling is intentionally asymmetric: | ||
| // - @include and frontmatter import errors are best-effort: failures emit a warning when | ||
| // verbose is true but do not stop the overall operation. | ||
| // - Dispatch-workflow and resource errors are fatal and are returned to the caller. | ||
| func fetchAllRemoteDependencies(ctx context.Context, content string, spec *WorkflowSpec, targetDir string, verbose bool, force bool, tracker *FileTracker) error { | ||
| // Fetch and save @include directive dependencies (best-effort: errors are not fatal). | ||
| if err := fetchAndSaveRemoteIncludes(content, spec, targetDir, verbose, force, tracker); err != nil { | ||
| if verbose { | ||
| fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to fetch include dependencies: %v", err))) | ||
| } | ||
| } | ||
| // Fetch and save frontmatter 'imports:' dependencies so they are available | ||
| // locally during compilation. Keeping these as relative paths (not workflowspecs) | ||
| // ensures the compiler resolves them from disk rather than downloading from GitHub. | ||
| // Best-effort: errors are not fatal. | ||
| if err := fetchAndSaveRemoteFrontmatterImports(content, spec, targetDir, verbose, force, tracker); err != nil { | ||
| if verbose { | ||
| fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to fetch frontmatter import dependencies: %v", err))) | ||
| } | ||
| } | ||
| // Fetch and save workflows referenced in safe-outputs.dispatch-workflow so they are | ||
| // available locally. Workflow names using GitHub Actions expression syntax are skipped. | ||
| if err := fetchAndSaveRemoteDispatchWorkflows(ctx, content, spec, targetDir, verbose, force, tracker); err != nil { | ||
| if verbose { | ||
| fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to fetch dispatch workflow dependencies: %v", err))) | ||
| } | ||
| return fmt.Errorf("failed to fetch dispatch workflow dependencies: %w", err) | ||
| } | ||
| // Fetch files listed in the 'resources:' frontmatter field (additional workflow or | ||
| // action files that should be present alongside this workflow). | ||
| if err := fetchAndSaveRemoteResources(content, spec, targetDir, verbose, force, tracker); err != nil { | ||
| if verbose { | ||
| fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to fetch resource dependencies: %v", err))) | ||
| } | ||
| return fmt.Errorf("failed to fetch resource dependencies: %w", err) | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function provides a clean, unified entry point for all remote dependency fetching. Smoke test review comment — Run 23617381060. |
||
| return nil | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -277,12 +277,10 @@ func installWorkflowInTrialMode(ctx context.Context, tempDir string, parsedSpec | |
| } | ||
| } | ||
|
|
||
| // Fetch and save include dependencies for remote workflows | ||
| // Fetch and save all remote dependencies (includes, imports, dispatch workflows, resources) | ||
| if !fetched.IsLocal { | ||
| if err := fetchAndSaveRemoteIncludes(string(content), parsedSpec, result.WorkflowsDir, opts.Verbose, true, nil); err != nil { | ||
| if opts.Verbose { | ||
| fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to fetch include dependencies: %v", err))) | ||
| } | ||
| if err := fetchAllRemoteDependencies(ctx, string(content), parsedSpec, result.WorkflowsDir, opts.Verbose, true, nil); err != nil { | ||
| return fmt.Errorf("failed to fetch remote dependencies: %w", err) | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good refactor — using |
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring says this function “fetches all remote dependencies”, but the implementation intentionally swallows errors from includes and frontmatter imports (only emitting a warning when verbose). This mismatch can confuse callers (e.g., trial wraps the returned error as if all dependency fetch failures would surface). Either update the comment/name to make the best-effort semantics explicit, or change the function to propagate/aggregate include/import errors when they occur.