diff --git a/pkg/cli/add_command_test.go b/pkg/cli/add_command_test.go index ace8f0c3473..3c89bb34e1b 100644 --- a/pkg/cli/add_command_test.go +++ b/pkg/cli/add_command_test.go @@ -29,7 +29,7 @@ func TestNewAddCommand(t *testing.T) { // Check number flag numberFlag := flags.Lookup("number") assert.NotNil(t, numberFlag, "Should have 'number' flag") - assert.Equal(t, "c", numberFlag.Shorthand, "Number flag shorthand should be 'c'") + assert.Equal(t, "", numberFlag.Shorthand, "Number flag should not have shorthand (conflicts with logs -c)") // Check name flag nameFlag := flags.Lookup("name") diff --git a/pkg/cli/completions_test.go b/pkg/cli/completions_test.go index da7990f2d1d..ddb4e0b4ee3 100644 --- a/pkg/cli/completions_test.go +++ b/pkg/cli/completions_test.go @@ -747,8 +747,8 @@ func TestValidEngineNamesConsistency(t *testing.T) { thirdCall := ValidEngineNames() // Verify same length across calls - assert.Equal(t, len(firstCall), len(secondCall), "Engine names list length should be consistent") - assert.Equal(t, len(secondCall), len(thirdCall), "Engine names list length should be consistent") + assert.Len(t, secondCall, len(firstCall), "Engine names list length should be consistent") + assert.Len(t, thirdCall, len(secondCall), "Engine names list length should be consistent") // Verify all expected engines are present in all calls expectedEngines := []string{"copilot", "claude", "codex", "custom"} diff --git a/pkg/workflow/maintenance_workflow.go b/pkg/workflow/maintenance_workflow.go index 548b725eedf..58bebf183c4 100644 --- a/pkg/workflow/maintenance_workflow.go +++ b/pkg/workflow/maintenance_workflow.go @@ -11,33 +11,27 @@ import ( var maintenanceLog = logger.New("workflow:maintenance_workflow") -// generateMaintenanceCron generates a cron schedule based on the minimum expires value in hours +// generateMaintenanceCron generates a cron schedule based on the minimum expires value in days // Schedule runs at minimum required frequency to check expirations at appropriate intervals // Returns cron expression and description. -func generateMaintenanceCron(minExpiresHours int) (string, string) { +func generateMaintenanceCron(minExpiresDays int) (string, string) { // Use a pseudo-random but deterministic minute (37) to avoid load spikes at :00 minute := 37 - // Determine frequency based on minimum expires value (in hours) + // Determine frequency based on minimum expires value (in days) // Run at least as often as the shortest expiration would need - if minExpiresHours <= 2 { - // For 2 hours or less, run every hour - return fmt.Sprintf("%d * * * *", minute), "Every hour" - } else if minExpiresHours <= 4 { - // For 3-4 hours, run every 2 hours + if minExpiresDays <= 1 { + // For 1 day or less, run every 2 hours return fmt.Sprintf("%d */2 * * *", minute), "Every 2 hours" - } else if minExpiresHours <= 12 { - // For 5-12 hours, run every 4 hours - return fmt.Sprintf("%d */4 * * *", minute), "Every 4 hours" - } else if minExpiresHours <= 24 { - // For 13-24 hours, run every 6 hours + } else if minExpiresDays == 2 { + // For 2 days, run every 6 hours return fmt.Sprintf("%d */6 * * *", minute), "Every 6 hours" - } else if minExpiresHours <= 48 { - // For 25-48 hours, run every 12 hours + } else if minExpiresDays <= 4 { + // For 3-4 days, run every 12 hours return fmt.Sprintf("%d */12 * * *", minute), "Every 12 hours" } - // For more than 48 hours, run daily + // For more than 4 days, run daily return fmt.Sprintf("%d %d * * *", minute, 0), "Daily" } @@ -84,8 +78,14 @@ func GenerateMaintenanceWorkflow(workflowDataList []*WorkflowData, workflowDir s maintenanceLog.Printf("Generating maintenance workflow for expired discussions and issues (minimum expires: %d hours)", minExpires) + // Convert hours to days for cron schedule generation + minExpiresDays := minExpires / 24 + if minExpires%24 > 0 { + minExpiresDays++ // Round up partial days + } + // Generate cron schedule based on minimum expires value - cronSchedule, scheduleDesc := generateMaintenanceCron(minExpires) + cronSchedule, scheduleDesc := generateMaintenanceCron(minExpiresDays) maintenanceLog.Printf("Maintenance schedule: %s (%s)", cronSchedule, scheduleDesc) // Create the maintenance workflow content using strings.Builder @@ -109,7 +109,7 @@ Schedule frequency is automatically determined by the shortest expiration time.` on: schedule: - - cron: "` + cronSchedule + `" # ` + scheduleDesc + ` (based on minimum expires: ` + fmt.Sprintf("%d", minExpires) + ` hours) + - cron: "` + cronSchedule + `" # ` + scheduleDesc + ` (based on minimum expires: ` + fmt.Sprintf("%d", minExpiresDays) + ` days) workflow_dispatch: permissions: {} diff --git a/pkg/workflow/strict_mode_test.go b/pkg/workflow/strict_mode_test.go index 85381be8650..48f12c5f48e 100644 --- a/pkg/workflow/strict_mode_test.go +++ b/pkg/workflow/strict_mode_test.go @@ -154,6 +154,11 @@ engine: copilot on: push timeout-minutes: 10 engine: copilot +network: + allowed: + - "api.example.com" +tools: + github: false --- # Test Workflow`, diff --git a/pkg/workflow/workflow_run_validation_test.go b/pkg/workflow/workflow_run_validation_test.go index 2266b19c459..0b33bcbb23c 100644 --- a/pkg/workflow/workflow_run_validation_test.go +++ b/pkg/workflow/workflow_run_validation_test.go @@ -32,8 +32,7 @@ on: workflows: ["build"] types: [completed] tools: - github: - allowed: [list_issues] + github: false --- # Workflow Run Without Branches @@ -52,8 +51,7 @@ on: workflows: ["build"] types: [completed] tools: - github: - allowed: [list_issues] + github: false --- # Workflow Run Without Branches Strict @@ -75,8 +73,7 @@ on: - main - develop tools: - github: - allowed: [list_issues] + github: false --- # Workflow Run With Branches @@ -97,8 +94,7 @@ on: branches: - main tools: - github: - allowed: [list_issues] + github: false --- # Workflow Run With Branches Strict @@ -116,8 +112,7 @@ on: push: branches: [main] tools: - github: - allowed: [list_issues] + github: false --- # Push Workflow @@ -138,8 +133,7 @@ on: workflows: ["build"] types: [completed] tools: - github: - allowed: [list_issues] + github: false --- # Mixed Triggers @@ -159,8 +153,7 @@ on: types: [completed] branches: [] tools: - github: - allowed: [list_issues] + github: false --- # Workflow Run With Empty Branches @@ -227,8 +220,7 @@ func TestWorkflowRunBranchValidationEdgeCases(t *testing.T) { frontmatter: `--- on: push tools: - github: - allowed: [list_issues] + github: false --- # No On Field @@ -245,8 +237,7 @@ on: workflows: ["build", "test"] types: [completed] tools: - github: - allowed: [list_issues] + github: false --- # Multiple Workflows