Skip to content

chore(ci): 升级pnpm action版本并固定版本号 #807

chore(ci): 升级pnpm action版本并固定版本号

chore(ci): 升级pnpm action版本并固定版本号 #807

Workflow file for this run

name: Pester Test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
permissions:
contents: read
checks: write
pull-requests: write # 如果需要评论 PR
jobs:
# ==========================================
# Job 1: PowerShell Pester 测试
# ==========================================
pester-test:
name: Run Pester on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Run Pester
shell: pwsh
run: |
$env:PWSH_TEST_MODE = 'full'
if ('${{ matrix.os }}' -eq 'windows-latest') {
$env:PWSH_TEST_ENABLE_COVERAGE = 'true'
}
else {
$env:PWSH_TEST_ENABLE_COVERAGE = 'false'
}
$config = ./PesterConfiguration.ps1
$config.Run.Exit = $true
Invoke-Pester -Configuration $config
# 测试图形化报告
- name: Publish Test Report
uses: dorny/test-reporter@v3
if: always() || failure()
with:
name: Pester Tests (${{ matrix.os }})
path: testResults.xml
reporter: dotnet-nunit
# ==========================================
# Job 2: Node.js Vitest 测试 (新增部分)
# ==========================================
node-test:
name: Node Vitest (Ubuntu)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
# 1. 安装 pnpm
- name: Install pnpm
uses: pnpm/action-setup@v6
with:
# 显式固定 pnpm 版本,避免 CI 与本地解析 lockfile 时出现差异。
version: 10.25.0
# 2. 安装 Node 并开启 pnpm 缓存 (这是 Monorepo 速度的关键)
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 24
cache: 'pnpm'
# 3. 安装依赖
- name: Install Dependencies
run: pnpm install --frozen-lockfile
# 4. 运行 Vitest 并生成报告
# 注意:你需要配置 Vitest 输出 JUnit 格式的 XML
- name: Run Vitest
env:
# 开启颜色输出,防止颜色测试代码报错
FORCE_COLOR: 1
run: |
pnpm exec vitest run --reporter=default --reporter=junit --outputFile.junit=vitest-report.xml
# 5. 上传 Vitest 报告
- name: Report Vitest
uses: dorny/test-reporter@v3
if: success() || failure()
with:
name: Vitest Results
path: '**/vitest-report.xml'
reporter: java-junit # Vitest 的 JUnit 输出对应 java-junit 解析器
fail-on-error: false