refactor(psutils): 抽取共享 helper 并修复 QA #863
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| # 版本统一由 package.json 的 packageManager 决定,避免与 action 输入重复声明。 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v6 | |
| # 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 |