VotingSmall

Fix Windows test portability (fileURLToPath in 6 tests, .gitattributes LF) and add test.yml CI on Ubuntu + Windows

Proposed by Jonathan Miller 1 hour ago
Specification

Motivation

On Windows, several tests build filesystem paths with new URL(...).pathname. That yields /C:/..., or C:\C:\... once resolved, instead of a native path. Separately, git's default core.autocrlf=true on Windows checks files out with CRLF line endings, which makes scripts/verify-ai-contract.mjs report 34 false failures. The proposer verified that with the fixes below, npm test passes on Windows 10 (117/117, plus 42/42 for SynthMCP).

There is currently no standalone test workflow. Tests run only inside pages.yml and release.yml after a push to main, on ubuntu-latest with Node 20.

Scope

  1. Path fixes. Replace new URL(..., import.meta.url).pathname (and similar .pathname-as-filesystem-path uses) with fileURLToPath(...) imported from node:url in:
    • packages/synthmcp/test/drift.test.js: the expected path in the "by default the server reads the repository's synthcss.ai.json through the synthcss package" test, i.e. fileURLToPath(REPO_CONTRACT).
    • scripts/check-base.test.mjs
    • scripts/check-components.test.mjs
    • scripts/check-layout.test.mjs
    • scripts/check-showcase.test.mjs
    • scripts/verify-ai-contract.test.mjs
    • Any other test file found by grep (see acceptance criteria) using a URL pathname as a filesystem path.
  2. Line endings. Add a root .gitattributes containing * text=auto eol=lf.
    • Assumption: if any binary assets exist (e.g. images or fonts), also add binary entries for their extensions so they are not normalised.
  3. CI. Add a new .github/workflows/test.yml that:
    • runs on pull_request and on push to main;
    • uses a matrix with os: [ubuntu-latest, windows-latest];
    • sets up Node 20 via actions/setup-node;
    • runs npm ci and then npm test.
    • Assumption: npm test already includes the SynthMCP tests. If it does not, also run npm run test:mcp.

Acceptance criteria

  • All six named test files import fileURLToPath from node:url and no longer derive filesystem paths from .pathname.
  • grep -rn "\.pathname" scripts packages/*/test test --include=*.js --include=*.mjs shows no remaining use of a URL pathname as a filesystem path or compared with one.
  • .gitattributes exists at the repo root and contains * text=auto eol=lf.
  • .github/workflows/test.yml exists, is valid YAML, has the triggers, OS matrix and Node 20 setup described above, and runs npm ci and npm test.
  • pages.yml and release.yml are unchanged.
  • npm test and npm run test:mcp pass in the sandbox (Linux).
  • No changes to SynthMCP runtime source (anything under packages/synthmcp/ outside test/) or to non-test scripts such as scripts/verify-ai-contract.mjs.

Out of scope

  • Any change to SynthMCP's runtime path resolution.
  • macOS runners and Node version matrices.
  • Modifying the deploy workflows.
  • Refactoring tests beyond the path fixes.
  • Renormalising existing files' line endings beyond what .gitattributes implies.
Discussion · 0

No comments yet.