Skip to content

Commit 4f77f95

Browse files
authored
Fix expression errors in issue-monster workflow by adding direct job dependencies (#5960)
1 parent a085621 commit 4f77f95

10 files changed

Lines changed: 93 additions & 9 deletions

.github/workflows/changeset.lock.yml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/craft.lock.yml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/daily-team-status.lock.yml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/issue-monster.lock.yml

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/issue-monster.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ tools:
2121
github:
2222
toolsets: [default, pull_requests]
2323

24+
if: needs.search_issues.outputs.has_issues == 'true'
25+
2426
jobs:
2527
search_issues:
2628
needs: ["pre_activation"]
@@ -79,8 +81,6 @@ jobs:
7981
core.setOutput('has_issues', 'false');
8082
}
8183
82-
if: needs.search_issues.outputs.has_issues == 'true'
83-
8484
safe-outputs:
8585
assign-to-agent:
8686
max: 3

.github/workflows/layout-spec-maintainer.lock.yml

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/mergefest.lock.yml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/poem-bot.lock.yml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/tidy.lock.yml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/workflow/compiler_jobs.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,25 @@ func (c *Compiler) getCustomJobsDependingOnPreActivation(customJobs map[string]a
9494
return jobNames
9595
}
9696

97+
// getReferencedCustomJobs returns custom job names that are referenced in the given content.
98+
// It looks for patterns like "needs.<jobName>." or "${{ needs.<jobName>." in the content.
99+
func (c *Compiler) getReferencedCustomJobs(content string, customJobs map[string]any) []string {
100+
if content == "" || customJobs == nil {
101+
return nil
102+
}
103+
var referencedJobs []string
104+
for jobName := range customJobs {
105+
// Check for patterns like "needs.job_name." which covers:
106+
// - needs.job_name.outputs.X
107+
// - ${{ needs.job_name.outputs.X }}
108+
// - needs.job_name.result
109+
if strings.Contains(content, fmt.Sprintf("needs.%s.", jobName)) {
110+
referencedJobs = append(referencedJobs, jobName)
111+
}
112+
}
113+
return referencedJobs
114+
}
115+
97116
// buildJobs creates all jobs for the workflow and adds them to the job manager
98117
func (c *Compiler) buildJobs(data *WorkflowData, markdownPath string) error {
99118
compilerJobsLog.Printf("Building jobs for workflow: %s", markdownPath)
@@ -1144,6 +1163,27 @@ func (c *Compiler) buildMainJob(data *WorkflowData, activationJobCreated bool) (
11441163
}
11451164
}
11461165

1166+
// IMPORTANT: Even though jobs that depend on pre_activation are transitively accessible
1167+
// through the activation job, if the workflow content directly references their outputs
1168+
// (e.g., ${{ needs.search_issues.outputs.* }}), we MUST add them as direct dependencies.
1169+
// This is required for GitHub Actions expression evaluation and actionlint validation.
1170+
referencedJobs := c.getReferencedCustomJobs(data.MarkdownContent, data.Jobs)
1171+
for _, jobName := range referencedJobs {
1172+
// Check if this job is already in depends
1173+
alreadyDepends := false
1174+
for _, dep := range depends {
1175+
if dep == jobName {
1176+
alreadyDepends = true
1177+
break
1178+
}
1179+
}
1180+
// Add it if not already present
1181+
if !alreadyDepends {
1182+
depends = append(depends, jobName)
1183+
compilerJobsLog.Printf("Added direct dependency on custom job '%s' because it's referenced in workflow content", jobName)
1184+
}
1185+
}
1186+
11471187
// Build outputs for all engines (GH_AW_SAFE_OUTPUTS functionality)
11481188
// Build job outputs
11491189
// Always include model output for reuse in other jobs

0 commit comments

Comments
 (0)