Skip to content

Commit 3428b36

Browse files
stephentoubCopilot
andauthored
fix(ci): address merge queue failure causes (#2515)
Synchronize Go replay proxy startup, avoid nested PowerShell in the Windows shell E2E test, normalize bare abort results, retry truncated Python downloads, and prevent local Java validation from invoking Central publishing. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 184e504 commit 3428b36

7 files changed

Lines changed: 50 additions & 14 deletions

File tree

.github/workflows/java-sdk-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ jobs:
410410
mvn -B -pl copilot-native deploy -Prelease -DskipTests \
411411
-Dcopilot.native.libc=glibc \
412412
-Dcopilot.native.test.local.publication=true \
413+
-DskipPublishing=true \
413414
"-Dcopilot.native.external.linux.arm64.classifier.path=$LINUX_ARM64_JAR" \
414415
"-Dcopilot.native.external.win32.classifier.path=$WINDOWS_JAR" \
415416
"-Dcopilot.native.external.win32.arm64.classifier.path=$WINDOWS_ARM64_JAR" \

go/internal/e2e/rpc_shell_and_fleet_e2e_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@ func TestRPCShellAndFleetE2E(t *testing.T) {
3030
t.Fatalf("Failed to create session: %v", err)
3131
}
3232

33-
markerPath := filepath.Join(ctx.WorkDir, "shell-rpc-"+randomHex(t)+".txt")
33+
commandDir := filepath.Join(ctx.WorkDir, "shell-rpc-"+randomHex(t))
34+
if err := os.Mkdir(commandDir, 0755); err != nil {
35+
t.Fatalf("Failed to create shell command directory: %v", err)
36+
}
37+
markerPath := filepath.Join(commandDir, "marker.txt")
3438
const marker = "copilot-sdk-shell-rpc"
3539

36-
cwd := ctx.WorkDir
40+
cwd := commandDir
3741
result, err := session.RPC.Shell.Exec(t.Context(), &rpc.ShellExecRequest{
38-
Command: writeFileCommand(markerPath, marker),
42+
Command: writeFileCommand(filepath.Base(markerPath), marker),
3943
Cwd: &cwd,
4044
})
4145
if err != nil {
@@ -174,11 +178,11 @@ func randomHex(t *testing.T) string {
174178
return hex.EncodeToString(buf[:])
175179
}
176180

177-
func writeFileCommand(markerPath, marker string) string {
181+
func writeFileCommand(markerName, marker string) string {
178182
if runtime.GOOS == "windows" {
179-
return fmt.Sprintf("powershell -NoLogo -NoProfile -Command \"Set-Content -LiteralPath '%s' -Value '%s'\"", markerPath, marker)
183+
return fmt.Sprintf("echo %s>\"%s\"", marker, markerName)
180184
}
181-
return fmt.Sprintf("sh -c \"printf '%%s' '%s' > '%s'\"", marker, markerPath)
185+
return fmt.Sprintf("sh -c \"printf '%%s' '%s' > '%s'\"", marker, markerName)
182186
}
183187

184188
func waitForFileText(t *testing.T, path, expected string) {

go/internal/e2e/testharness/context.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,15 @@ func NewTestContext(t *testing.T) *TestContext {
163163
os.RemoveAll(workDir)
164164
t.Fatalf("Failed to start proxy: %v", err)
165165
}
166+
// Initialize the proxy before any client can start runtime requests. Tests that
167+
// use a snapshot replace this empty configuration before model traffic begins.
168+
dummySnapshotPath := filepath.Join(workDir, "__no_snapshot__.yaml")
169+
if err := proxy.Configure(dummySnapshotPath, workDir); err != nil {
170+
proxy.StopWithOptions(true)
171+
os.RemoveAll(homeDir)
172+
os.RemoveAll(workDir)
173+
t.Fatalf("Failed to initialize proxy: %v", err)
174+
}
166175
if err := proxy.SetCopilotUserByToken(defaultGitHubToken, map[string]interface{}{
167176
"login": "e2e-test-user",
168177
"copilot_plan": "individual_pro",

python/copilot/_cli_download.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import tempfile
2828
import time
2929
import zipfile
30+
from http.client import IncompleteRead
3031
from pathlib import Path, PurePosixPath
3132
from urllib.error import HTTPError, URLError
3233
from urllib.request import urlopen
@@ -43,6 +44,7 @@
4344

4445
_CACHE_DIR_NAME = "github-copilot-sdk"
4546
_MAX_RETRIES = 3
47+
_RETRIABLE_DOWNLOAD_ERRORS = (HTTPError, URLError, IncompleteRead)
4648

4749

4850
def _sanitize_version(version: str) -> str:
@@ -128,7 +130,7 @@ def _fetch_checksums(version: str) -> dict[str, str]:
128130
with urlopen(url, timeout=30) as response:
129131
text = response.read().decode("utf-8")
130132
break
131-
except (HTTPError, URLError) as exc:
133+
except _RETRIABLE_DOWNLOAD_ERRORS as exc:
132134
last_exc = exc
133135
if attempt < _MAX_RETRIES - 1:
134136
time.sleep(2**attempt)
@@ -255,7 +257,7 @@ def download_cli(version: str | None = None, *, force: bool = False) -> str:
255257
with urlopen(url, timeout=120) as response:
256258
data = response.read()
257259
break
258-
except (HTTPError, URLError) as exc:
260+
except _RETRIABLE_DOWNLOAD_ERRORS as exc:
259261
last_exc = exc
260262
if attempt < _MAX_RETRIES - 1:
261263
time.sleep(2**attempt)
@@ -315,7 +317,7 @@ def _fetch_url_bytes(url: str, *, timeout: int) -> bytes:
315317
try:
316318
with urlopen(url, timeout=timeout) as response:
317319
return response.read()
318-
except (HTTPError, URLError) as exc:
320+
except _RETRIABLE_DOWNLOAD_ERRORS as exc:
319321
last_exc = exc
320322
if attempt < _MAX_RETRIES - 1:
321323
time.sleep(2**attempt)

python/test_cli_download.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import io
88
import os
99
import tarfile
10-
from unittest.mock import patch
10+
from http.client import IncompleteRead
11+
from unittest.mock import MagicMock, patch
1112

1213
import pytest
1314

@@ -41,6 +42,26 @@ def _runtime_package(npm_platform: str) -> bytes:
4142
return buffer.getvalue()
4243

4344

45+
def test_fetch_url_bytes_retries_truncated_response():
46+
truncated_response = MagicMock()
47+
truncated_response.__enter__.return_value.read.side_effect = IncompleteRead(b"partial", 4)
48+
complete_response = MagicMock()
49+
complete_response.__enter__.return_value.read.return_value = b"complete"
50+
51+
with (
52+
patch.object(
53+
_cli_download,
54+
"urlopen",
55+
side_effect=[truncated_response, complete_response],
56+
) as urlopen,
57+
patch.object(_cli_download.time, "sleep") as sleep,
58+
):
59+
assert _cli_download._fetch_url_bytes("https://example/runtime", timeout=30) == b"complete"
60+
61+
assert urlopen.call_count == 2
62+
sleep.assert_called_once_with(1)
63+
64+
4465
class TestVerifyIntegrity:
4566
def test_accepts_matching_checksum(self):
4667
data = b"native-library-bytes"

test/harness/replayingCapiProxy.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ Always include PINEAPPLE_COCONUT_42.
981981
}
982982
});
983983

984-
test("matches semantically equivalent interrupted shell results", async () => {
984+
test("matches semantically equivalent interrupted tool results", async () => {
985985
const originalShellConfig =
986986
process.platform === "win32"
987987
? ShellConfig.powerShell
@@ -1056,8 +1056,7 @@ Always include PINEAPPLE_COCONUT_42.
10561056
{
10571057
role: "tool",
10581058
tool_call_id: "runtime-call-id",
1059-
content:
1060-
"<shell context is being reconfigured; retry the command>",
1059+
content: "Session aborted",
10611060
},
10621061
],
10631062
},

test/harness/replayingCapiProxy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ function normalizeAvailableToolNames(result: string): string {
15561556

15571557
function normalizeInterruptedToolResult(result: string): string {
15581558
return result.replace(
1559-
/^(?:Failed to execute `[^`]+` tool(?: with arguments: [\s\S]*?)? due to error: (?:Error: )?Session aborted|<shell context is being reconfigured; retry the command>|unknown attachedShellSession handle \d+)$/,
1559+
/^(?:Session aborted|Failed to execute `[^`]+` tool(?: with arguments: [\s\S]*?)? due to error: (?:Error: )?Session aborted|<shell context is being reconfigured; retry the command>|unknown attachedShellSession handle \d+)$/,
15601560
"The execution of this tool, or a previous tool was interrupted.",
15611561
);
15621562
}

0 commit comments

Comments
 (0)