Skip to content

Commit 54831e1

Browse files
committed
setup integration-advanced-esm
1 parent 7abf743 commit 54831e1

File tree

4 files changed

+136
-137
lines changed

4 files changed

+136
-137
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Reusable Common
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
runner:
7+
required: true
8+
type: string
9+
node-version:
10+
required: true
11+
type: string
12+
task:
13+
required: true
14+
type: string
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
run:
21+
runs-on: ${{ inputs.runner }}
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
25+
with:
26+
fetch-depth: 1
27+
28+
- name: Git config
29+
if: ${{ inputs.runner == 'windows-latest' }}
30+
shell: bash
31+
run: |
32+
git config --system core.longpaths true
33+
34+
- name: Install pnpm
35+
run: |
36+
npm install -g corepack@latest --force
37+
corepack enable
38+
39+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
40+
id: changes
41+
with:
42+
predicate-quantifier: 'every'
43+
filters: |
44+
changed:
45+
- "!**/*.md"
46+
- "!**/*.mdx"
47+
- "!**/_meta.json"
48+
- "!**/dictionary.txt"
49+
50+
- name: Setup Node.js ${{ inputs.node-version }}
51+
if: ${{ steps.changes.outputs.changed == 'true' }}
52+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
53+
with:
54+
node-version: ${{ inputs.node-version }}
55+
cache: 'pnpm'
56+
57+
# Special handling for Node.js 18: use Node.js 20 for tsgo dependency installation
58+
- name: Setup Node.js 20 for dependency installation (Node 18 only)
59+
if: ${{ steps.changes.outputs.changed == 'true' && inputs.node-version == '18' }}
60+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
61+
with:
62+
node-version: 20
63+
cache: 'pnpm'
64+
65+
- name: Install Dependencies
66+
if: ${{ steps.changes.outputs.changed == 'true' }}
67+
run: pnpm install
68+
69+
- name: Install Playwright browsers (only for integration-e2e)
70+
if: ${{ steps.changes.outputs.changed == 'true' && inputs.task == 'integration-e2e' }}
71+
run: |
72+
cd ./tests || exit 0
73+
pnpm playwright install chromium
74+
75+
# Switch back to Node.js 18 after dependency installation
76+
- name: Switch back to Node.js ${{ inputs.node-version }} (Node 18 only)
77+
if: ${{ steps.changes.outputs.changed == 'true' && inputs.node-version == '18' }}
78+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
79+
with:
80+
node-version: ${{ inputs.node-version }}
81+
cache: 'pnpm'
82+
83+
- name: Type Check
84+
if: ${{ steps.changes.outputs.changed == 'true' && inputs.task == 'ut' }}
85+
run: pnpm run type-check
86+
87+
- name: Unit Test
88+
if: ${{ steps.changes.outputs.changed == 'true' && inputs.task == 'ut' }}
89+
run: pnpm run test:unit
90+
91+
- name: Integration Test (Rstest)
92+
if: ${{ steps.changes.outputs.changed == 'true' && inputs.task == 'integration-e2e' }}
93+
run: pnpm run test:integration
94+
95+
- name: Integration Test with Advanced ESM (Rstest)
96+
if: ${{ steps.changes.outputs.changed == 'true' && inputs.task == 'integration-advanced-esm' }}
97+
run: pnpm run test:integration:advanced-esm
98+
99+
- name: E2E Test (Playwright)
100+
if: ${{ steps.changes.outputs.changed == 'true' && inputs.task == 'integration-e2e' }}
101+
run: pnpm run test:e2e

.github/workflows/test.yml

Lines changed: 28 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -13,150 +13,44 @@ permissions:
1313
contents: read
1414

1515
jobs:
16-
# ======== ut ========
1716
ut:
18-
runs-on: ${{ matrix.os }}
1917
strategy:
2018
matrix:
21-
os: [ubuntu-latest]
19+
runner: [ubuntu-latest]
2220
node-version: [18, 20, 22]
2321
include:
2422
- node-version: 18
25-
os: windows-latest
23+
runner: windows-latest
24+
uses: ./.github/workflows/reusable-common.yml
25+
with:
26+
runner: ${{ matrix.runner }}
27+
node-version: ${{ matrix.node-version }}
28+
task: ut
2629

27-
steps:
28-
- name: Checkout
29-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
30-
with:
31-
fetch-depth: 1
32-
33-
- name: Git config
34-
if: ${{ matrix.os == 'windows-latest' }}
35-
shell: bash
36-
run: |
37-
git config --system core.longpaths true
38-
39-
- name: Install pnpm
40-
run: |
41-
npm install -g corepack@latest --force
42-
corepack enable
43-
44-
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
45-
id: changes
46-
with:
47-
predicate-quantifier: 'every'
48-
filters: |
49-
changed:
50-
- "!**/*.md"
51-
- "!**/*.mdx"
52-
- "!**/_meta.json"
53-
- "!**/dictionary.txt"
54-
55-
- name: Setup Node.js ${{ matrix.node-version }}
56-
if: steps.changes.outputs.changed == 'true'
57-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
58-
with:
59-
node-version: ${{ matrix.node-version }}
60-
cache: 'pnpm'
61-
62-
# Special handling for Node.js 18: use Node.js 20 for tsgo dependency installation
63-
- name: Setup Node.js 20 for dependency installation (Node 18 only)
64-
if: steps.changes.outputs.changed == 'true' && matrix.node-version == 18
65-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
66-
with:
67-
node-version: 20
68-
cache: 'pnpm'
69-
70-
- name: Install Dependencies
71-
if: steps.changes.outputs.changed == 'true'
72-
run: pnpm install
73-
74-
# Switch back to Node.js 18 after dependency installation
75-
- name: Switch back to Node.js ${{ matrix.node-version }} (Node 18 only)
76-
if: steps.changes.outputs.changed == 'true' && matrix.node-version == 18
77-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
78-
with:
79-
node-version: ${{ matrix.node-version }}
80-
cache: 'pnpm'
81-
82-
- name: Type Check
83-
if: steps.changes.outputs.changed == 'true'
84-
run: pnpm run type-check
85-
86-
- name: Unit Test
87-
if: steps.changes.outputs.changed == 'true'
88-
run: pnpm run test:unit
89-
90-
# ======== integration && e2e ========
9130
integration-e2e:
92-
runs-on: ${{ matrix.os }}
9331
strategy:
9432
matrix:
95-
os: [ubuntu-latest]
33+
runner: [ubuntu-latest]
9634
node-version: [18, 20, 22]
9735
include:
9836
- node-version: 18
99-
os: windows-latest
100-
101-
steps:
102-
- name: Checkout
103-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
104-
with:
105-
fetch-depth: 1
106-
107-
- name: Git config
108-
if: ${{ matrix.os == 'windows-latest' }}
109-
shell: bash
110-
run: |
111-
git config --system core.longpaths true
112-
113-
- name: Install pnpm
114-
run: |
115-
npm install -g corepack@latest --force
116-
corepack enable
117-
118-
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
119-
id: changes
120-
with:
121-
predicate-quantifier: 'every'
122-
filters: |
123-
changed:
124-
- "!**/*.md"
125-
- "!**/*.mdx"
126-
- "!**/_meta.json"
127-
- "!**/dictionary.txt"
128-
129-
- name: Setup Node.js ${{ matrix.node-version }}
130-
if: steps.changes.outputs.changed == 'true'
131-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
132-
with:
133-
node-version: ${{ matrix.node-version }}
134-
cache: 'pnpm'
135-
136-
# Special handling for Node.js 18: use Node.js 20 for tsgo dependency installation
137-
- name: Setup Node.js 20 for dependency installation (Node 18 only)
138-
if: steps.changes.outputs.changed == 'true' && matrix.node-version == 18
139-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
140-
with:
141-
node-version: 20
142-
cache: 'pnpm'
143-
144-
- name: Install Dependencies
145-
if: steps.changes.outputs.changed == 'true'
146-
run: pnpm install && cd ./tests && pnpm playwright install chromium
147-
148-
# Switch back to Node.js 18 after dependency installation
149-
- name: Switch back to Node.js ${{ matrix.node-version }} (Node 18 only)
150-
if: steps.changes.outputs.changed == 'true' && matrix.node-version == 18
151-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
152-
with:
153-
node-version: ${{ matrix.node-version }}
154-
cache: 'pnpm'
155-
156-
- name: Integration Test (Rstest)
157-
if: steps.changes.outputs.changed == 'true'
158-
run: pnpm run test:integration
159-
160-
- name: E2E Test (Playwright)
161-
if: steps.changes.outputs.changed == 'true'
162-
run: pnpm run test:e2e
37+
runner: windows-latest
38+
uses: ./.github/workflows/reusable-common.yml
39+
with:
40+
runner: ${{ matrix.runner }}
41+
node-version: ${{ matrix.node-version }}
42+
task: integration-e2e
43+
44+
integration-advanced-esm:
45+
strategy:
46+
matrix:
47+
runner: [ubuntu-latest]
48+
node-version: [22]
49+
include:
50+
- node-version: 22
51+
runner: windows-latest
52+
uses: ./.github/workflows/reusable-common.yml
53+
with:
54+
runner: ${{ matrix.runner }}
55+
node-version: ${{ matrix.node-version }}
56+
task: integration-advanced-esm

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
"prebundle": "nx run-many -t prebundle",
1616
"prepare": "pnpm run build && simple-git-hooks",
1717
"sort-package-json": "npx sort-package-json \"packages/*/package.json\"",
18-
"test": "pnpm run test:unit && pnpm run test:integration && pnpm run test:e2e",
18+
"test": "pnpm run test:unit && pnpm run test:integration && pnpm run test:integration:advanced-esm && pnpm run test:e2e",
1919
"test:benchmark": "cd ./tests && pnpm run test:benchmark",
2020
"test:e2e": "pnpm run build:examples && cd tests && pnpm run test:e2e",
21-
"test:ecosystem-ci": "pnpm run test:unit && cross-env ECO_CI=1 pnpm run test:integration && pnpm run test:e2e",
21+
"test:ecosystem-ci": "pnpm run test:unit && cross-env ECO_CI=1 pnpm run test:integration && cross-env ECO_CI=1 pnpm run test:integration:advanced-esm && pnpm run test:e2e",
2222
"test:integration": "rstest run --project integration",
23+
"test:integration:advanced-esm": "cross-env ADVANCED_ESM=1 rstest run --project integration",
2324
"test:unit": "rstest run --project unit*",
24-
"testu": "pnpm run test:unit -u && pnpm run test:integration -u",
25+
"testu": "pnpm run test:unit -u && pnpm run test:integration -u && pnpm test:integration:advanced-esm -u",
2526
"type-check": "pnpm -r run type-check",
2627
"update:rsbuild": "npx taze minor --include /rsbuild/ -w -r -l",
2728
"watch": "pnpm build --watch"

tests/scripts/shared.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ export function generateBundleEsmConfig(config: LibConfig = {}): LibConfig {
8383
output: {
8484
distPath: './dist/esm',
8585
},
86+
experiments: {
87+
advancedEsm: process.env.ADVANCED_ESM === '1',
88+
},
8689
};
8790

8891
return mergeConfig(esmBasicConfig, config)!;

0 commit comments

Comments
 (0)