Skip to content

Deduplicate main-action Jest harness setup across coverage-gap suites - #6691

Merged
lpcox merged 3 commits into
mainfrom
copilot/fix-duplicate-test-setup
Jul 28, 2026
Merged

Deduplicate main-action Jest harness setup across coverage-gap suites#6691
lpcox merged 3 commits into
mainfrom
copilot/fix-duplicate-test-setup

Conversation

Copilot AI commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Both main-action test suites repeated the same fs mock boilerplate and harness-adjacent setup patterns, creating sync risk and unnecessary maintenance churn. This PR consolidates the duplicated fs mock wiring into a shared test utility and updates both suites to consume it.

  • What changed

    • Added src/commands/main-action-fs-mock.test-utils.ts to centralize shared fs mock state and factory logic.
    • Replaced inline jest.mock('fs', ...) blocks in:
      • src/commands/main-action.test.ts
      • src/commands/main-action-coverage-gaps.test.ts
    • Kept per-suite behavior intact by reusing the same named mock handles (mkdirSync, writeFileSync, chmodSync, openSync, closeSync) via shared exports.
  • Why this refactor matters

    • Removes duplicate mock wiring from both suites.
    • Reduces drift risk when mock behavior needs to change.
    • Keeps setup intent explicit while moving implementation to one source of truth.
  • Example

    // shared utility
    export const mainActionFsMocks = {
      mkdirSync: jest.fn(),
      writeFileSync: jest.fn(),
      chmodSync: jest.fn(),
      openSync: jest.fn().mockReturnValue(42),
      closeSync: jest.fn(),
    };
    
    export function mainActionFsMockFactory() {
      const actual = jest.requireActual<typeof import('fs')>('fs');
      return {
        ...actual,
        mkdirSync: (...args: unknown[]) => mainActionFsMocks.mkdirSync(...args),
        writeFileSync: (...args: unknown[]) => mainActionFsMocks.writeFileSync(...args),
        chmodSync: (...args: unknown[]) => mainActionFsMocks.chmodSync(...args),
        openSync: (...args: unknown[]) => mainActionFsMocks.openSync(...args),
        closeSync: (...args: unknown[]) => mainActionFsMocks.closeSync(...args),
      };
    }

Copilot AI changed the title [WIP] Fix duplicate code in main-action test setup Deduplicate main-action Jest harness setup across coverage-gap suites Jul 28, 2026
Copilot finished work on behalf of lpcox July 28, 2026 16:45
Copilot AI requested a review from lpcox July 28, 2026 16:45
@lpcox
lpcox marked this pull request as ready for review July 28, 2026 16:48
Copilot AI review requested due to automatic review settings July 28, 2026 16:48

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

Centralizes duplicated filesystem mocks used by the main-action Jest suites.

Changes:

  • Adds a shared filesystem mock factory and mock handles.
  • Updates both main-action suites to consume the utility.
Show a summary per file
File Description
src/commands/main-action-fs-mock.test-utils.ts Defines shared filesystem mocks.
src/commands/main-action.test.ts Uses shared mocks and handles.
src/commands/main-action-coverage-gaps.test.ts Uses the shared mock factory.

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: 2
  • Review effort level: Medium

Comment thread src/commands/main-action.test.ts Outdated
Comment on lines +1 to +3
import { mainActionFsMockFactory, mainActionFsMocks } from './main-action-fs-mock.test-utils';

jest.mock('fs', () => mainActionFsMockFactory());
closeSync: (...args: unknown[]) => mockCloseSync(...args),
};
});
jest.mock('fs', () => mainActionFsMockFactory());
@lpcox

lpcox commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

Copilot AI commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback

Fixed in the latest commit. Both jest.mock('fs', ...) calls now use lazy require inside the factory callback instead of closing over the imported mainActionFsMockFactory binding — matching the pattern used in src/workdir-setup.test.ts:5-12. All 43 tests continue to pass.

Copilot finished work on behalf of lpcox July 28, 2026 17:16
@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 Regression Detected

This PR decreases test coverage. Please add tests to maintain coverage levels.

Overall Coverage

Metric Base PR Delta
Lines 99.17% 99.19% 📈 +0.02%
Statements 99.07% 99.09% 📈 +0.02%
Functions 99.45% 99.35% 📉 -0.10%
Branches 95.75% 95.75% ➡️ +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/main-action-fs-mock.test-utils.ts: 88.9% lines

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

@github-actions

github-actions Bot commented Jul 28, 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 Jul 28, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Contribution Check completed successfully!

