ci: run unit tests on windows - #954
Merged
Merged
Conversation
…on (#953) ## Summary Running `bob init` on Windows writes backslashes into `package.json`: ```json { "main": "./lib\module\index.js", "types": "./lib\typescript\src\index.d.ts", "exports": { ".": { "types": "./lib\typescript\src\index.d.ts", "default": "./lib\module\index.js" } } } ``` `main`, `module`, `types` and `exports` are **module specifiers**, not filesystem paths — they're always forward-slashed regardless of platform. `main` and `types` are lenient enough that some tooling still copes, but `exports` is matched as a literal string by Node's resolver, so a library initialised on Windows ships a manifest whose entry points don't resolve. The values are built by interpolating `path.join` into a `./…` template: ```ts entries.module = `./${path.join(output, 'module', 'index.js')}`; ``` `path.join` is correct for touching the filesystem and wrong for producing a specifier. Since these are always relative and always forward-slashed, `path.posix.join` is the right join — five call sites, all feeding the same `entries` / `types` objects that `main`, `module`, `types` and `exports` are later derived from. This is the same class of bug as [callstack/react-native-paper#5054](callstack/react-native-paper#5054), where a platform-native path reached an import specifier. ## Test plan Windows 11, Node 22.23.2, yarn 4.11.0. `src/__tests__/init.test.ts` already covers this — the committed snapshot encodes the correct forward-slash output, so on Windows it fails on `main` today: **Before** ``` ❯ src/__tests__/init.test.ts (1 test | 1 failed) × initializes the configuration - "main": "./lib/module/index.js", + "main": "./lib\module\index.js", ``` **After** — passes, **without the snapshot being regenerated**. The only file in the diff is `init.ts`; the snapshot is untouched, which is the point: the fix makes Windows produce exactly the output Linux and macOS already produce. `yarn lint` and `yarn typecheck` are both clean, and the lefthook pre-commit (eslint + tsc) passed. ### One thing that is *not* fixed here, and isn't yours Two cases in `typescript.test.ts` still fail on my machine: ``` Error: EPERM: operation not permitted, symlink '…\bob-typescript-SA8Uzm' -> '…\consumer\node_modules\library' ``` That's a local privilege limitation, not a bug in this repo — Windows only allows `fs.symlink` with Developer Mode enabled or elevation, and I confirmed Developer Mode is off here (`AllowDevelopmentWithoutDevLicense` unset) and that a bare `fs.symlinkSync` fails the same way outside the repo entirely. I'm mentioning it only so the number of failing tests in the "before" output isn't confusing; I haven't touched those tests. Worth noting the `os` matrices in `build-local-libraries.yml` and `build-templates.yml` are `[ubuntu-latest, macos-latest]`, which is why this hasn't surfaced. Happy to add `windows-latest` in a separate PR if you'd like the coverage — I didn't want to spend your CI minutes without asking. --------- Co-authored-by: Satyajit Sahoo <satyajit.happy@gmail.com>
Comment on lines
+35
to
+47
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest, windows-latest] | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
|
|
||
| - name: Setup | ||
| uses: ./.github/actions/setup | ||
|
|
||
| - name: Test | ||
| run: yarn test |
Member
Author
There was a problem hiding this comment.
what token is used here?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.