Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dotnet/test/Harness/E2ETestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ public IReadOnlyDictionary<string, string> 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 { }
Expand Down
2 changes: 1 addition & 1 deletion go/internal/e2e/testharness/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
4 changes: 3 additions & 1 deletion nodejs/test/e2e/harness/sdkTestContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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 };
Expand Down
4 changes: 2 additions & 2 deletions nodejs/test/e2e/session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 3 additions & 1 deletion python/e2e/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion python/e2e/testharness/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion test/harness/replayingCapiProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading