From 8624d078121dfbe8cea04c16bb33d4216b5f8158 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 02:45:38 +0000 Subject: [PATCH 1/2] Initial plan From e68b7caa1dc61c5a4df993628640e2255d855b1f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 02:55:52 +0000 Subject: [PATCH 2/2] Add experimental warning for rate-limit feature - Add warning emission in compiler.go when rate-limit config is present - Create integration test to verify warning behavior - Test passes for all scenarios (with/without rate-limit config) - Warning displayed during compilation: "Using experimental feature: rate-limit" Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/workflow/compiler.go | 6 + .../rate_limit_experimental_warning_test.go | 153 ++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 pkg/workflow/rate_limit_experimental_warning_test.go diff --git a/pkg/workflow/compiler.go b/pkg/workflow/compiler.go index 9e1e3409db..85b716b600 100644 --- a/pkg/workflow/compiler.go +++ b/pkg/workflow/compiler.go @@ -222,6 +222,12 @@ func (c *Compiler) validateWorkflowData(workflowData *WorkflowData, markdownPath c.IncrementWarningCount() } + // Emit experimental warning for rate-limit feature + if workflowData.RateLimit != nil { + fmt.Fprintln(os.Stderr, console.FormatWarningMessage("Using experimental feature: rate-limit")) + c.IncrementWarningCount() + } + // Validate workflow_run triggers have branch restrictions log.Printf("Validating workflow_run triggers for branch restrictions") if err := c.validateWorkflowRunBranches(workflowData, markdownPath); err != nil { diff --git a/pkg/workflow/rate_limit_experimental_warning_test.go b/pkg/workflow/rate_limit_experimental_warning_test.go new file mode 100644 index 0000000000..11f295d5e1 --- /dev/null +++ b/pkg/workflow/rate_limit_experimental_warning_test.go @@ -0,0 +1,153 @@ +//go:build integration + +package workflow + +import ( + "bytes" + "io" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/github/gh-aw/pkg/testutil" +) + +// TestRateLimitExperimentalWarning tests that the rate-limit feature +// emits an experimental warning when enabled. +func TestRateLimitExperimentalWarning(t *testing.T) { + tests := []struct { + name string + content string + expectWarning bool + }{ + { + name: "rate-limit enabled produces experimental warning", + content: `--- +on: workflow_dispatch +engine: copilot +rate-limit: + max: 5 + window: 60 +permissions: + contents: read + issues: read + pull-requests: read +--- + +# Test Workflow +`, + expectWarning: true, + }, + { + name: "no rate-limit does not produce experimental warning", + content: `--- +on: workflow_dispatch +engine: copilot +permissions: + contents: read + issues: read + pull-requests: read +--- + +# Test Workflow +`, + expectWarning: false, + }, + { + name: "rate-limit with custom ignored roles produces experimental warning", + content: `--- +on: workflow_dispatch +engine: copilot +rate-limit: + max: 3 + window: 30 + ignored-roles: + - admin + - maintain +permissions: + contents: read + issues: read + pull-requests: read +--- + +# Test Workflow +`, + expectWarning: true, + }, + { + name: "rate-limit with events produces experimental warning", + content: `--- +on: + workflow_dispatch: + issue_comment: + types: [created] +engine: copilot +rate-limit: + max: 5 + window: 60 + events: [workflow_dispatch, issue_comment] +permissions: + contents: read + issues: read + pull-requests: read +--- + +# Test Workflow +`, + expectWarning: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tmpDir := testutil.TempDir(t, "rate-limit-experimental-warning-test") + + testFile := filepath.Join(tmpDir, "test-workflow.md") + if err := os.WriteFile(testFile, []byte(tt.content), 0644); err != nil { + t.Fatal(err) + } + + // Capture stderr to check for warnings + oldStderr := os.Stderr + r, w, _ := os.Pipe() + os.Stderr = w + + compiler := NewCompiler() + compiler.SetStrictMode(false) + err := compiler.CompileWorkflow(testFile) + + // Restore stderr + w.Close() + os.Stderr = oldStderr + var buf bytes.Buffer + io.Copy(&buf, r) + stderrOutput := buf.String() + + if err != nil { + t.Errorf("Expected compilation to succeed but it failed: %v", err) + return + } + + expectedMessage := "Using experimental feature: rate-limit" + + if tt.expectWarning { + if !strings.Contains(stderrOutput, expectedMessage) { + t.Errorf("Expected warning containing '%s', got stderr:\n%s", expectedMessage, stderrOutput) + } + } else { + if strings.Contains(stderrOutput, expectedMessage) { + t.Errorf("Did not expect warning '%s', but got stderr:\n%s", expectedMessage, stderrOutput) + } + } + + // Verify warning count includes rate-limit warning + if tt.expectWarning { + warningCount := compiler.GetWarningCount() + if warningCount == 0 { + t.Error("Expected warning count > 0 but got 0") + } + } + }) + } +}