From 55b2e41882771e6ccd6ca7f9241724f468332892 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 30 May 2026 16:49:38 +0000 Subject: [PATCH 1/3] Initial plan From abe262749dcd49c7e790baec1e702691f194bd59 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 30 May 2026 17:01:20 +0000 Subject: [PATCH 2/3] Handle on.needs as processed on-section field Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com> --- pkg/workflow/compiler_draft_test.go | 32 +++++++++++++++++++++ pkg/workflow/frontmatter_extraction_yaml.go | 28 +++++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/pkg/workflow/compiler_draft_test.go b/pkg/workflow/compiler_draft_test.go index 1bf5d9b88e2..57d956fd9d7 100644 --- a/pkg/workflow/compiler_draft_test.go +++ b/pkg/workflow/compiler_draft_test.go @@ -352,6 +352,38 @@ func TestCommentOutProcessedFieldsInOnSection(t *testing.T) { workflow_dispatch:`, description: "Should reset workflow_run conclusion tracker when entering a new event section", }, + { + name: "top-level on needs array", + input: `on: + needs: + - study_repo + schedule: + - cron: "23 * * * *" + workflow_dispatch:`, + expected: `on: + # needs: # Needs processed as dependency in pre-activation job + # - study_repo # Needs processed as dependency in pre-activation job + schedule: + - cron: "23 * * * *" + workflow_dispatch:`, + description: "Should comment out needs in on section after compiler processing", + }, + { + name: "top-level on needs array with compact list indentation", + input: `on: + needs: + - study_repo + schedule: + - cron: "23 * * * *" + workflow_dispatch:`, + expected: `on: + # needs: # Needs processed as dependency in pre-activation job + # - study_repo # Needs processed as dependency in pre-activation job + schedule: + - cron: "23 * * * *" + workflow_dispatch:`, + description: "Should comment out needs list items when emitted with compact indentation", + }, { name: "issues with two-space indentation names", input: `on: diff --git a/pkg/workflow/frontmatter_extraction_yaml.go b/pkg/workflow/frontmatter_extraction_yaml.go index e55fc844559..bfdbd76b1a4 100644 --- a/pkg/workflow/frontmatter_extraction_yaml.go +++ b/pkg/workflow/frontmatter_extraction_yaml.go @@ -101,7 +101,7 @@ func (c *Compiler) extractTopLevelYAMLSection(frontmatter map[string]any, key st return yamlStr } -// commentOutProcessedFieldsInOnSection comments out draft, fork, forks, names, labels, manual-approval, stop-after, skip-if-match, skip-if-no-match, skip-roles, reaction, lock-for-agent, steps, permissions, and stale-check fields in the on section +// commentOutProcessedFieldsInOnSection comments out draft, fork, forks, names, labels, manual-approval, stop-after, skip-if-match, skip-if-no-match, skip-roles, reaction, lock-for-agent, steps, permissions, needs, and stale-check fields in the on section // These fields are processed separately and should be commented for documentation // Exception: names fields in sections with __gh_aw_native_label_filter__ marker in frontmatter are NOT commented out func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmatter map[string]any) string { @@ -145,6 +145,7 @@ func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmat inRolesArray := false inBotsArray := false inLabelsArray := false + inNeedsArray := false inGitHubApp := false inOnSteps := false inOnPermissions := false @@ -300,6 +301,13 @@ func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmat inLabelsArray = true } + // Check if we're entering needs array + if !inPullRequest && !inIssues && !inDiscussion && !inIssueComment && + !inOnSteps && !inOnPermissions && + lineIndent == 2 && strings.HasPrefix(trimmedLine, "needs:") { + inNeedsArray = true + } + // Check if we're entering on.steps array if !inPullRequest && !inIssues && !inDiscussion && !inIssueComment && strings.HasPrefix(trimmedLine, "steps:") { inOnSteps = true @@ -482,6 +490,17 @@ func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmat } } + // Check if we're leaving the needs array by encountering another top-level field + if inNeedsArray && strings.TrimSpace(line) != "" { + // Get the indentation of the current line + lineIndent := len(line) - len(strings.TrimLeft(line, " \t")) + + // If this is a non-dash line at the same level as needs (2 spaces), we're out of the array + if lineIndent == 2 && !strings.HasPrefix(trimmedLine, "-") && !strings.HasPrefix(trimmedLine, "needs:") && !strings.HasPrefix(trimmedLine, "#") { + inNeedsArray = false + } + } + // Check if we're leaving the on.steps array by encountering another top-level field if inOnSteps && strings.TrimSpace(line) != "" { lineIndent := len(line) - len(strings.TrimLeft(line, " \t")) @@ -575,6 +594,13 @@ func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmat // Comment out array items in labels shouldComment = true commentReason = " # Label filtering applied via job conditions" + } else if !inOnSteps && !inOnPermissions && lineIndent == 2 && strings.HasPrefix(trimmedLine, "needs:") { + shouldComment = true + commentReason = " # Needs processed as dependency in pre-activation job" + } else if inNeedsArray && strings.HasPrefix(trimmedLine, "-") { + // Comment out array items in needs + shouldComment = true + commentReason = " # Needs processed as dependency in pre-activation job" } else if strings.HasPrefix(trimmedLine, "steps:") { shouldComment = true commentReason = " # Steps injected into pre-activation job" From 57a16f029248b7b4c271e1133dd15893bd97a45f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 30 May 2026 17:35:54 +0000 Subject: [PATCH 3/3] Add inline needs regression test Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/workflow/compiler_draft_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/workflow/compiler_draft_test.go b/pkg/workflow/compiler_draft_test.go index 57d956fd9d7..0ac12a2d53c 100644 --- a/pkg/workflow/compiler_draft_test.go +++ b/pkg/workflow/compiler_draft_test.go @@ -384,6 +384,20 @@ func TestCommentOutProcessedFieldsInOnSection(t *testing.T) { workflow_dispatch:`, description: "Should comment out needs list items when emitted with compact indentation", }, + { + name: "top-level on needs inline array", + input: `on: + needs: [study_repo, setup] + schedule: + - cron: "23 * * * *" + workflow_dispatch:`, + expected: `on: + # needs: [study_repo, setup] # Needs processed as dependency in pre-activation job + schedule: + - cron: "23 * * * *" + workflow_dispatch:`, + description: "Should comment out needs when emitted as an inline YAML array", + }, { name: "issues with two-space indentation names", input: `on: