MCPcopy Index your code
hub / github.com/github/gh-aw / compileWorkflowFile

Function compileWorkflowFile

pkg/cli/compile_workflow_processor.go:71–190  ·  view source on GitHub ↗

compileWorkflowFile compiles a single workflow file (not a campaign spec) Returns the workflow data, lock file path, validation result, and success status

(
	ctx context.Context,
	compiler *workflow.Compiler,
	resolvedFile string,
	opts compileWorkflowFileOptions,
)

Source from the content-addressed store, hash-verified

69// compileWorkflowFile compiles a single workflow file (not a campaign spec)
70// Returns the workflow data, lock file path, validation result, and success status
71func compileWorkflowFile(
72 ctx context.Context,
73 compiler *workflow.Compiler,
74 resolvedFile string,
75 opts compileWorkflowFileOptions,
76) compileWorkflowFileResult {
77 compileWorkflowProcessorLog.Printf("Processing workflow file: %s", resolvedFile)
78
79 result := compileWorkflowFileResult{
80 validationResult: ValidationResult{
81 Workflow: filepath.Base(resolvedFile),
82 Valid: true,
83 Errors: []CompileValidationError{},
84 Warnings: []CompileValidationError{},
85 },
86 success: false,
87 }
88
89 // Generate lock file name
90 lockFile := stringutil.MarkdownToLockFile(resolvedFile)
91 result.lockFile = lockFile
92
93 // Parse workflow file to get data
94 compileWorkflowProcessorLog.Printf("Parsing workflow file: %s", resolvedFile)
95
96 // Set workflow identifier for schedule scattering (use repository-relative path for stability)
97 relPath, err := getRepositoryRelativePath(resolvedFile)
98 if err != nil {
99 compileWorkflowProcessorLog.Printf("Warning: failed to get repository-relative path for %s: %v", resolvedFile, err)
100 // Fallback to basename if we can't get relative path
101 relPath = filepath.Base(resolvedFile)
102 }
103 compiler.SetWorkflowIdentifier(relPath)
104
105 // Set repository slug for this specific file (may differ from CWD's repo)
106 // Uses SetRepositorySlugIfUnlocked so that an explicit --schedule-seed flag is never overridden.
107 fileRepoSlug := getRepositorySlugFromRemoteForPath(resolvedFile)
108 if fileRepoSlug != "" {
109 if compiler.IsRepositorySlugLocked() {
110 compileWorkflowProcessorLog.Printf("Repository slug from file remote (%s) ignored: overridden via --schedule-seed (%s)", fileRepoSlug, compiler.GetRepositorySlug())
111 } else {
112 compiler.SetRepositorySlugIfUnlocked(fileRepoSlug)
113 compileWorkflowProcessorLog.Printf("Repository slug for file set: %s", fileRepoSlug)
114 }
115 }
116
117 // Parse the workflow
118 workflowData, err := compiler.ParseWorkflowFile(resolvedFile)
119 if err != nil {
120 // Check if this is a shared workflow (not an error, just info)
121 var sharedErr *workflow.SharedWorkflowError
122 if errors.As(err, &sharedErr) {
123 if !opts.jsonOutput {
124 // Print info message instead of error
125 fmt.Fprintln(os.Stderr, console.FormatInfoMessage(sharedErr.Error()))
126 }
127 // Mark as valid but skipped
128 result.validationResult.Valid = true

Callers 2

compileSpecificFilesFunction · 0.85

Calls 15

ErrorMethod · 0.95
ErrorMethod · 0.95
MarkdownToLockFileFunction · 0.92
FormatInfoMessageFunction · 0.92
appendValidationErrorsFunction · 0.85
extractSafeOutputLabelsFunction · 0.85
SetWorkflowIdentifierMethod · 0.80
GetRepositorySlugMethod · 0.80

Tested by

no test coverage detected