Skip to content

Commit d1ac8f1

Browse files
authored
chore(CI): extract reusable yml and remove Node 20 tests (#1283)
1 parent 41820d3 commit d1ac8f1

File tree

2 files changed

+127
-138
lines changed

2 files changed

+127
-138
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Reusable Test
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+
test:
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 22 for tsgo dependency installation
58+
- name: Setup Node.js 22 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: 22
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 e2e)
70+
if: ${{ steps.changes.outputs.changed == 'true' && inputs.task == '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' }}
93+
run: pnpm run test:integration
94+
95+
- name: E2E Test (Playwright)
96+
if: ${{ steps.changes.outputs.changed == 'true' && inputs.task == 'e2e' }}
97+
run: pnpm run test:e2e

.github/workflows/test.yml

Lines changed: 30 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -13,150 +13,42 @@ permissions:
1313
contents: read
1414

1515
jobs:
16-
# ======== ut ========
1716
ut:
18-
runs-on: ${{ matrix.os }}
1917
strategy:
2018
matrix:
21-
os: [ubuntu-latest]
22-
node-version: [18, 20, 22]
19+
runner: [ubuntu-latest, windows-latest]
20+
node-version: [22]
21+
uses: ./.github/workflows/reusable-test.yml
22+
with:
23+
runner: ${{ matrix.runner }}
24+
node-version: ${{ matrix.node-version }}
25+
task: ut
26+
27+
integration:
28+
strategy:
29+
matrix:
30+
runner: [ubuntu-latest]
31+
node-version: [18, 22]
2332
include:
24-
- node-version: 18
25-
os: windows-latest
26-
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
33+
- runner: windows-latest
34+
node-version: 22
8535

86-
- name: Unit Test
87-
if: steps.changes.outputs.changed == 'true'
88-
run: pnpm run test:unit
36+
uses: ./.github/workflows/reusable-test.yml
37+
with:
38+
runner: ${{ matrix.runner }}
39+
node-version: ${{ matrix.node-version }}
40+
task: integration
8941

90-
# ======== integration && e2e ========
91-
integration-e2e:
92-
runs-on: ${{ matrix.os }}
42+
e2e:
9343
strategy:
9444
matrix:
95-
os: [ubuntu-latest]
96-
node-version: [18, 20, 22]
45+
runner: [ubuntu-latest]
46+
node-version: [18, 22]
9747
include:
98-
- 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
48+
- runner: windows-latest
49+
node-version: 22
50+
uses: ./.github/workflows/reusable-test.yml
51+
with:
52+
runner: ${{ matrix.runner }}
53+
node-version: ${{ matrix.node-version }}
54+
task: e2e

0 commit comments

Comments
 (0)