Skip to content

Commit 38fcca5

Browse files
authored
ci: add windows test (#61)
1 parent 2216330 commit 38fcca5

File tree

8 files changed

+191
-27
lines changed

8 files changed

+191
-27
lines changed

.github/workflows/test-ubuntu.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ jobs:
4242
changed:
4343
- "!**/*.md"
4444
- "!**/*.mdx"
45+
- "!**/_meta.json"
46+
- "!**/dictionary.txt"
4547
4648
- name: Setup Node.js ${{ matrix.node-version }}
4749
if: steps.changes.outputs.changed == 'true'
@@ -83,6 +85,8 @@ jobs:
8385
changed:
8486
- "!**/*.md"
8587
- "!**/*.mdx"
88+
- "!**/_meta.json"
89+
- "!**/dictionary.txt"
8690
8791
- name: Setup Node.js ${{ matrix.node-version }}
8892
if: steps.changes.outputs.changed == 'true'

.github/workflows/test-windows.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Test (Windows)
2+
3+
# Controls when the action will run.
4+
on:
5+
# Triggers the workflow on pull request events but only for the main branch
6+
pull_request:
7+
branches: [main]
8+
9+
push:
10+
branches: [main]
11+
12+
merge_group:
13+
14+
# Allows you to run this workflow manually from the Actions tab
15+
workflow_dispatch:
16+
17+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
18+
jobs:
19+
# ======== ut ========
20+
ut-windows:
21+
runs-on: windows-latest
22+
strategy:
23+
matrix:
24+
node-version: [18.x]
25+
26+
# Steps represent a sequence of tasks that will be executed as part of the job
27+
steps:
28+
- name: Git config
29+
shell: bash
30+
run: |
31+
git config --system core.longpaths true
32+
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 10
37+
38+
- name: Install Pnpm
39+
run: corepack enable
40+
41+
- uses: dorny/paths-filter@v3
42+
id: changes
43+
with:
44+
predicate-quantifier: 'every'
45+
filters: |
46+
changed:
47+
- "!**/*.md"
48+
- "!**/*.mdx"
49+
- "!**/_meta.json"
50+
- "!**/dictionary.txt"
51+
52+
- name: Setup Node.js ${{ matrix.node-version }}
53+
if: steps.changes.outputs.changed == 'true'
54+
uses: actions/setup-node@v4
55+
with:
56+
node-version: ${{ matrix.node-version }}
57+
cache: 'pnpm'
58+
59+
- name: Install Dependencies
60+
if: steps.changes.outputs.changed == 'true'
61+
run: pnpm install
62+
63+
- name: Unit Test
64+
if: steps.changes.outputs.changed == 'true'
65+
run: pnpm run test:unit
66+
67+
# # ======== e2e ========
68+
e2e-windows:
69+
runs-on: windows-latest
70+
strategy:
71+
matrix:
72+
node-version: [18.x]
73+
74+
# Steps represent a sequence of tasks that will be executed as part of the job
75+
steps:
76+
- name: Git config
77+
shell: bash
78+
run: |
79+
git config --system core.longpaths true
80+
81+
- name: Checkout
82+
uses: actions/checkout@v4
83+
with:
84+
fetch-depth: 10
85+
86+
- name: Install Pnpm
87+
run: corepack enable
88+
89+
- uses: dorny/paths-filter@v3
90+
id: changes
91+
with:
92+
predicate-quantifier: 'every'
93+
filters: |
94+
changed:
95+
- "!**/*.md"
96+
- "!**/*.mdx"
97+
- "!**/_meta.json"
98+
- "!**/dictionary.txt"
99+
100+
- name: Setup Node.js ${{ matrix.node-version }}
101+
if: steps.changes.outputs.changed == 'true'
102+
uses: actions/setup-node@v4
103+
with:
104+
node-version: ${{ matrix.node-version }}
105+
cache: 'pnpm'
106+
107+
- name: Install Dependencies
108+
if: steps.changes.outputs.changed == 'true'
109+
run: pnpm install && cd ./e2e && npx playwright install
110+
111+
- name: E2E Test
112+
if: steps.changes.outputs.changed == 'true'
113+
run: |
114+
pnpm run test:artifact
115+
pnpm run test:e2e
116+
117+
- name: Examples Test
118+
if: steps.changes.outputs.changed == 'true'
119+
run: |
120+
pnpm run build:examples

e2e/cases/alias/__snapshots__/index.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ console.info(a);
1313
`;
1414

1515
exports[`source.alias 2`] = `
16-
""use strict";
16+
"\\"use strict\\";
1717
var __webpack_exports__ = {};
1818
1919
;// CONCATENATED MODULE: ./src/a.ts

e2e/cases/syntax/__snapshots__/index.test.ts.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ export { Foo };
2020

2121
exports[`should downgrade class private method with output.syntax config 1`] = `
2222
"
23-
;// CONCATENATED MODULE: ../../../../node_modules/.pnpm/@[email protected]/node_modules/@swc/helpers/esm/_class_private_method_get.js
23+
;// CONCATENATED MODULE: ../../../../node_modules/<PNPM_INNER>/@swc/helpers/esm/_class_private_method_get.js
2424
function _class_private_method_get(receiver, privateSet, fn) {
25-
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
25+
if (!privateSet.has(receiver)) throw new TypeError(\\"attempted to get private field on non-instance\\");
2626
2727
return fn;
2828
}
2929
3030
31-
;// CONCATENATED MODULE: ../../../../node_modules/.pnpm/@[email protected]/node_modules/@swc/helpers/esm/_check_private_redeclaration.js
31+
;// CONCATENATED MODULE: ../../../../node_modules/<PNPM_INNER>/@swc/helpers/esm/_check_private_redeclaration.js
3232
function _check_private_redeclaration(obj, privateCollection) {
3333
if (privateCollection.has(obj)) {
34-
throw new TypeError("Cannot initialize the same private elements twice on an object");
34+
throw new TypeError(\\"Cannot initialize the same private elements twice on an object\\");
3535
}
3636
}
3737
3838
39-
;// CONCATENATED MODULE: ../../../../node_modules/.pnpm/@[email protected]/node_modules/@swc/helpers/esm/_class_private_method_init.js
39+
;// CONCATENATED MODULE: ../../../../node_modules/<PNPM_INNER>/@swc/helpers/esm/_class_private_method_init.js
4040
4141
4242
function _class_private_method_init(obj, privateSet) {

e2e/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@types/node": "~18.19.39",
1919
"@types/react": "^18.3.3",
2020
"fast-glob": "^3.3.2",
21-
"fs-extra": "^11.2.0"
21+
"fs-extra": "^11.2.0",
22+
"path-serializer": "0.0.6"
2223
}
2324
}

e2e/setupVitestTests.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
import path from 'node:path';
12
import process from 'node:process';
2-
import { beforeEach } from 'vitest';
3+
import { createSnapshotSerializer } from 'path-serializer';
4+
import { beforeEach, expect } from 'vitest';
35

46
beforeEach(() => {
57
// since our NODE_ENV injection logic is via cli, we need to
68
// delete "test" NODE_ENV to avoid affecting the default build config
79
delete process.env.NODE_ENV;
810
});
11+
12+
expect.addSnapshotSerializer(
13+
createSnapshotSerializer({
14+
workspace: path.join(__dirname, '..'),
15+
}),
16+
);

packages/core/tests/lcp.test.ts

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os from 'node:os';
12
import { vol } from 'memfs';
23
import { beforeEach, describe, expect, it, vi } from 'vitest';
34
import { calcLongestCommonPath } from '../src/utils/helper';
@@ -19,35 +20,57 @@ describe('LCP calculate correctly', () => {
1920
it('correct 1', async () => {
2021
vol.fromJSON({ '/Users/Someone/project-a/src': null });
2122

22-
const result = await calcLongestCommonPath([
23-
'/Users/Someone/project-a/src/helpers',
24-
'/Users/Someone/project-a/src',
25-
'/Users/Someone/project-a/src/utils',
26-
]);
27-
expect(result).toBe('/Users/Someone/project-a/src');
23+
if (os.platform() !== 'win32') {
24+
const result = await calcLongestCommonPath([
25+
'/Users/Someone/project-a/src/helpers',
26+
'/Users/Someone/project-a/src',
27+
'/Users/Someone/project-a/src/utils',
28+
]);
29+
expect(result).toEqual('/Users/Someone/project-a/src');
30+
} else {
31+
const result = await calcLongestCommonPath([
32+
'D:\\Users\\Someone\\project-a\\src\\helpers',
33+
'D:\\Users\\Someone\\project-a\\src',
34+
'D:\\Users\\Someone\\project-a\\src\\utils',
35+
]);
36+
expect(result).toEqual('D:\\Users\\Someone\\project-a\\src');
37+
}
2838
});
2939

3040
it('correct 2', async () => {
3141
vol.fromJSON({ '/Users/Someone/project-monorepo': null });
3242

33-
const result = await calcLongestCommonPath([
34-
'/Users/Someone/project-monorepo/packages-a/src/index.ts',
35-
'/Users/Someone/project-monorepo/packages-util/src/index.js',
36-
'/Users/Someone/project-monorepo/script.js',
37-
]);
38-
39-
expect(result).toBe('/Users/Someone/project-monorepo');
43+
if (os.platform() !== 'win32') {
44+
const result = await calcLongestCommonPath([
45+
'/Users/Someone/project-monorepo/packages-a/src/index.ts',
46+
'/Users/Someone/project-monorepo/packages-util/src/index.js',
47+
'/Users/Someone/project-monorepo/script.js',
48+
]);
49+
expect(result).toEqual('/Users/Someone/project-monorepo');
50+
} else {
51+
const result = await calcLongestCommonPath([
52+
'D:\\Users\\Someone\\project-monorepo\\packages-a\\src\\index.ts',
53+
'D:\\Users\\Someone\\project-monorepo\\packages-util\\src\\index.js',
54+
'D:\\Users\\Someone\\project-monorepo\\script.js',
55+
]);
56+
expect(result).toEqual('D:\\Users\\Someone\\project-monorepo');
57+
}
4058
});
4159

4260
it('correct 3', async () => {
4361
vol.fromJSON({
4462
'/Users/Someone/project/src/index.js': '',
4563
});
46-
47-
const result = await calcLongestCommonPath([
48-
'/Users/Someone/project/src/index.js',
49-
]);
50-
51-
expect(result).toBe('/Users/Someone/project/src');
64+
if (os.platform() !== 'win32') {
65+
const result = await calcLongestCommonPath([
66+
'/Users/Someone/project/src/index.js',
67+
]);
68+
expect(result).toEqual('/Users/Someone/project/src');
69+
} else {
70+
const result = await calcLongestCommonPath([
71+
'D:\\Users\\Someone\\project\\src\\index.js',
72+
]);
73+
expect(result).toEqual('D:\\Users\\Someone\\project\\src');
74+
}
5275
});
5376
});

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)