Skip to content

Commit d53bfe2

Browse files
committed
ci(workflow): 添加 Node.js Vitest 测试任务并重命名原有任务
新增 Node.js Vitest 测试任务,包含 pnpm 安装、依赖缓存和测试报告生成功能 同时将原有的 PowerShell Pester 测试任务重命名为更明确的名称
1 parent cb8486e commit d53bfe2

1 file changed

Lines changed: 46 additions & 2 deletions

File tree

.github/workflows/test.yml

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ permissions:
1313
pull-requests: write # 如果需要评论 PR
1414

1515
jobs:
16-
test:
16+
# ==========================================
17+
# Job 1: PowerShell Pester 测试
18+
# ==========================================
19+
pester-test:
1720
name: Run Pester on ${{ matrix.os }}
1821
runs-on: ${{ matrix.os }}
1922
strategy:
@@ -35,4 +38,45 @@ jobs:
3538
with:
3639
name: Pester Tests (${{ matrix.os }})
3740
path: testResults.xml
38-
reporter: dotnet-nunit
41+
reporter: dotnet-nunit
42+
# ==========================================
43+
# Job 2: Node.js Vitest 测试 (新增部分)
44+
# ==========================================
45+
node-test:
46+
name: Node Vitest (Ubuntu)
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
# 1. 安装 pnpm
52+
- name: Install pnpm
53+
uses: pnpm/action-setup@v4
54+
with:
55+
version: 10 # 指定你使用的 pnpm 版本
56+
57+
# 2. 安装 Node 并开启 pnpm 缓存 (这是 Monorepo 速度的关键)
58+
- name: Setup Node
59+
uses: actions/setup-node@v4
60+
with:
61+
node-version: 24
62+
cache: 'pnpm'
63+
64+
# 3. 安装依赖
65+
- name: Install Dependencies
66+
run: pnpm install --frozen-lockfile
67+
68+
# 4. 运行 Vitest 并生成报告
69+
# 注意:你需要配置 Vitest 输出 JUnit 格式的 XML
70+
- name: Run Vitest
71+
run: |
72+
pnpm exec vitest run --reporter=junit --outputFile=vitest-report.xml
73+
74+
# 5. 上传 Vitest 报告
75+
- name: Report Vitest
76+
uses: dorny/test-reporter@v2
77+
if: success() || failure()
78+
with:
79+
name: Vitest Results
80+
path: vitest-report.xml
81+
reporter: java-junit # Vitest 的 JUnit 输出对应 java-junit 解析器
82+
fail-on-error: false

0 commit comments

Comments
 (0)