Skip to content

refactor: split postprocess-smoke-workflows.ts into focused modules#5909

Merged
lpcox merged 2 commits into
mainfrom
copilot/refactor-split-postprocess-smoke-workflows
Jul 5, 2026
Merged

refactor: split postprocess-smoke-workflows.ts into focused modules#5909
lpcox merged 2 commits into
mainfrom
copilot/refactor-split-postprocess-smoke-workflows

Conversation

Copilot AI commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

scripts/ci/postprocess-smoke-workflows.ts was an 874-line flat script mixing four concerns: regex/sentinel constants, YAML step builders, the general patch loop, and the Codex-specific patch loop. The test file worked around the monolithic structure by duplicating ~17 regex constants inline.

Changes

New modules

  • workflow-patch-patterns.ts (~163 lines) — all regex constants, sentinels, and SAFE_XPIA_CONTENT as named exports
  • workflow-step-builders.ts (~151 lines) — all build*Step() and buildXpiaHeredoc() functions as named exports
  • apply-general-workflow-patches.ts (~402 lines) — applyGeneralWorkflowPatches(content, workflowPath): { content, log } extracted from the 432-line imperative loop
  • apply-codex-workflow-patches.ts (~101 lines) — applyCodexWorkflowPatches(content): { content, log } for the Codex-specific transforms

Slimmed orchestrator

  • postprocess-smoke-workflows.ts reduced to ~76 lines: file discovery → call both apply* functions → write on change

Test file cleanup

  • postprocess-smoke-workflows.test.ts now imports the 17 previously-duplicated constants and buildCopySessionStateStep directly from their owning modules, eliminating the duplication:
// Before: inline copy of every pattern, e.g.
const installStepRegex =
  /^(\s*)- name: Install [Aa][Ww][Ff] binary\n.../m;

// After: single import
import {
  installStepRegex,
  duplicateSetupNodeRegex,
  sessionStateDirInjectionRegex,
  // ...14 more
} from './workflow-patch-patterns';
import { buildCopySessionStateStep } from './workflow-step-builders';

No behavioural changes — all transforms are mechanically extracted. All 168 tests across 26 suites continue to pass.

Extract the 874-line monolithic script into five focused modules:

- workflow-patch-patterns.ts (~163 lines): all regex constants,
  sentinel strings, and replacement payloads; exported so the test
  file can import them directly instead of duplicating them

- workflow-step-builders.ts (~151 lines): the five build*Step()
  functions plus buildXpiaHeredoc(), each independently testable

- apply-general-workflow-patches.ts (~402 lines): named exported
  applyGeneralWorkflowPatches(content, workflowPath) function
  extracted from the 432-line imperative loop body

- apply-codex-workflow-patches.ts (~101 lines): named exported
  applyCodexWorkflowPatches(content) function for Codex-specific
  transforms

- postprocess-smoke-workflows.ts (~76 lines): thin orchestration

Update postprocess-smoke-workflows.test.ts to import all 17
duplicated constants and buildCopySessionStateStep directly from the
new modules, eliminating ~70 lines of duplication.

All 168 tests across 26 test suites continue to pass.

Closes #5894
Copilot AI changed the title [WIP] Refactor postprocess-smoke-workflows.ts into focused modules refactor: split postprocess-smoke-workflows.ts into focused modules Jul 4, 2026
Copilot AI requested a review from lpcox July 4, 2026 13:59
Copilot finished work on behalf of lpcox July 4, 2026 13:59
@lpcox lpcox marked this pull request as ready for review July 4, 2026 14:22
@lpcox lpcox requested a review from Copilot July 4, 2026 14:22

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 the smoke-workflow post-processing pipeline by splitting the previously monolithic scripts/ci/postprocess-smoke-workflows.ts into focused, side-effect-free modules. This keeps the orchestration logic minimal while making the regex patterns and YAML fragment builders reusable (notably by tests) without triggering file I/O at import time.

Changes:

  • Extracted all regex constants/sentinels and the SAFE_XPIA_CONTENT payload into a dedicated patterns module.
  • Extracted YAML step-fragment builders into a dedicated builders module.
  • Extracted the general patch loop and the Codex-only patch loop into apply* functions returning { content, log }, leaving postprocess-smoke-workflows.ts as a slim orchestrator.
  • Updated tests to import shared patterns/builders directly, removing duplicated regex definitions.
