Skip to content

Deduplicate AWF_TOKEN_LOG_DIR setup across token-tracker tests#3360

Merged
lpcox merged 2 commits into
mainfrom
copilot/fix-duplicate-token-setup-code
May 18, 2026
Merged

Deduplicate AWF_TOKEN_LOG_DIR setup across token-tracker tests#3360
lpcox merged 2 commits into
mainfrom
copilot/fix-duplicate-token-setup-code

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 18, 2026

The token-tracker test suite repeated the same AWF_TOKEN_LOG_DIR temp-dir initialization block in three files, creating maintenance drift risk for environment setup changes. This PR centralizes that setup into a single shared test helper and updates each suite to use it.

  • What changed

    • Added a shared helper: containers/api-proxy/test-helpers/token-tracker-setup.js
    • Moved the AWF_TOKEN_LOG_DIR temp-dir initialization logic into that helper
    • Replaced duplicated inline setup blocks in:
      • token-tracker.http.test.js
      • token-tracker.schema.test.js
      • token-tracker.websocket.test.js
  • Result

    • Token-tracker test environment setup now has one source of truth, reducing copy-paste drift and future update overhead.
// token-tracker test files
require('./test-helpers/token-tracker-setup');

Copilot AI changed the title [WIP] Fix duplicate AWF_TOKEN_LOG_DIR setup block in tests Deduplicate AWF_TOKEN_LOG_DIR setup across token-tracker tests May 18, 2026
Copilot AI requested a review from lpcox May 18, 2026 22:28
Copilot finished work on behalf of lpcox May 18, 2026 22:28
@lpcox lpcox marked this pull request as ready for review May 18, 2026 22:48
Copilot AI review requested due to automatic review settings May 18, 2026 22:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 reduces maintenance drift in the API proxy’s token-tracker Jest suites by centralizing the AWF_TOKEN_LOG_DIR temp-directory initialization into a shared helper, ensuring token-persistence.js reads a writable log directory at module load time.

Changes:

  • Added containers/api-proxy/test-helpers/token-tracker-setup.js to set process.env.AWF_TOKEN_LOG_DIR (creating a temp dir when unset).
  • Updated the HTTP, WebSocket, and schema token-tracker test suites to require() the shared setup helper instead of duplicating inline env setup.
Show a summary per file
File Description
containers/api-proxy/token-tracker.websocket.test.js Replaces inline temp-dir/env setup with shared helper require.
containers/api-proxy/token-tracker.schema.test.js Replaces inline temp-dir/env setup with shared helper require.
containers/api-proxy/token-tracker.http.test.js Replaces inline temp-dir/env setup with shared helper require.
containers/api-proxy/test-helpers/token-tracker-setup.js New shared helper that initializes AWF_TOKEN_LOG_DIR for tests.

Copilot's findings

Tip

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

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

@github-actions
Copy link
Copy Markdown
Contributor

🧪 Smoke Test Results

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

Overall: PASS

PR by @Copilot, assignees: @lpcox, @Copilot

📰 BREAKING: Report filed by Smoke Copilot

@github-actions
Copy link
Copy Markdown
Contributor

✅ GitHub API: 2 PR entries verified
✅ Playwright: GitHub site loads with title containing 'GitHub'
✅ File verify: smoke-test file exists

Overall: PASS

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Copy Markdown
Contributor

🔥 Smoke Test: Copilot BYOK (Offline) Mode

Test Result
GitHub MCP (list PRs) ✅ PR #3360 retrieved successfully
GitHub.com connectivity ⚠️ Pre-step data not available (template vars unexpanded)
File write/read ⚠️ Pre-step data not available (template vars unexpanded)
BYOK inference (this response) ✅ Agent running via api-proxy → api.githubcopilot.com

Running in BYOK offline mode (COPILOT_OFFLINE=true) via api-proxy → api.githubcopilot.com.

PR by @Copilot, assignees: @lpcox, @Copilot.

Overall: PARTIAL (MCP + BYOK inference confirmed ✅; pre-step connectivity data unavailable due to unexpanded template variables)

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions github-actions Bot mentioned this pull request May 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test

✅ PR review: chore: recompile all workflow lock files; refactor: split token-tracker.js into four focused modules
❌ Safe Inputs GH CLI: safeinputs-gh unavailable
✅ Playwright: GitHub title verified
❌ Tavily: bridge returned no tools/results
✅ File/bash: temp file created and read
❌ Discussion: github-discussion-query unavailable
✅ Build: npm ci && npm run build
Overall status: FAIL

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

🏗️ 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 #3360 · ● 5.4M ·

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results

  • Redis PING: ❌ (timeout — host.docker.internal:6379 unreachable)
  • PostgreSQL pg_isready: ❌ (host.docker.internal:5432 — no response)
  • PostgreSQL SELECT 1: ❌ (connection failed)

Overall: FAILhost.docker.internal is not resolvable/reachable from this runner environment. Service containers may not be running or host gateway routing is unavailable.

🔌 Service connectivity validated by Smoke Services

@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.15.0 v20.20.2
Go go1.22.12 go1.22.12

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

Tested by Smoke Chroot

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results

  • chore: recompile all workflow lock files
  • refactor: split token-tracker.js into four focused modules
  1. GitHub MCP Testing: ✅
  2. GitHub.com Connectivity: ✅
  3. File Writing Testing: ✅
  4. Bash Tool Testing: ✅

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

@lpcox
Copy link
Copy Markdown
Collaborator

lpcox commented May 18, 2026

@copilot address review feedback

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 18, 2026

@copilot address review feedback

The automated review from @copilot-pull-request-reviewer generated 0 comments — no issues or suggestions were raised. There is no actionable feedback to address.

Copilot finished work on behalf of lpcox May 18, 2026 22:56
@lpcox lpcox merged commit c88d220 into main May 18, 2026
66 of 73 checks passed
@lpcox lpcox deleted the copilot/fix-duplicate-token-setup-code branch May 18, 2026 23:05
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] AWF_TOKEN_LOG_DIR setup block duplicated across three token-tracker test files

3 participants