From b6db821cdedc46cc3f6b22eeacb28ee73f5b9786 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 Jan 2026 19:56:59 +0000 Subject: [PATCH 1/2] Initial plan From dd84e0dc67d952937ba14999f0572e5a94036ef9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 Jan 2026 20:15:45 +0000 Subject: [PATCH 2/2] Add compiler integration tests for invalid schedule validation - Add TestCompileWithInvalidSchedule: tests that invalid schedule strings fail compilation - Add TestCompileWithInvalidScheduleArrayFormat: tests invalid schedules in array format - Both tests verify compilation fails with appropriate error messages - Both tests verify no lock file is created on failure Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/compile_integration_test.go | 103 ++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/pkg/cli/compile_integration_test.go b/pkg/cli/compile_integration_test.go index 8801f7a4f3e..519fc75956c 100644 --- a/pkg/cli/compile_integration_test.go +++ b/pkg/cli/compile_integration_test.go @@ -698,3 +698,106 @@ This workflow tests fuzzy daily schedule compilation using array format with cro t.Logf("Integration test passed - successfully compiled fuzzy daily schedule (array format) to %s", lockFilePath) } + +// TestCompileWithInvalidSchedule tests that compilation fails with an invalid schedule string +func TestCompileWithInvalidSchedule(t *testing.T) { + setup := setupIntegrationTest(t) + defer setup.cleanup() + + // Create a test markdown workflow file with an invalid schedule + testWorkflow := `--- +name: Invalid Schedule Test +on: + schedule: invalid schedule format + workflow_dispatch: +permissions: + contents: read +engine: copilot +--- + +# Invalid Schedule Test + +This workflow tests that invalid schedule strings fail compilation. +` + + testWorkflowPath := filepath.Join(setup.workflowsDir, "invalid-schedule-test.md") + if err := os.WriteFile(testWorkflowPath, []byte(testWorkflow), 0644); err != nil { + t.Fatalf("Failed to write test workflow file: %v", err) + } + + // Run the compile command - expect it to fail + cmd := exec.Command(setup.binaryPath, "compile", testWorkflowPath) + output, err := cmd.CombinedOutput() + + // The command should fail with an error + if err == nil { + t.Fatalf("Expected compile to fail with invalid schedule, but it succeeded\nOutput: %s", string(output)) + } + + outputStr := string(output) + + // Verify the error message contains information about invalid schedule + if !strings.Contains(outputStr, "schedule") && !strings.Contains(outputStr, "trigger") { + t.Errorf("Expected error output to mention 'schedule' or 'trigger', got: %s", outputStr) + } + + // Verify no lock file was created + lockFilePath := filepath.Join(setup.workflowsDir, "invalid-schedule-test.lock.yml") + if _, err := os.Stat(lockFilePath); err == nil { + t.Errorf("Lock file should not be created for invalid workflow, but %s exists", lockFilePath) + } + + t.Logf("Integration test passed - invalid schedule correctly failed compilation\nOutput: %s", outputStr) +} + +// TestCompileWithInvalidScheduleArrayFormat tests that compilation fails with an invalid schedule in array format +func TestCompileWithInvalidScheduleArrayFormat(t *testing.T) { + setup := setupIntegrationTest(t) + defer setup.cleanup() + + // Create a test markdown workflow file with an invalid schedule in array format + testWorkflow := `--- +name: Invalid Schedule Array Format Test +on: + schedule: + - cron: totally invalid cron here + workflow_dispatch: +permissions: + contents: read +engine: copilot +--- + +# Invalid Schedule Array Format Test + +This workflow tests that invalid schedule strings in array format fail compilation. +` + + testWorkflowPath := filepath.Join(setup.workflowsDir, "invalid-schedule-array-test.md") + if err := os.WriteFile(testWorkflowPath, []byte(testWorkflow), 0644); err != nil { + t.Fatalf("Failed to write test workflow file: %v", err) + } + + // Run the compile command - expect it to fail + cmd := exec.Command(setup.binaryPath, "compile", testWorkflowPath) + output, err := cmd.CombinedOutput() + + // The command should fail with an error + if err == nil { + t.Fatalf("Expected compile to fail with invalid schedule, but it succeeded\nOutput: %s", string(output)) + } + + outputStr := string(output) + + // Verify the error message contains information about invalid schedule + if !strings.Contains(outputStr, "schedule") && !strings.Contains(outputStr, "cron") { + t.Errorf("Expected error output to mention 'schedule' or 'cron', got: %s", outputStr) + } + + // Verify no lock file was created + lockFilePath := filepath.Join(setup.workflowsDir, "invalid-schedule-array-test.lock.yml") + if _, err := os.Stat(lockFilePath); err == nil { + t.Errorf("Lock file should not be created for invalid workflow, but %s exists", lockFilePath) + } + + t.Logf("Integration test passed - invalid schedule in array format correctly failed compilation\nOutput: %s", outputStr) +}