Contribution check complete for PR #6691: no actionable guideline violations found in the provided context.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 28, 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 28, 2026

Copy link
Copy Markdown
Contributor

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

@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

Generated by Smoke Claude for #6691 · haiku45 · 31.4 AIC · ⊞ 3.3K ·
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

🔒 Smoke Test: Copilot Network Isolation

@lpcox

EGRESS_RESULT allow=pass deny=pass

  • ✅ Allowed domain (api.github.com) — HTTP 200
  • ✅ Blocked domain (example.com) — 403 proxy denial

Overall: PASS

Warning

Firewall blocked 1 domain

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

  • example.com

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

network:
  allowed:
    - defaults
    - "example.com"

See Network Configuration for more information.

🛡️ Egress verdict from Smoke Copilot Network Isolation
Add label ready-for-aw to run again

@github-actions github-actions Bot added the smoke-copilot-network-isolation Copilot network-isolation egress smoke test label Jul 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔥 Smoke Test: Copilot BYOK (Direct) — PASS

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

Test Result
GitHub MCP connectivity
GitHub.com connectivity (HTTP 200)
File write/read
BYOK inference (agent → api-proxy → api.githubcopilot.com)

Overall: PASS@lpcox

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: GitHub Actions Services Connectivity

Check Result
Redis PING ❌ Name resolution failed for host.docker.internal
PostgreSQL pg_isready ❌ No response
PostgreSQL SELECT 1 ❌ Name resolution failed

Overall: FAILhost.docker.internal is not resolvable in this environment. The AWF sandbox cannot reach the service containers.

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

@github-actions

Copy link
Copy Markdown
Contributor

🔬 Smoke Test Results

Test Result
GitHub MCP Connectivity ⚠️ Filtered by secrecy policy
GitHub.com HTTP ✅ 200 OK
File Write/Read ⚠️ Pre-step data not expanded

Overall: PARTIAL — core HTTP connectivity passed; pre-computed smoke data unavailable (template variables not expanded at runtime).

@lpcox

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

@github-actions

Copy link
Copy Markdown
Contributor

Gemini Smoke Test Results

  1. GitHub MCP Testing: ❌ (Results filtered by secrecy policy)
  2. GitHub.com Connectivity: ❌ (Network unreachable)
  3. File Writing Testing: ✅
  4. Bash Tool Testing: ✅

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
Add label ready-for-aw to run again

@github-actions github-actions Bot mentioned this pull request Jul 28, 2026
@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.13 ✅ YES
Node.js v24.18.0 v22.23.1 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Result: FAILED — Node.js version mismatch (host v24.18.0 vs chroot v22.23.1).

Tested by Smoke Chroot
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): The default Maven local repo path /home/runner/.m2/repository was owned by root (no write permission). Resolved by using -Dmaven.repo.local=/tmp/gh-aw/agent/m2-repo as a writable alternative. All Maven downloads, compiles, and tests succeeded.

Generated by Build Test Suite for #6691 · sonnet46 · 46.4 AIC · ⊞ 8.4K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🔬 Smoke Test: API Proxy OpenTelemetry Tracing

Scenario Result Notes
1. Module Loading otel.js loads successfully; exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled
2. Test Suite otel.test.js exists with full test coverage using InMemorySpanExporter; otel-fanout.test.js also present
3. Env Var Forwarding src/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 Integration onUsage callback present in token-tracker-http.js (line 348/406) as the OTEL hook point
5. OTEL Diagnostics Module reports isEnabled: true (file fallback to /var/log/api-proxy/otel.jsonl when no OTLP endpoint configured)

Summary: All 5 scenarios pass. OTEL tracing integration is complete — span creation, token usage attributes (GenAI semantic conventions), parent context propagation, OTLP fan-out export, and graceful degradation via file fallback are all implemented and tested.

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

@github-actions

Copy link
Copy Markdown
Contributor

Reviewed PRs: feat(api-proxy): use runtime model metadata and pricing overlays; chore: upgrade gh-aw extension to v0.83.4 pre-release and recompile workflows
GitHub reads: ✅
Playwright: ✅
File write/read: ✅
Build: ❌ (npm ci hit 403 on yocto-queue)
Overall: 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
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Smoke Test: Docker Sbx — PASS

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

Overall: PASS @lpcox

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

@lpcox
lpcox merged commit ccee1ee into main Jul 28, 2026
135 of 139 checks passed
@lpcox
lpcox deleted the copilot/fix-duplicate-test-setup branch July 28, 2026 22:42
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] Main-action test harness setup is duplicated across coverage-gap suites

3 participants