From 7aeefb356a82e8b6336b67d06eb7bd9cb84f0497 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 23 Mar 2026 03:24:42 +0000 Subject: [PATCH 1/3] test(add_labels): add tests for staged mode, blocked patterns, and filtered labels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add test for staged mode preview without calling API - Add test that staged calls count toward processedCount limit - Add test for blocked pattern filtering (removes matching labels) - Add test for when all labels are filtered out by allowed list (succeeds with empty labelsAdded) Total: 25 → 29 tests for add_labels handler Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- actions/setup/js/add_labels.test.cjs | 81 ++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/actions/setup/js/add_labels.test.cjs b/actions/setup/js/add_labels.test.cjs index 3a233e043d7..c1f0e5bde2e 100644 --- a/actions/setup/js/add_labels.test.cjs +++ b/actions/setup/js/add_labels.test.cjs @@ -569,5 +569,86 @@ describe("add_labels", () => { expect(result.number).toBe(99); expect(addLabelsCalls[0].issue_number).toBe(99); }); + + it("should preview labels in staged mode without calling API", async () => { + const handler = await main({ max: 10, staged: true }); + const addLabelsCalls = []; + + mockGithub.rest.issues.addLabels = async params => { + addLabelsCalls.push(params); + return {}; + }; + + const result = await handler( + { + item_number: 100, + labels: ["bug", "enhancement"], + }, + {} + ); + + expect(result.success).toBe(true); + expect(result.staged).toBe(true); + expect(result.previewInfo).toBeDefined(); + expect(result.previewInfo.number).toBe(100); + expect(result.previewInfo.labels).toEqual(["bug", "enhancement"]); + expect(addLabelsCalls.length).toBe(0); + }); + + it("should count staged calls toward processedCount", async () => { + const handler = await main({ max: 1, staged: true }); + + const result1 = await handler({ item_number: 1, labels: ["bug"] }, {}); + expect(result1.success).toBe(true); + expect(result1.staged).toBe(true); + + const result2 = await handler({ item_number: 2, labels: ["enhancement"] }, {}); + expect(result2.success).toBe(false); + expect(result2.error).toContain("Max count"); + }); + + it("should filter out labels matching blocked patterns", async () => { + const handler = await main({ + max: 10, + blocked: ["internal-*", "~*"], + }); + const addLabelsCalls = []; + + mockGithub.rest.issues.addLabels = async params => { + addLabelsCalls.push(params); + return {}; + }; + + const result = await handler( + { + item_number: 100, + labels: ["bug", "internal-only", "~secret", "enhancement"], + }, + {} + ); + + expect(result.success).toBe(true); + expect(result.labelsAdded).toEqual(["bug", "enhancement"]); + expect(addLabelsCalls[0].labels).toEqual(["bug", "enhancement"]); + }); + + it("should succeed with empty labelsAdded when all labels filtered by allowed list", async () => { + const handler = await main({ + max: 10, + allowed: ["bug", "enhancement"], + }); + + const result = await handler( + { + item_number: 100, + labels: ["documentation", "invalid-label"], + }, + {} + ); + + expect(result.success).toBe(true); + expect(result.labelsAdded).toEqual([]); + expect(result.message).toContain("No valid labels"); + }); }); }); From fd58d1d33092d6ce78dc5dd25ab8482b86170a6c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Mar 2026 03:53:31 +0000 Subject: [PATCH 2/3] fix: set item_number required=true for label trigger workflow_dispatch inputs Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/gh-aw/sessions/3ead85d8-c115-425f-88b4-18f27175e720 --- .github/workflows/refiner.lock.yml | 3 +-- pkg/workflow/label_trigger_parser.go | 8 +++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/refiner.lock.yml b/.github/workflows/refiner.lock.yml index 3fcd67a7b03..cb8a1743b61 100644 --- a/.github/workflows/refiner.lock.yml +++ b/.github/workflows/refiner.lock.yml @@ -34,9 +34,8 @@ name: "Code Refiner" workflow_dispatch: inputs: item_number: - default: "" description: The number of the pull request - required: false + required: true type: string permissions: {} diff --git a/pkg/workflow/label_trigger_parser.go b/pkg/workflow/label_trigger_parser.go index 24a6fcaa470..7cda5c92986 100644 --- a/pkg/workflow/label_trigger_parser.go +++ b/pkg/workflow/label_trigger_parser.go @@ -117,15 +117,13 @@ func expandLabelTriggerShorthand(entityType string, labelNames []string) map[str } triggerConfig["names"] = namesAny - // Create workflow_dispatch with item_number input (not required so the workflow can be - // triggered manually without providing a value; the activation job will fall back to - // the event payload when item_number is not supplied). + // Create workflow_dispatch with item_number input (required so that the workflow can be + // triggered manually with a specific item number). workflowDispatchConfig := map[string]any{ "inputs": map[string]any{ "item_number": map[string]any{ "description": "The number of the " + getItemTypeName(entityType), - "required": false, - "default": "", + "required": true, "type": "string", }, }, From 62acaad6f13e220e4c4163bf770f273594852b21 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Mar 2026 04:06:06 +0000 Subject: [PATCH 3/3] fix: correct TestLabelTriggerIntegrationSimple to expect required=false for item_number input Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/gh-aw/sessions/531637cf-d8c8-415b-8b02-277e0e917422 --- .github/workflows/refiner.lock.yml | 3 ++- pkg/workflow/label_trigger_integration_test.go | 4 ++-- pkg/workflow/label_trigger_parser.go | 8 +++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/refiner.lock.yml b/.github/workflows/refiner.lock.yml index cb8a1743b61..3fcd67a7b03 100644 --- a/.github/workflows/refiner.lock.yml +++ b/.github/workflows/refiner.lock.yml @@ -34,8 +34,9 @@ name: "Code Refiner" workflow_dispatch: inputs: item_number: + default: "" description: The number of the pull request - required: true + required: false type: string permissions: {} diff --git a/pkg/workflow/label_trigger_integration_test.go b/pkg/workflow/label_trigger_integration_test.go index cadb73df47d..549a0d2c6d6 100644 --- a/pkg/workflow/label_trigger_integration_test.go +++ b/pkg/workflow/label_trigger_integration_test.go @@ -88,8 +88,8 @@ func TestLabelTriggerIntegrationSimple(t *testing.T) { } required, ok := itemNumber["required"].(bool) - if !ok || !required { - t.Errorf("item_number.required = %v, want true", required) + if !ok || required { + t.Errorf("item_number.required = %v, want false", required) } } diff --git a/pkg/workflow/label_trigger_parser.go b/pkg/workflow/label_trigger_parser.go index 7cda5c92986..24a6fcaa470 100644 --- a/pkg/workflow/label_trigger_parser.go +++ b/pkg/workflow/label_trigger_parser.go @@ -117,13 +117,15 @@ func expandLabelTriggerShorthand(entityType string, labelNames []string) map[str } triggerConfig["names"] = namesAny - // Create workflow_dispatch with item_number input (required so that the workflow can be - // triggered manually with a specific item number). + // Create workflow_dispatch with item_number input (not required so the workflow can be + // triggered manually without providing a value; the activation job will fall back to + // the event payload when item_number is not supplied). workflowDispatchConfig := map[string]any{ "inputs": map[string]any{ "item_number": map[string]any{ "description": "The number of the " + getItemTypeName(entityType), - "required": true, + "required": false, + "default": "", "type": "string", }, },