Skip to content

fix(vite): 统一 Web source candidate 扫描边界 (#1062) #1881

fix(vite): 统一 Web source candidate 扫描边界 (#1062)

fix(vite): 统一 Web source candidate 扫描边界 (#1062) #1881

Workflow file for this run

name: Benchmark
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
push:
branches:
- main
- alpha
- beta
- rc
- next
workflow_dispatch:
inputs:
baseline:
description: npm 发布基线;auto 会按当前包版本推断 next/beta/rc/latest
required: false
default: auto
build_runs:
description: 每个项目的 build 采样次数
required: false
default: '3'
hmr_runs:
description: 每个项目的 HMR 采样次数
required: false
default: '5'
only:
description: 可选:只跑指定项目 key,多个 key 用逗号分隔
required: false
default: ''
concurrency:
group: benchmark-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
benchmark-matrix:
name: Prepare benchmark matrix
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
include: ${{ steps.matrix.outputs.include }}
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Generate benchmark matrix
id: matrix
env:
BENCH_ONLY: ${{ github.event.inputs.only || '' }}
run: |
include="$(node benchmark/version-compare/scripts/ci-matrix.mjs --event "$GITHUB_EVENT_NAME" --only "$BENCH_ONLY")"
echo "include=$include" >> "$GITHUB_OUTPUT"
benchmark-shard:
name: Benchmark shard (${{ matrix.case_name }})
needs: benchmark-matrix
runs-on: ubuntu-latest
timeout-minutes: ${{ github.event_name == 'pull_request' && 30 || 45 }}
strategy:
fail-fast: false
max-parallel: 6
matrix:
include: ${{ fromJSON(needs.benchmark-matrix.outputs.include) }}
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
WEAPP_TW_BENCH_BASELINE: ${{ github.event.inputs.baseline || 'auto' }}
BENCH_BUILD_RUNS: ${{ github.event_name == 'pull_request' && '3' || github.event.inputs.build_runs || '3' }}
BENCH_HMR_RUNS: ${{ github.event_name == 'pull_request' && '6' || github.event.inputs.hmr_runs || '5' }}
BENCH_ONLY: ${{ matrix.bench_only }}
steps:
- name: Check out code
uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
- name: Setup Node.js environment
uses: actions/setup-node@v6
with:
node-version: 22
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run pull request performance guard
if: github.event_name == 'pull_request'
run: >
pnpm perf:guard --
--baseline-ref "${{ github.event.pull_request.base.sha }}"
--build-runs "$BENCH_BUILD_RUNS"
--hmr-runs "$BENCH_HMR_RUNS"
--timeout 180000
--poll-interval 30
--only "$BENCH_ONLY"
--result-dir .tmp/benchmark-ci/result
- name: Run current vs published benchmark
if: github.event_name != 'pull_request'
run: >
pnpm bench:ci --
--build-runs "$BENCH_BUILD_RUNS"
--hmr-runs "$BENCH_HMR_RUNS"
--timeout 180000
--poll-interval 30
--only "$BENCH_ONLY"
--result-dir .tmp/benchmark-ci/result
- name: Upload benchmark artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: benchmark-performance-${{ matrix.case_name }}
path: .tmp/benchmark-ci/result/**
if-no-files-found: error
current-vs-published:
name: Performance guard and published trend
if: always()
needs: benchmark-shard
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Download benchmark reports
if: always()
continue-on-error: true
uses: actions/download-artifact@v4
with:
pattern: benchmark-performance-*
path: .tmp/benchmark-ci/artifacts
- name: Report benchmark shard failures
if: always()
env:
BENCHMARK_RESULT: ${{ needs.benchmark-shard.result }}
run: |
if [ "$BENCHMARK_RESULT" = success ]; then
exit 0
fi
echo "benchmark-shard result: $BENCHMARK_RESULT"
node benchmark/version-compare/scripts/report-shard-failures.mjs .tmp/benchmark-ci/artifacts
- name: Require every benchmark shard
env:
BENCHMARK_RESULT: ${{ needs.benchmark-shard.result }}
run: |
if [ "$BENCHMARK_RESULT" != success ]; then
echo "::error title=Benchmark matrix failed::At least one benchmark shard failed. Review the Benchmark shard failure annotations above for the exact project and metric."
fi
test "$BENCHMARK_RESULT" = success