Skip to content

Refactor workdir setup tests and guard fixture cleanup#5303

Merged
lpcox merged 3 commits into
mainfrom
copilot/fix-duplicate-code-workdir-setup-tests
Jun 20, 2026
Merged

Refactor workdir setup tests and guard fixture cleanup#5303
lpcox merged 3 commits into
mainfrom
copilot/fix-duplicate-code-workdir-setup-tests

Conversation

Copilot AI commented Jun 19, 2026

Copy link
Copy Markdown
Contributor
  • Read and understand /home/runner/work/gh-aw-firewall/gh-aw-firewall/src/workdir-setup.test.ts
  • Extract shared setupWorkdirFixture() helper to remove duplicated setup across the test suites
  • Guard fixture cleanup so afterEach only removes directories when tempDir was created
  • Validate the affected area with lint, build, and npm test -- src/workdir-setup.test.ts

Removes ~45 duplicated lines across three describe blocks by introducing
setupWorkdirFixture(). Suites opt out of chroot-home cleanup via the
cleanupChrootHome option.
Copilot AI requested a review from lpcox June 19, 2026 22:38
@lpcox lpcox marked this pull request as ready for review June 19, 2026 23:19
Copilot AI review requested due to automatic review settings June 19, 2026 23:19
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 97.62% 97.66% 📈 +0.04%
Statements 97.56% 97.60% 📈 +0.04%
Functions 98.85% 98.85% ➡️ +0.00%
Branches 93.24% 93.27% 📈 +0.03%
📁 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

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/workdir-setup.test.ts to reduce duplicated boilerplate by extracting a shared setupWorkdirFixture() helper that centralizes temp dir creation, config building, and Jest hook setup/cleanup.

Changes:

  • Added setupWorkdirFixture() to own tempDir, buildConfig(), and shared beforeEach/afterEach.
  • Updated the three test suites to use the fixture (and fixture.tempDir) instead of repeating setup code.
  • Made chroot-home cleanup optional for the log-directories sub-function suite.
Show a summary per file
File Description
src/workdir-setup.test.ts Refactors workdir setup tests to use a shared fixture helper and reduce duplicated setup/cleanup code.

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

Comment thread src/workdir-setup.test.ts
Comment on lines 41 to +45
afterEach(() => {
fs.rmSync(tempDir, { recursive: true, force: true });
fs.rmSync(`${tempDir}-chroot-home`, { recursive: true, force: true });
if (cleanupChrootHome) {
fs.rmSync(`${tempDir}-chroot-home`, { recursive: true, force: true });
}
@lpcox

lpcox commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

@copilot address the review feedback and fix the pr title and summary

@lpcox

lpcox commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

@copilot address the review feedback and fix the pr title and summary

@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.

@lpcox lpcox changed the title [WIP] Refactor workdir setup tests to reduce duplicate code Refactor workdir setup tests and guard fixture cleanup Jun 20, 2026

Copilot AI commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address the review feedback and fix the pr title and summary

Addressed in 157fe2f. I added the tempDir guard in the shared fixture cleanup and updated the PR title/summary.

@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude failed

@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

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

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

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

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Contribution Check completed successfully!

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK ✅ PASS

Test Results:

  • ✅ GitHub MCP connectivity (list_pull_requests: 2 merged PRs retrieved)
  • ✅ GitHub.com HTTP connectivity (HTTP 200)
  • ✅ File write/read operations
  • ✅ BYOK inference path (agent → api-proxy → api.githubcopilot.com)

Mode: Direct BYOK (COPILOT_PROVIDER_API_KEY via api-proxy sidecar)
Status: All systems operational

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test COPILOT BYOK (Direct)

  • MCP PR retrieval ✅
  • GitHub.com connectivity ✅
  • File I/O ✅
  • Direct BYOK inference ✅

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

Overall: PASS

cc @lpcox

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)

@github-actions

Copy link
Copy Markdown
Contributor

🔬 Smoke Test Results — PASS

Test Result
GitHub MCP connectivity
GitHub.com HTTP ✅ 200
File write/read

PR: Refactor workdir setup tests and guard fixture cleanup
Author: @Copilot | Assignees: @lpcox @Copilot

Overall: PASS

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results — PAT Auth

Test Result
GitHub MCP connectivity
GitHub.com HTTP ✅ 200
File write/read ⚠️ (template vars unexpanded)

Overall: PASS (2/2 runnable tests passed; file test skipped — ${{ }} not substituted)

Auth mode: PAT (COPILOT_GITHUB_TOKEN)
PR: "Refactor workdir setup tests and guard fixture cleanup" by @Copilot · assignees: @lpcox @Copilot

🔑 PAT report filed by Smoke Copilot PAT

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: API Proxy OpenTelemetry Tracing

Scenario Result Details
1. Module Loading ✅ Pass otel.js loads cleanly; exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled + internal helpers
2. Test Suite ✅ Pass 59/59 tests passed across otel.test.js and otel-fanout.test.js
3. Env Var Forwarding ✅ Pass src/services/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, and OTEL_SERVICE_NAME to the api-proxy container
4. Token Tracker Integration ✅ Pass onUsage callback exists at line 283/324 in token-tracker-http.js; onSpanEnd hook also present for span completion
5. OTEL Diagnostics ✅ Pass Graceful degradation confirmed: FileSpanExporter fallback to /var/log/api-proxy/otel.jsonl when no OTLP endpoint configured

All 5 scenarios pass. OTEL tracing integration is working correctly.

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Smoke Test 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: ❌ FAILED — Python and Node.js versions differ between host and chroot.

Tested by Smoke Chroot

@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

Generated by Build Test Suite for issue #5303 · 37.3 AIC · ⊞ 7.7K ·

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Services Connectivity

Check Result
Redis PING ❌ no response
PostgreSQL pg_isready ❌ no response
PostgreSQL SELECT 1 ❌ failed

host.docker.internal resolves to 172.17.0.1 but services are not reachable.

Overall: FAIL

🔌 Service connectivity validated by Smoke Services

@github-actions

Copy link
Copy Markdown
Contributor

Gemini Smoke Test Results

Overall Status: PASS

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

@lpcox @Copilot
PRs: Refactor extract functions in token-parsers file; Refactor to extract rule-setup phases into named bash functions
GitHub MCP: ✅
GitHub.com: ✅
File IO: ✅
BYOK 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)
Overall: PASS

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

@github-actions

Copy link
Copy Markdown
Contributor

[WIP] Refactor entrypoint.sh by extracting initialization phases into functions
[WIP] Refactor to extract rule-setup phases into named bash functions
✅ GitHub PR query
✅ GitHub discussion query/comment
✅ Playwright github.com title
✅ File write/read
✅ npm ci && npm run build
Overall: PASS

🔮 The oracle has spoken through Smoke Codex

@lpcox lpcox merged commit 8ee1833 into main Jun 20, 2026
87 of 90 checks passed
@lpcox lpcox deleted the copilot/fix-duplicate-code-workdir-setup-tests branch June 20, 2026 15:35
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