Skip to content

@W-20937015: Adding windows test support#359

Merged
amit-kumar8-sf merged 10 commits intomainfrom
feature-W-20937015-add-windows-testing-support
Apr 21, 2026
Merged

@W-20937015: Adding windows test support#359
amit-kumar8-sf merged 10 commits intomainfrom
feature-W-20937015-add-windows-testing-support

Conversation

@amit-kumar8-sf
Copy link
Copy Markdown
Collaborator

@amit-kumar8-sf amit-kumar8-sf commented Apr 20, 2026

Summary

Adds Windows CI coverage for the B2C developer tooling monorepo by introducing a sibling test-windows job alongside the existing Linux test job in ci.yml, following the pwa-kit pattern (pwa-kit / pwa-kit-windows).

  • New composite action .github/actions/setup-windows/action.yml — Node + pnpm + pnpm-store cache + pnpm install --frozen-lockfile for reuse across all Windows jobs.
  • .github/workflows/ci.yml — new test-windows job (matrix: [22.x, 24.x]) running SDK → MCP → CLI → VS Extension checks with Windows-suffixed coverage and test-result artifacts. Includes a diagnostic Print Windows test failures step that parses each package's test-results.json and echoes failing titles + error snippets to the job log (Mocha's JSON reporter otherwise hides the failures behind an opaque non-zero exit code).
  • .github/workflows/e2e-tests.yml + .github/workflows/e2e-shell-tests.yml — bash-default shell wiring so existing E2E matrices can be extended to Windows in a follow-up without re-doing shell quirks.
  • Test fixes for Windows path/permission assumptions (behavior unchanged on POSIX):
    • packages/b2c-tooling-sdk/test/operations/debug/source-mapping.test.ts — use path.resolve so expectations match the drive-prefixed absolute path production returns on Windows.
    • packages/b2c-tooling-sdk/test/discovery/utils.test.ts — normalize glob results to POSIX slashes before asserting.
    • packages/b2c-tooling-sdk/test/scaffold/registry.test.ts — assert SCAFFOLDS_DATA_DIR via path.join('data', 'scaffolds') so the substring check works on both separators.
    • packages/b2c-dx-mcp/test/tools/mrt/index.test.ts — switch 4 path.join(projectDir, 'build') expectations to path.resolve(...) (matches services.resolveWithProjectDirectory).
    • packages/b2c-dx-mcp/test/services.test.tspath.resolve(projectDir, 'subdir') assertion.
    • packages/b2c-cli/test/commands/mrt/save-credentials.test.ts — skip the 0o600 mode-bit assertion on win32; NTFS doesn't honor POSIX mode bits, credential files are protected via ACLs.
  • Production fixes for real Windows bugs uncovered by the new matrix:
    • packages/b2c-tooling-sdk/src/plugins/loader.ts — convert hook path to a file:// URL via pathToFileURL(hookFilePath).href before dynamic import(). Node's ESM import() on Windows rejects raw backslash/drive-letter paths. Without this fix, every hook-based plugin silently failed to load on Windows.
    • packages/b2c-dx-mcp/src/tools/storefrontnext/site-theming/theming-store.ts — replace filePath.startsWith('/') (POSIX-only absolute detection) with path.isAbsolute() so THEMING_FILES env entries resolve on both platforms; harden emoji-anchored section regexes with explicit Unicode escapes (\u26A0\uFE0F?, \u{1F4CB}, \u{1F504}, \u2705, \u{1F4DD}) and \r?\n CRLF tolerance to be robust against Git line-ending conversion on Windows checkouts.
  • packages/b2c-cli/package.json — new sibling script test:ci:win that runs the same Mocha suite with c8 --check-coverage=false. Used only by the Windows CI step; Linux test:ci is untouched and continues to enforce the 70% function-coverage gate.

Design notes:

  • Sibling job (not an os matrix row) — keeps the existing Ubuntu job untouched, allows an independent Windows Node matrix, and produces clearly labelled Windows reports/artifacts.
  • All Windows jobs use defaults.run.shell: bash so the existing env VAR=value mocha … inline-env npm scripts keep working unchanged under Git Bash — no cross-env dependency or script rewrites required.
  • ${{ runner.os }} produces a distinct Windows-pnpm-store-* cache key, preventing cross-OS cache pollution.
  • Advisory rollout: test-windows is marked continue-on-error: true. Windows coverage is new and the last infrastructure-level quirk (V8 coverage on Windows double-counting some TS files via the tsx loader registering them under two URL casings, dragging CLI function coverage from ~78% down to ~68%) is surfaced but not gated. The per-matrix test-results-windows-node-* artifact is always uploaded and the diagnostic Print Windows test failures step renders failures inline, so any remaining platform-specific issue can be read directly from the Actions run. Each job has a comment flagging that continue-on-error should be removed once Windows tests are consistently green.

Testing

Infrastructure + cross-platform test-hardening change; verified as follows:

  • YAML parses cleanly on all edited workflow files.
  • Scoped unit-test runs on POSIX (macOS) after every change:
    • b2c-tooling-sdk operations/debug, plugins, scaffold, discovery — 209 passing.
    • b2c-dx-mcp mrt + site-theming — 149 passing.
    • b2c-cli mrt — 13 passing.
  • c8 --check-coverage=false confirmed locally to disable the threshold gate while still producing coverage/lcov.info for artifact upload.
  • No new linter errors on any touched file (pnpm run lint in each affected package).
  • End-to-end validation of the new Windows matrix happens on the first PR run (test-windows at [22.x, 24.x]). The previous 24-failure baseline from the last Windows run is now expected to drop to 0 blocking failures with this PR.

Dependencies

  • No net-new third-party dependencies were added
  • If net-new third-party dependencies were added, rationale/discussion is included and 3pl-approved is set by a maintainer

  • Tests pass (pnpm test) — all scoped suites pass locally on macOS; Windows matrix runs with continue-on-error: true during the advisory rollout
  • Code is formatted (pnpm run format) — ran lint on every modified file, no linter errors

@amit-kumar8-sf amit-kumar8-sf requested a review from clavery as a code owner April 20, 2026 12:13
Copy link
Copy Markdown
Collaborator

@clavery clavery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good. I like that we're skipping errors for now. Will test the loader.ts change

@amit-kumar8-sf amit-kumar8-sf merged commit b324de6 into main Apr 21, 2026
5 checks passed
@amit-kumar8-sf amit-kumar8-sf deleted the feature-W-20937015-add-windows-testing-support branch April 21, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants