Skip to content

Commit a2d5d22

Browse files
Enhance workflow and job management logging (#3946)
1 parent 1ecbb88 commit a2d5d22

4 files changed

Lines changed: 14 additions & 0 deletions

File tree

pkg/workflow/filters.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ func (c *Compiler) applyPullRequestForkFilter(data *WorkflowData, frontmatter ma
149149
// If "*" wildcard is present, skip fork filtering (allow all forks)
150150
for _, pattern := range allowedForks {
151151
if pattern == "*" {
152+
filtersLog.Print("Wildcard fork pattern detected, allowing all forks")
152153
return // No fork filtering needed
153154
}
154155
}
@@ -368,6 +369,7 @@ func (c *Compiler) applyLabelFilter(data *WorkflowData, frontmatter map[string]a
368369

369370
// If we have label conditions, combine them and apply to the workflow
370371
if len(labelConditions) > 0 {
372+
filtersLog.Printf("Applying label name filters: %d conditions found", len(labelConditions))
371373
var finalCondition ConditionNode
372374
if len(labelConditions) == 1 {
373375
finalCondition = labelConditions[0]

pkg/workflow/jobs.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ func (jm *JobManager) ValidateDependencies() error {
101101

102102
// detectCycles uses DFS to detect cycles in the job dependency graph
103103
func (jm *JobManager) detectCycles() error {
104+
jobLog.Print("Detecting cycles in job dependency graph")
104105
// Track visit states: 0=unvisited, 1=visiting, 2=visited
105106
visitState := make(map[string]int)
106107

@@ -118,6 +119,7 @@ func (jm *JobManager) detectCycles() error {
118119
}
119120
}
120121

122+
jobLog.Print("No cycles detected in job dependencies")
121123
return nil
122124
}
123125

@@ -145,6 +147,7 @@ func (jm *JobManager) dfsVisit(jobName string, visitState map[string]int) error
145147

146148
// RenderToYAML generates the jobs section of a GitHub Actions workflow
147149
func (jm *JobManager) RenderToYAML() string {
150+
jobLog.Printf("Rendering %d jobs to YAML", len(jm.jobs))
148151
if len(jm.jobs) == 0 {
149152
return "jobs:\n"
150153
}
@@ -341,6 +344,7 @@ func (jm *JobManager) renderJob(job *Job) string {
341344

342345
// GetTopologicalOrder returns jobs in topological order (dependencies before dependents)
343346
func (jm *JobManager) GetTopologicalOrder() ([]string, error) {
347+
jobLog.Printf("Computing topological order for %d jobs", len(jm.jobs))
344348
// First validate dependencies to ensure no cycles
345349
if err := jm.ValidateDependencies(); err != nil {
346350
return nil, err

pkg/workflow/runtime_setup.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ func DetectRuntimeRequirements(workflowData *WorkflowData) []RuntimeRequirement
226226

227227
// detectFromCustomSteps scans custom steps YAML for runtime commands
228228
func detectFromCustomSteps(customSteps string, requirements map[string]*RuntimeRequirement) {
229+
log.Print("Scanning custom steps for runtime commands")
229230
lines := strings.Split(customSteps, "\n")
230231
for _, line := range lines {
231232
// Look for run: commands
@@ -277,6 +278,7 @@ func detectRuntimeFromCommand(cmdLine string, requirements map[string]*RuntimeRe
277278

278279
// detectFromMCPConfigs scans MCP server configurations for runtime commands
279280
func detectFromMCPConfigs(tools map[string]any, requirements map[string]*RuntimeRequirement) {
281+
log.Printf("Scanning %d MCP configurations for runtime commands", len(tools))
280282
for _, tool := range tools {
281283
// Handle structured MCP config with command field
282284
if toolMap, ok := tool.(map[string]any); ok {
@@ -369,6 +371,7 @@ func GenerateRuntimeSetupSteps(requirements []RuntimeRequirement) []GitHubAction
369371

370372
// generateSetupStep creates a setup step for a given runtime
371373
func generateSetupStep(runtime *Runtime, version string) GitHubActionStep {
374+
log.Printf("Generating setup step for runtime: %s, version=%s", runtime.ID, version)
372375
// Use default version if none specified
373376
if version == "" {
374377
version = runtime.DefaultVersion
@@ -426,6 +429,7 @@ func ShouldSkipRuntimeSetup(workflowData *WorkflowData) bool {
426429

427430
// applyRuntimeOverrides applies runtime version overrides from frontmatter
428431
func applyRuntimeOverrides(runtimes map[string]any, requirements map[string]*RuntimeRequirement) {
432+
log.Printf("Applying runtime overrides for %d configured runtimes", len(runtimes))
429433
for runtimeID, configAny := range runtimes {
430434
// Parse runtime configuration
431435
configMap, ok := configAny.(map[string]any)

pkg/workflow/template.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,19 @@ func wrapExpressionsInTemplateConditionals(markdown string) string {
3232
// Check if expression is already wrapped in ${{ ... }}
3333
// Look for the pattern starting with "${{"
3434
if strings.HasPrefix(expr, "${{") {
35+
templateLog.Print("Expression already wrapped, skipping")
3536
return match // Already wrapped, return as-is
3637
}
3738

3839
// Check if expression is an environment variable reference (starts with ${)
3940
// These don't need ${{ }} wrapping as they're already evaluated
4041
if strings.HasPrefix(expr, "${") {
42+
templateLog.Print("Environment variable reference detected, skipping wrap")
4143
return match // Environment variable reference, return as-is
4244
}
4345

4446
// Always wrap expressions that don't start with ${{ or ${
47+
templateLog.Printf("Wrapping expression: %s", expr)
4548
return "{{#if ${{ " + expr + " }} }}"
4649
})
4750

@@ -73,6 +76,7 @@ func (c *Compiler) generateInterpolationAndTemplateStep(yaml *strings.Builder, e
7376

7477
// Skip if neither interpolation nor template rendering is needed
7578
if !hasExpressions && !hasTemplates {
79+
templateLog.Print("No interpolation or template rendering needed, skipping step generation")
7680
return
7781
}
7882

0 commit comments

Comments
 (0)