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
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.5</version>
<configuration>
<runOrder>alphabetical</runOrder>
<!-- Inject JaCoCo agent + any JDK-version-specific flags -->
<argLine>${testExecutionAgentArgs} ${surefire.jvm.args}</argLine>
<!--
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/com/github/copilot/sdk/CapiProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public String start() throws IOException, InterruptedException {
: new ProcessBuilder("npx", "tsx", "server.ts");
pb.directory(harnessDir.toFile());
pb.redirectErrorStream(false);
// Tell the replaying proxy to fail fast on unmatched requests rather than
// forwarding them to the real API. Without this, unmatched requests hit the
// live API with a fake token and crash the proxy's JSON parser.
pb.environment().put("GITHUB_ACTIONS", "true");

process = pb.start();

Expand Down
8 changes: 8 additions & 0 deletions src/test/java/com/github/copilot/sdk/CompactionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

Expand Down Expand Up @@ -52,10 +53,17 @@ static void teardown() throws Exception {
/**
* Verifies that compaction is triggered with low threshold and emits events.
*
* <p>
* Disabled due to flakiness — compaction timing is non-deterministic and the
* snapshot cannot reliably match across platforms. The reference implementation
* (nodejs) also skips this test. See <a href=
* "https://github.com/github/copilot-sdk/issues/1227">copilot-sdk#1227</a>.
*
* @see Snapshot:
* compaction/should_trigger_compaction_with_low_threshold_and_emit_events
*/
@Test
@Disabled("Flaky: compaction timing varies by platform — see https://github.com/github/copilot-sdk/issues/1227")
@Timeout(value = 300, unit = TimeUnit.SECONDS)
void testShouldTriggerCompactionWithLowThresholdAndEmitEvents() throws Exception {
ctx.configureForTest("compaction", "should_trigger_compaction_with_low_threshold_and_emit_events");
Expand Down
22 changes: 4 additions & 18 deletions src/test/java/com/github/copilot/sdk/E2ETestContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,10 @@ public Map<String, String> getEnvironment() {
env.put("REQUESTS_CA_BUNDLE", caFile);
env.put("CURL_CA_BUNDLE", caFile);
env.put("GIT_SSL_CAINFO", caFile);
env.put("GH_TOKEN", "");
env.put("GITHUB_TOKEN", "");
env.put("GH_ENTERPRISE_TOKEN", "");
env.put("GITHUB_ENTERPRISE_TOKEN", "");
}

if ("true".equals(System.getenv("GITHUB_ACTIONS"))) {
env.put("GH_TOKEN", "fake-token-for-e2e-tests");
env.put("GITHUB_TOKEN", "fake-token-for-e2e-tests");
env.put("GH_ENTERPRISE_TOKEN", "");
env.put("GITHUB_ENTERPRISE_TOKEN", "");
}

return env;
Expand All @@ -291,13 +286,7 @@ public Map<String, String> getEnvironment() {
*/
public CopilotClient createClient() {
CopilotClientOptions options = new CopilotClientOptions().setCliPath(cliPath).setCwd(workDir.toString())
.setEnvironment(getEnvironment());

// In CI (GitHub Actions), use a fake token to avoid auth issues
String ci = System.getenv("GITHUB_ACTIONS");
if (ci != null && !ci.isEmpty()) {
options.setGitHubToken("fake-token-for-e2e-tests");
}
.setEnvironment(getEnvironment()).setGitHubToken("fake-token-for-e2e-tests");

return new CopilotClient(options);
}
Expand All @@ -321,10 +310,7 @@ public CopilotClient createClient(CopilotClientOptions options) {
if (options.getEnvironment() == null || options.getEnvironment().isEmpty()) {
options.setEnvironment(getEnvironment());
}

// In CI (GitHub Actions), use a fake token to avoid auth issues
String ci = System.getenv("GITHUB_ACTIONS");
if (ci != null && !ci.isEmpty() && options.getGitHubToken() == null) {
if (options.getGitHubToken() == null) {
options.setGitHubToken("fake-token-for-e2e-tests");
}

Expand Down
8 changes: 2 additions & 6 deletions src/test/java/com/github/copilot/sdk/ExecutorWiringTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,8 @@ int getTaskCount() {

private CopilotClientOptions createOptionsWithExecutor(TrackingExecutor executor) {
CopilotClientOptions options = new CopilotClientOptions().setCliPath(ctx.getCliPath())
.setCwd(ctx.getWorkDir().toString()).setEnvironment(ctx.getEnvironment()).setExecutor(executor);

String ci = System.getenv("GITHUB_ACTIONS");
if (ci != null && !ci.isEmpty()) {
options.setGitHubToken("fake-token-for-e2e-tests");
}
.setCwd(ctx.getWorkDir().toString()).setEnvironment(ctx.getEnvironment()).setExecutor(executor)
.setGitHubToken("fake-token-for-e2e-tests");
return options;
}

Expand Down