Skip to content

Commit d4c997a

Browse files
committed
Preserve runtime diagnostics on failure
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6e902b9a-5527-4a32-a5a3-e0bf5bfef3f7
1 parent 57d1304 commit d4c997a

2 files changed

Lines changed: 40 additions & 17 deletions

File tree

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

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ on:
1010
pull_request:
1111
types: [opened, synchronize, reopened, ready_for_review]
1212
paths:
13-
- 'nodejs/**'
14-
- 'test/**'
15-
- '.github/workflows/nodejs-sdk-tests.yml'
16-
- '!nodejs/scripts/**'
17-
- '!**/*.md'
18-
- '!**/LICENSE*'
19-
- '!**/.gitignore'
20-
- '!**/.editorconfig'
21-
- '!**/*.png'
22-
- '!**/*.jpg'
23-
- '!**/*.jpeg'
24-
- '!**/*.gif'
25-
- '!**/*.svg'
13+
- "nodejs/**"
14+
- "test/**"
15+
- ".github/workflows/nodejs-sdk-tests.yml"
16+
- "!nodejs/scripts/**"
17+
- "!**/*.md"
18+
- "!**/LICENSE*"
19+
- "!**/.gitignore"
20+
- "!**/.editorconfig"
21+
- "!**/*.png"
22+
- "!**/*.jpg"
23+
- "!**/*.jpeg"
24+
- "!**/*.gif"
25+
- "!**/*.svg"
2626
workflow_dispatch:
2727
merge_group:
2828

@@ -85,6 +85,7 @@ jobs:
8585
- name: Run Node.js SDK tests
8686
env:
8787
COPILOT_HMAC_KEY: ${{ secrets.COPILOT_DEVELOPER_CLI_INTEGRATION_HMAC_KEY }}
88+
COPILOT_SDK_PRESERVE_TEST_HOME: "1"
8889
run: |
8990
pwsh.exe -NoProfile -Command '
9091
while ($true) {
@@ -98,3 +99,19 @@ jobs:
9899
monitor_pid=$!
99100
trap 'kill "$monitor_pid"' EXIT
100101
npm test
102+
103+
- name: Collect runtime diagnostics
104+
if: failure()
105+
shell: pwsh
106+
run: |
107+
$paths = Get-ChildItem $env:TEMP -Directory -Filter "copilot-test-home-*"
108+
if ($paths) {
109+
Compress-Archive -Path $paths.FullName -DestinationPath runtime-diagnostics.zip
110+
}
111+
112+
- name: Upload runtime diagnostics
113+
if: failure()
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: nodejs-runtime-diagnostics
117+
path: nodejs/runtime-diagnostics.zip

nodejs/test/e2e/harness/sdkTestContext.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ export async function createSdkTestContext({
230230
// beforeEach below), so the worker inherits it; passing a per-client env here
231231
// would have no effect (and is rejected by the in-process transport).
232232
env: effectiveInProcess ? undefined : mergedEnv,
233-
logLevel: logLevel ?? "error",
233+
logLevel:
234+
logLevel ??
235+
(process.env.COPILOT_SDK_PRESERVE_TEST_HOME === "1" ? "debug" : "error"),
234236
connection: effectiveConnection,
235237
gitHubToken: authTokenToUse,
236238
...rest,
@@ -308,9 +310,13 @@ export async function createSdkTestContext({
308310
afterAll(async () => {
309311
await runDiagnosticPhase("client.stop", () => copilotClient.stop());
310312
await runDiagnosticPhase("proxy.stop", () => openAiEndpoint.stop(anyTestFailed));
311-
await runDiagnosticPhase("remove copilotHomeDir", () =>
312-
rmDir("remove e2e test copilotHomeDir", copilotHomeDir)
313-
);
313+
if (anyTestFailed && process.env.COPILOT_SDK_PRESERVE_TEST_HOME === "1") {
314+
console.error(`[sdk-test-diagnostic pid=${process.pid}] preserved ${copilotHomeDir}`);
315+
} else {
316+
await runDiagnosticPhase("remove copilotHomeDir", () =>
317+
rmDir("remove e2e test copilotHomeDir", copilotHomeDir)
318+
);
319+
}
314320
await runDiagnosticPhase("remove homeDir", () => rmDir("remove e2e test homeDir", homeDir));
315321
await runDiagnosticPhase("remove workDir", () => rmDir("remove e2e test workDir", workDir));
316322
});

0 commit comments

Comments
 (0)