Skip to content

refactor: extract shared signal-handler test fixture to eliminate duplication#6132

Merged
lpcox merged 3 commits into
mainfrom
copilot/fix-duplicate-signal-handler-setup
Jul 12, 2026
Merged

refactor: extract shared signal-handler test fixture to eliminate duplication#6132
lpcox merged 3 commits into
mainfrom
copilot/fix-duplicate-signal-handler-setup

Conversation

Copilot AI commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

flushPromises, the handlers registry, and the three Jest process/console spies with their beforeEach/afterEach lifecycle were duplicated verbatim across signal-handler.test.ts and coverage-branch-gaps-3.test.ts — any change to the mocking strategy required two edits.

Changes

  • New src/commands/signal-handler.test-utils.ts — exports:

    • flushPromises — shared Promise-flush helper
    • createSignalHandlerTestHarness() — factory that mocks process.on to capture registered signal handlers, sets up process.exit and console.error spies, and wires beforeEach/afterEach teardown automatically; returns a typed harness object
    • SignalHandlerTestHarness — exported return type
  • signal-handler.test.ts — replaces ~24 lines of boilerplate with a single createSignalHandlerTestHarness() call; accesses spies and handlers via harness.*

  • coverage-branch-gaps-3.test.ts — same replacement; removes local flushPromises, handlers, and all three spy vars

// before (duplicated in two files)
const flushPromises = (): Promise<void> => new Promise(resolve => setImmediate(resolve));
const handlers: Record<string, (...args: unknown[]) => unknown> = {};
beforeEach(() => {
  processOnSpy = jest.spyOn(process, 'on').mockImplementation(...);
  processExitSpy = jest.spyOn(process, 'exit').mockImplementation(() => undefined as never);
  consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();
});
afterEach(() => { /* restore all three */ });

// after (shared fixture)
import { flushPromises, createSignalHandlerTestHarness } from './signal-handler.test-utils';
const harness = createSignalHandlerTestHarness(); // beforeEach/afterEach registered automatically

Copilot AI changed the title [WIP] Refactor signal-handler jest setup to eliminate duplication refactor: extract shared signal-handler test fixture to eliminate duplication Jul 12, 2026
Copilot finished work on behalf of lpcox July 12, 2026 14:06
Copilot AI requested a review from lpcox July 12, 2026 14:06
@lpcox lpcox marked this pull request as ready for review July 12, 2026 14:33
Copilot AI review requested due to automatic review settings July 12, 2026 14:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extracts duplicated signal-handler test setup into a reusable harness.

Changes:

  • Adds shared promise flushing and Jest spy lifecycle utilities.
  • Refactors both signal-handler test suites to use the harness.
  • Preserves existing signal-handler coverage.
Show a summary per file
File Description
src/commands/signal-handler.test-utils.ts Adds the shared test harness and helper.
src/commands/signal-handler.test.ts Replaces duplicated fixture setup.
src/coverage-branch-gaps-3.test.ts Reuses the shared fixture for branch tests.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread src/commands/signal-handler.test-utils.ts Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@copilot Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 98.30% 98.34% 📈 +0.04%
Statements 98.23% 98.27% 📈 +0.04%
Functions 99.07% 99.08% 📈 +0.01%
Branches 93.85% 93.85% ➡️ +0.00%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)
✨ New Files (1 files)
  • src/commands/signal-handler.test-utils.ts: 100.0% lines

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

Smoke test completed with FAIL status.

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

📰 DEVELOPING STORY: Smoke Docker Sbx reports failed. Our correspondents are investigating the incident...

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Contribution Check completed successfully!

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results

Test Status
GitHub MCP connectivity
GitHub.com HTTP
File write/read

Overall: FAIL

Auth mode: PAT (COPILOT_GITHUB_TOKEN)

Note: Workflow template variables (${{ steps.smoke-data.outputs.* }}) were not expanded — pre-computed test data was unavailable to the agent.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🔑 PAT report filed by Smoke Copilot PAT
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the focused refactor. One contribution-guideline item is missing: please reference any related issue in the PR description, or explicitly state that there is no related issue. This is required by CONTRIBUTING.md under Pull Request Process → Pull request requirements ("Reference any related issues").

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Contribution Check for #6132 · 3.21 AIC · ⊞ 19.3K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

Check Result
API Status ✅ PASS
GH Check ✅ PASS
File Status ✅ PASS

Overall Result: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Smoke Claude for #6132 · 35.3 AIC · ⊞ 3.3K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

@lpcox

#6132: Smoke test for Copilot BYOK (Direct) Mode — Azure OpenAI

  • MCP connectivity: ✅
  • GitHub.com connectivity: ✅
  • File write/read test: ✅
  • BYOK inference path: ✅

Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw)

Overall: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Services Connectivity

  • Redis PING: ❌ Network is unreachable
  • PostgreSQL pg_isready: ❌ No response
  • PostgreSQL SELECT 1: ❌ Network is unreachable

Overall: FAILhost.docker.internal (172.17.0.1) unreachable from this runner. Service containers may not be configured for this workflow.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🔌 Service connectivity validated by Smoke Services
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK Direct Mode@lpcox

✅ GitHub.com connectivity (HTTP 200)
✅ File write/read test
✅ BYOK inference mode active

Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY) via api-proxy → api.githubcopilot.com

Overall: PASS 🔓

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🔑 BYOK report filed by Smoke Copilot BYOK
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results

Test Status
GitHub MCP Connectivity
GitHub.com HTTP ✅ (200)
File Write/Read ❌ (template vars unresolved in workflow)

Overall: FAIL — pre-step outputs not substituted

cc @lpcox

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

📰 BREAKING: Report filed by Smoke Copilot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🔭 OTEL Smoke Test Results

Scenario Result
1. Module Loadingotel.js loaded; exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled + internals
2. Test Suite — 59 tests across otel.test.js + otel-fanout.test.js ✅ 59/59 passed
3. Env Var Forwardingsrc/services/api-proxy-env-config.ts forwards GH_AW_OTLP_ENDPOINTS, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, GITHUB_AW_OTEL_TRACE_ID, GITHUB_AW_OTEL_PARENT_SPAN_ID, OTEL_SERVICE_NAME
4. Token Tracker IntegrationonUsage callback present in token-tracker-http.js (invoked at line 343)
5. OTEL Diagnostics — No live collector configured; file fallback (otel.jsonl) activated per design ✅ (expected)

All scenarios pass. OTEL tracing integration is healthy.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

📡 OTel tracing validated by Smoke OTel Tracing
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3 ❌ NO
Node.js v24.18.0 v22.23.1 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Result: Not all tests passed — Python and Node.js versions differ between host and chroot.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Tested by Smoke Chroot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

feat: add gVisor smoke tests for Claude, Codex, and build workloads ✅
chore: upgrade gh-aw to v0.82.8 pre-release and recompile workflows ✅
Overall: PASS

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • awmgmcpg
  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results: Gemini Engine

  • GitHub MCP Testing: ❌ (Could not retrieve PRs)
  • GitHub.com Connectivity: ❌ (000/Network unreachable)
  • File Writing Testing: ✅
  • Bash Tool Testing: ✅

Overall Status: FAIL

Merged PR Titles:

  1. feat: add Docker sbx microVM runtime support (feat: add Docker sbx microVM runtime support #6101)
  2. (Unknown)

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

@lpcox

  • ✅ GitHub MCP connectivity (pre-fetched data)
  • ✅ GitHub.com connectivity
  • ❌ File write/read test
  • ✅ BYOK inference path

Running in direct BYOK mode (AWF_AUTH_TYPE=github-oidc + AWF_AUTH_AZURE_* + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) authenticated via Microsoft Entra

Overall: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx All passed ✅ PASS
Node.js execa All passed ✅ PASS
Node.js p-limit All passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Note: Java required a custom Maven settings file with a writable local repository path since the default ~/.m2/repository was not writable in this environment.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Build Test Suite for #6132 · 41.8 AIC · ⊞ 6.9K ·
Add label ready-for-aw to run again

@lpcox lpcox merged commit f34d4cd into main Jul 12, 2026
115 of 117 checks passed
@lpcox lpcox deleted the copilot/fix-duplicate-signal-handler-setup branch July 12, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Duplicate Code] Signal-handler Jest setup is duplicated across dedicated and branch-coverage tests

3 participants