diff --git a/dotnet/test/Harness/E2ETestContext.cs b/dotnet/test/Harness/E2ETestContext.cs index 00fc32075..62acd580f 100644 --- a/dotnet/test/Harness/E2ETestContext.cs +++ b/dotnet/test/Harness/E2ETestContext.cs @@ -94,13 +94,13 @@ public IReadOnlyDictionary GetEnvironment() Cwd = WorkDir, CliPath = GetCliPath(_repoRoot), Environment = GetEnvironment(), - GitHubToken = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("CI")) ? "fake-token-for-e2e-tests" : null, + GitHubToken = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("GITHUB_ACTIONS")) ? "fake-token-for-e2e-tests" : null, }); public async ValueTask DisposeAsync() { // Skip writing snapshots in CI to avoid corrupting them on test failures - var isCI = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("CI")); + var isCI = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("GITHUB_ACTIONS")); await _proxy.StopAsync(skipWritingCache: isCI); try { if (Directory.Exists(HomeDir)) Directory.Delete(HomeDir, true); } catch { } diff --git a/go/internal/e2e/testharness/context.go b/go/internal/e2e/testharness/context.go index cefb87b58..b9edab1e5 100644 --- a/go/internal/e2e/testharness/context.go +++ b/go/internal/e2e/testharness/context.go @@ -166,7 +166,7 @@ func (c *TestContext) NewClient() *copilot.Client { } // Use fake token in CI to allow cached responses without real auth - if os.Getenv("CI") == "true" { + if os.Getenv("GITHUB_ACTIONS") == "true" { options.GitHubToken = "fake-token-for-e2e-tests" } diff --git a/nodejs/test/e2e/harness/sdkTestContext.ts b/nodejs/test/e2e/harness/sdkTestContext.ts index 4986d1299..a5cf2ec57 100644 --- a/nodejs/test/e2e/harness/sdkTestContext.ts +++ b/nodejs/test/e2e/harness/sdkTestContext.ts @@ -13,6 +13,8 @@ import { CopilotClient } from "../../../src"; import { CapiProxy } from "./CapiProxy"; import { retry } from "./sdkTestHelper"; +export const isCI = process.env.GITHUB_ACTIONS === "true"; + const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const SNAPSHOTS_DIR = resolve(__dirname, "../../../../test/snapshots"); @@ -42,7 +44,7 @@ export async function createSdkTestContext({ logLevel: logLevel || "error", cliPath: process.env.COPILOT_CLI_PATH, // Use fake token in CI to allow cached responses without real auth - githubToken: process.env.CI === "true" ? "fake-token-for-e2e-tests" : undefined, + githubToken: isCI ? "fake-token-for-e2e-tests" : undefined, }); const harness = { homeDir, workDir, openAiEndpoint, copilotClient, env }; diff --git a/nodejs/test/e2e/session.test.ts b/nodejs/test/e2e/session.test.ts index 9d067a8ef..93731d617 100644 --- a/nodejs/test/e2e/session.test.ts +++ b/nodejs/test/e2e/session.test.ts @@ -2,7 +2,7 @@ import { rm } from "fs/promises"; import { describe, expect, it, onTestFinished } from "vitest"; import { ParsedHttpExchange } from "../../../test/harness/replayingCapiProxy.js"; import { CopilotClient, approveAll } from "../../src/index.js"; -import { createSdkTestContext } from "./harness/sdkTestContext.js"; +import { createSdkTestContext, isCI } from "./harness/sdkTestContext.js"; import { getFinalAssistantMessage, getNextEventOfType } from "./harness/sdkTestHelper.js"; describe("Sessions", async () => { @@ -187,7 +187,7 @@ describe("Sessions", async () => { // Resume using a new client const newClient = new CopilotClient({ env, - githubToken: process.env.CI === "true" ? "fake-token-for-e2e-tests" : undefined, + githubToken: isCI ? "fake-token-for-e2e-tests" : undefined, }); onTestFinished(() => newClient.forceStop()); diff --git a/python/e2e/test_session.py b/python/e2e/test_session.py index 47cb1b5ae..13e749507 100644 --- a/python/e2e/test_session.py +++ b/python/e2e/test_session.py @@ -183,7 +183,9 @@ async def test_should_resume_a_session_using_a_new_client(self, ctx: E2ETestCont assert "2" in answer.data.content # Resume using a new client - github_token = "fake-token-for-e2e-tests" if os.environ.get("CI") == "true" else None + github_token = ( + "fake-token-for-e2e-tests" if os.environ.get("GITHUB_ACTIONS") == "true" else None + ) new_client = CopilotClient( { "cli_path": ctx.cli_path, diff --git a/python/e2e/testharness/context.py b/python/e2e/testharness/context.py index eb0c44081..c03088912 100644 --- a/python/e2e/testharness/context.py +++ b/python/e2e/testharness/context.py @@ -60,7 +60,9 @@ async def setup(self): # Create the shared client (like Node.js/Go do) # Use fake token in CI to allow cached responses without real auth - github_token = "fake-token-for-e2e-tests" if os.environ.get("CI") == "true" else None + github_token = ( + "fake-token-for-e2e-tests" if os.environ.get("GITHUB_ACTIONS") == "true" else None + ) self._client = CopilotClient( { "cli_path": self.cli_path, diff --git a/test/harness/replayingCapiProxy.ts b/test/harness/replayingCapiProxy.ts index 6864731df..1a8fbc243 100644 --- a/test/harness/replayingCapiProxy.ts +++ b/test/harness/replayingCapiProxy.ts @@ -311,7 +311,8 @@ export class ReplayingCapiProxy extends CapturingHttpProxy { // Fallback to normal proxying if no cached response found // This implicitly captures the new exchange too - if (process.env.CI === "true") { + const isCI = process.env.GITHUB_ACTIONS === "true"; + if (isCI) { await exitWithNoMatchingRequestError( options, state.testInfo,