refactor: split postprocess-smoke-workflows.ts into focused modules#5909
Conversation
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
There was a problem hiding this comment.
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_CONTENTpayload 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 }, leavingpostprocess-smoke-workflows.tsas 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
|
✅ Copilot review passed with no inline comments. @copilot Add the |
|
✅ Smoke Claude passed |
|
✅ Build Test Suite completed successfully! |
|
🔌 Smoke Services — All services reachable! ✅ |
|
✅ Contribution Check completed successfully! PR #5909 follows the applicable CONTRIBUTING.md guidelines based on the provided metadata, diff, and contributing guide; no comment needed. |
|
✅ Smoke Gemini completed. All facets verified. 💎 Smoke test completed with partial failures. File system operations passed, but network and GitHub MCP tools were unreachable. |
|
📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅ |
|
✅ Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓 |
|
🚀 Security Guard has started processing this pull request |
|
❌ Smoke Copilot BYOK AOAI (Entra) reports failed. AOAI BYOK (Entra) mode investigation needed... |
|
✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓 |
|
🌑 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. |
|
🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅ |
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
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]; |
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
Smoke Test: Claude Engine Validation
Overall Result: PASS ✅ Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test: Copilot BYOK (Direct) Mode ✅All tests passed — running in direct BYOK mode via api-proxy → api.githubcopilot.com
Status: PASS Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test: Services Connectivity
Overall: FAIL — Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test: Copilot PAT Auth ✅ PASS
Overall: PASS · Auth mode: PAT (COPILOT_GITHUB_TOKEN) Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
🔬 Smoke Test Results
Overall: PASS — Copilot engine reachable; pre-step data unavailable (unsubstituted template variables in workflow). Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test: API Proxy OpenTelemetry Tracing
All 5 scenarios pass. OTEL tracing integration is functional. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Gemini Smoke Test Results
Overall status: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
|
Smoke Test: Copilot BYOK (Direct) Mode — Azure OpenAI (Foundry, api-key) ✅ GitHub MCP Testing Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (o4-mini-aw)
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
scripts/ci/postprocess-smoke-workflows.tswas 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, andSAFE_XPIA_CONTENTas named exportsworkflow-step-builders.ts(~151 lines) — allbuild*Step()andbuildXpiaHeredoc()functions as named exportsapply-general-workflow-patches.ts(~402 lines) —applyGeneralWorkflowPatches(content, workflowPath): { content, log }extracted from the 432-line imperative loopapply-codex-workflow-patches.ts(~101 lines) —applyCodexWorkflowPatches(content): { content, log }for the Codex-specific transformsSlimmed orchestrator
postprocess-smoke-workflows.tsreduced to ~76 lines: file discovery → call bothapply*functions → write on changeTest file cleanup
postprocess-smoke-workflows.test.tsnow imports the 17 previously-duplicated constants andbuildCopySessionStateStepdirectly from their owning modules, eliminating the duplication:No behavioural changes — all transforms are mechanically extracted. All 168 tests across 26 suites continue to pass.