diff --git a/pkg/cli/compile_maintenance_test.go b/pkg/cli/compile_maintenance_test.go index 8da2f28931d..c49434d8ba3 100644 --- a/pkg/cli/compile_maintenance_test.go +++ b/pkg/cli/compile_maintenance_test.go @@ -141,6 +141,7 @@ engine: copilot safe-outputs: create-issue: max: 1 + noop: false --- Test workflow that creates issues without expiration. diff --git a/pkg/workflow/maintenance_workflow.go b/pkg/workflow/maintenance_workflow.go index 644ac7e955f..3a9848c6d7e 100644 --- a/pkg/workflow/maintenance_workflow.go +++ b/pkg/workflow/maintenance_workflow.go @@ -122,8 +122,14 @@ type GenerateMaintenanceWorkflowOptions struct { RepoSlug string } +const defaultNoOpIssueExpirationHours = 24 * 30 + +func isNoOpReportAsIssueEnabled(reportAsIssue *string) bool { + return reportAsIssue == nil || !strings.EqualFold(strings.TrimSpace(*reportAsIssue), "false") +} + // GenerateMaintenanceWorkflow generates the agentics-maintenance.yml workflow -// if any workflows use the expires field for discussions or issues. +// if any workflows use expiring safe outputs or noop issue reporting. // When opts.RepoConfig is non-nil and opts.RepoConfig.MaintenanceDisabled is true the // maintenance workflow is deleted and the function returns immediately. // opts.RepoSlug is the owner/repo slug used to determine the default branch for the push @@ -343,6 +349,17 @@ func scanWorkflowsForExpires(workflowDataList []*WorkflowData) (bool, int) { } } } + // Check for no-op runs issue expiration (runtime defaults to 30 days) + if workflowData.SafeOutputs.NoOp != nil { + if isNoOpReportAsIssueEnabled(workflowData.SafeOutputs.NoOp.ReportAsIssue) { + hasExpires = true + expires := defaultNoOpIssueExpirationHours + maintenanceLog.Printf("Workflow %s has no-op report-as-issue enabled, using %d-hour no-op issue expiration", workflowData.Name, expires) + if minExpires == 0 || expires < minExpires { + minExpires = expires + } + } + } } return hasExpires, minExpires diff --git a/pkg/workflow/maintenance_workflow_test.go b/pkg/workflow/maintenance_workflow_test.go index 66de6989e39..5c3beac7d44 100644 --- a/pkg/workflow/maintenance_workflow_test.go +++ b/pkg/workflow/maintenance_workflow_test.go @@ -145,6 +145,49 @@ func TestGenerateMaintenanceWorkflow_WithExpires(t *testing.T) { expectWorkflowGenerated: true, expectError: false, }, + { + name: "with noop report-as-issue default - should generate workflow", + workflowDataList: []*WorkflowData{ + { + Name: "noop-default-workflow", + SafeOutputs: &SafeOutputsConfig{ + NoOp: &NoOpConfig{}, + }, + }, + }, + expectWorkflowGenerated: true, + expectError: false, + }, + { + name: "with noop report-as-issue false - should NOT generate workflow", + workflowDataList: []*WorkflowData{ + { + Name: "noop-disabled-report-workflow", + SafeOutputs: &SafeOutputsConfig{ + NoOp: &NoOpConfig{ + ReportAsIssue: strPtr("false"), + }, + }, + }, + }, + expectWorkflowGenerated: false, + expectError: false, + }, + { + name: "with noop report-as-issue true - should generate workflow", + workflowDataList: []*WorkflowData{ + { + Name: "noop-explicit-report-workflow", + SafeOutputs: &SafeOutputsConfig{ + NoOp: &NoOpConfig{ + ReportAsIssue: strPtr("true"), + }, + }, + }, + }, + expectWorkflowGenerated: true, + expectError: false, + }, } for _, tt := range tests {