Skip to content

refactor: extract shared helper to eliminate duplicate test scaffold in docker-host-env tests#5419

Merged
lpcox merged 2 commits into
mainfrom
copilot/fix-duplicate-code-docker-host-tests
Jun 23, 2026
Merged

refactor: extract shared helper to eliminate duplicate test scaffold in docker-host-env tests#5419
lpcox merged 2 commits into
mainfrom
copilot/fix-duplicate-code-docker-host-tests

Conversation

Copilot AI commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Three tests in src/docker-host-env.test.ts repeated an identical ~20-line block: temp dir setup, two mockResolvedValueOnce calls, startContainers invocation, compose-call filtering, env extraction, and cleanup.

Changes

  • src/docker-host-env.test.ts: extracted runStartContainersAndGetComposeEnv() as an inline helper inside the describe block. It owns the full scaffold and returns the env object from the first docker compose call. Each test now only sets up its DOCKER_HOST/setAwfDockerHost precondition and asserts the expected forwarded value.

Before (repeated three times):

const testDir = fs.mkdtempSync(path.join(os.tmpdir(), 'awf-test-'));
try {
  mockExecaFn.mockResolvedValueOnce({ stdout: '', stderr: '', exitCode: 0 } as any);
  mockExecaFn.mockResolvedValueOnce({ stdout: '', stderr: '', exitCode: 0 } as any);
  await startContainers(testDir, ['github.com']);
  const composeCalls = mockExecaFn.mock.calls.filter((call: any[]) => call[1]?.[0] === 'compose');
  expect(composeCalls.length).toBeGreaterThan(0);
  const composeEnv = composeCalls[0][2]?.env as Record<string, string | undefined> | undefined;
  expect(composeEnv!.DOCKER_HOST).toBe('...');
} finally {
  fs.rmSync(testDir, { recursive: true, force: true });
}

After:

process.env.DOCKER_HOST = 'tcp://localhost:2375';
const composeEnv = await runStartContainersAndGetComposeEnv();
expect(composeEnv).toBeDefined();
expect(composeEnv!.DOCKER_HOST).toBe('tcp://localhost:2375');

Net result: ~30 lines removed, assertion consistency guaranteed across all three ARC/DinD DOCKER_HOST boundary tests.

Copilot AI changed the title [WIP] Refactor Docker host env tests to remove duplicate code refactor: extract shared helper to eliminate duplicate test scaffold in docker-host-env tests Jun 22, 2026
Copilot AI requested a review from lpcox June 22, 2026 22:57
Copilot finished work on behalf of lpcox June 22, 2026 22:57
@lpcox lpcox marked this pull request as ready for review June 23, 2026 13:51
Copilot AI review requested due to automatic review settings June 23, 2026 13:51

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

This PR refactors src/docker-host-env.test.ts to remove duplicated test scaffolding around startContainers calls, improving consistency and reducing repetition in the DOCKER_HOST isolation tests.

Changes:

  • Extracted a shared inline helper runStartContainersAndGetComposeEnv() within the describe block to centralize temp dir setup, mocked execa results, startContainers() execution, and docker compose env extraction.
  • Updated the three DOCKER_HOST boundary tests to use the helper and focus only on preconditions + assertions.
Show a summary per file
File Description
src/docker-host-env.test.ts Refactors repeated test setup into a shared helper and simplifies the three DOCKER_HOST forwarding/override tests.

Copilot's findings

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Jun 23, 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 Jun 23, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (api-key) reports failed. AOAI BYOK (api-key) mode investigation needed...

@github-actions

github-actions Bot commented Jun 23, 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 Jun 23, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 98.01% 98.05% 📈 +0.04%
Statements 97.95% 97.98% 📈 +0.03%
Functions 99.51% 99.51% ➡️ +0.00%
Branches 93.68% 93.72% 📈 +0.04%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/workdir-setup.ts 92.7% → 94.5% (+1.82%) 92.7% → 94.5% (+1.82%)

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct Mode) ✅ PASS

Test Results:

  • ✅ GitHub MCP Testing: Connectivity confirmed
  • ✅ GitHub.com Connectivity: HTTP 200
  • ✅ File Write/Read Test: Verified
  • ✅ BYOK Inference: Agent responding (api-proxy → api.githubcopilot.com)

Mode: Direct BYOK (COPILOT_PROVIDER_API_KEY) via api-proxy sidecar

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

Check Status
API ✅ PASS
gh CLI ✅ PASS
File operations ✅ PASS

Overall result: PASS

Generated by Smoke Claude for issue #5419 · 36.8 AIC · ⊞ 3.1K ·

@github-actions

Copy link
Copy Markdown
Contributor

🔥 Smoke Test Results — PASS

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

PR: refactor: extract shared helper to eliminate duplicate test scaffold in docker-host-env tests
Author: @Copilot | Assignees: @lpcox @Copilot

Overall: PASS

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

Copy link
Copy Markdown
Contributor

🔥 Smoke Test Results — Auth mode: PAT (COPILOT_GITHUB_TOKEN)

Test Result
GitHub MCP connectivity
GitHub.com HTTP (200)
File write/read ❌ (pre-step outputs not resolved)

Overall: FAIL

cc @lpcox — PR by @Copilot, assigned to @lpcox @Copilot

🔑 PAT report filed by Smoke Copilot PAT

@github-actions

Copy link
Copy Markdown
Contributor

@lpcox

  • GitHub MCP Testing: ✅
  • GitHub.com Connectivity: ✅
  • File Write/Read Test: ✅
  • BYOK Inference Test: ✅

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: PASS

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)

@github-actions

Copy link
Copy Markdown
Contributor

Gemini Smoke Test Results

Overall status: FAIL

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

@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
Node.js v24.16.0 v22.22.3
Go go1.22.12 go1.22.12

Overall: ❌ Tests did not pass — Python and Node.js versions differ between host and chroot environments.

Tested by Smoke Chroot

@github-actions

Copy link
Copy Markdown
Contributor

📡 OTel Tracing Smoke Test Results

Scenario Result
S1: Module Loading otel.js loaded, isEnabled: true, exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled
S2: Test Suite ✅ 59 tests passed, 0 failed (2 suites: otel.test.js, otel-fanout.test.js)
S3: Env Var Forwarding api-proxy-service-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 via pickEnvVars
S4: Token Tracker Integration token-tracker-http.js has onUsage callback (OTEL hook point)
S5: OTEL Diagnostics i️ No span file (expected — no live api-proxy container in this run)

All scenarios pass. ✅

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test

  • Remove unused ParsedDomainList export from domain-matchers
  • Remove unused ParsedDomain from domain-patterns
  • GitHub title check ✅
  • File write/read ✅
  • Discussion lookup/comment ✅
  • npm ci && npm run build
  • Overall status: PASS

Warning

Firewall blocked 1 domain

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

  • registry.npmjs.org

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

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

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: GitHub Actions Services Connectivity

Check Result
Redis PING (host.docker.internal:6379) ❌ Connection timed out
PostgreSQL pg_isready (host.docker.internal:5432) ❌ No response
PostgreSQL SELECT 1 ❌ No response

host.docker.internal resolves to 172.17.0.1 but both services are unreachable from this environment.

Overall: FAIL

🔌 Service connectivity validated by Smoke Services

@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 passed ✅ PASS
Node.js execa passed ✅ PASS
Node.js p-limit passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for issue #5419 · 44.7 AIC · ⊞ 7.7K ·

@lpcox lpcox merged commit d9b050a into main Jun 23, 2026
87 of 90 checks passed
@lpcox lpcox deleted the copilot/fix-duplicate-code-docker-host-tests branch June 23, 2026 15:32
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.

3 participants