Show a summary per file
File Description
scripts/ci/postprocess-smoke-workflows.ts Slim orchestrator: discovers lock files, calls applyGeneralWorkflowPatches and Codex-only patches, writes on change.
scripts/ci/workflow-patch-patterns.ts Centralizes exported regex constants, sentinels, and SAFE_XPIA_CONTENT for reuse by patchers and tests.
scripts/ci/workflow-step-builders.ts Centralizes exported YAML step builders (local install, session-state copy, cache hardening steps, XPIA heredoc).
scripts/ci/apply-general-workflow-patches.ts Implements the general post-processing transforms as a pure function returning updated content + logs.
scripts/ci/apply-codex-workflow-patches.ts Implements Codex-only transforms (openai-proxy provider injection + XPIA sanitization) as a pure function.
scripts/ci/postprocess-smoke-workflows.test.ts Removes duplicated patterns by importing from the new modules; adds/reset handling for global-regex lastIndex in relevant tests.

Review details

Tip

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

  • Files reviewed: 6/6 changed files
  • Comments generated: 0
  • Review effort level: Low

@github-actions

github-actions Bot commented Jul 5, 2026

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

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Contribution Check completed successfully!

PR #5909 follows the applicable CONTRIBUTING.md guidelines based on the provided metadata, diff, and contributing guide; no comment needed.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

Smoke test completed with partial failures. File system operations passed, but network and GitHub MCP tools were unreachable.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

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

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (Entra) reports failed. AOAI BYOK (Entra) mode investigation needed...

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation...

No GitHub-side write was possible: discussion comment and PR comment/label attempts were blocked by repository permissions, so this smoke run is read-only.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

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

Copy link
Copy Markdown
Contributor

Chroot tests failed Smoke Chroot failed - See logs for details.

if (!content.includes(cacheDateStepSentinel)) {
const createCacheMatch = content.match(createCacheDirStepRegex);
if (createCacheMatch) {
const indent = createCacheMatch[1];
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 98.59% 98.63% 📈 +0.04%
Statements 98.52% 98.55% 📈 +0.03%
Functions 99.44% 99.44% ➡️ +0.00%
Branches 94.34% 94.34% ➡️ +0.00%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/workdir-setup.ts 93.2% → 94.9% (+1.69%) 93.2% → 94.9% (+1.69%)

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

@github-actions

github-actions Bot commented Jul 5, 2026

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 #5909 · 55.6 AIC · ⊞ 5.8K ·
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) Mode ✅

All tests passed — running in direct BYOK mode via api-proxy → api.githubcopilot.com

  • ✅ GitHub MCP connectivity
  • ✅ GitHub.com connectivity (HTTP 200)
  • ✅ File write/read test (smoke-test-copilot-byok.txt)
  • ✅ BYOK inference path working

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

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Services Connectivity

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

Overall: FAILhost.docker.internal (172.17.0.1) is unreachable from this runner. Service containers may not be running or network routing is unavailable.

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

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot PAT Auth ✅ PASS

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

Overall: PASS · Auth mode: PAT (COPILOT_GITHUB_TOKEN)
Author: @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.

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

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

🔬 Smoke Test Results

Test Status
GitHub MCP Connectivity ✅ PASS
GitHub.com HTTP ⚠️ N/A (pre-step vars unsubstituted)
File Write/Read ⚠️ N/A (pre-step vars unsubstituted)

Overall: PASS — Copilot engine reachable; pre-step data unavailable (unsubstituted template variables in 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.

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

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: API Proxy OpenTelemetry Tracing

Scenario Result Notes
1. Module Loading ✅ Pass otel.js loads; exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled + test internals
2. Test Suite ✅ Pass 59/59 tests pass across otel.test.js and otel-fanout.test.js
3. Env Var Forwarding ✅ Pass 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 ✅ Pass onUsage callback exists in token-tracker-http.js as OTEL hook point
5. OTEL Diagnostics ✅ Pass Graceful degradation confirmed — falls back to /var/log/api-proxy/otel.jsonl when no OTLP endpoint configured

All 5 scenarios pass. OTEL tracing integration is functional.

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 github-actions Bot mentioned this pull request Jul 5, 2026
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Gemini Smoke Test Results

  • GitHub MCP Testing: ❌ (Tools not found)
  • GitHub.com Connectivity: ❌ (HTTP 000)
  • File Writing Testing: ✅
  • 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 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) Mode — Azure OpenAI (Foundry, api-key)

✅ GitHub MCP Testing
✅ GitHub.com Connectivity
✅ File I/O
✅ BYOK Inference

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

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

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

@github-actions

github-actions Bot commented Jul 5, 2026

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 (run: Hello, World!) ✅ PASS
.NET json-parse N/A (run: JSON parsed) ✅ 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

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 #5909 · 42.5 AIC · ⊞ 6.9K ·
Add label ready-for-aw to run again

@lpcox lpcox merged commit c7d69b5 into main Jul 5, 2026
88 of 91 checks passed
@lpcox lpcox deleted the copilot/refactor-split-postprocess-smoke-workflows branch July 5, 2026 03:46
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.

[Refactoring] Split scripts/ci/postprocess-smoke-workflows.ts into focused modules

4 participants