Build(Release): Verify staged native artifacts #107
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: Benchmark | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - alpha | |
| - beta | |
| - rc | |
| - canary | |
| paths: | |
| - benchmarks/** | |
| - packages/schema/** | |
| - packages/lexer/** | |
| - packages/engine/** | |
| - packages/preset/** | |
| - packages/runtime/** | |
| - shared/** | |
| - package.json | |
| - pnpm-lock.yaml | |
| - pnpm-workspace.yaml | |
| - turbo.json | |
| - tsconfig*.json | |
| - .npmrc | |
| - .github/actions/setup-pnpm/action.yml | |
| - .github/workflows/benchmark.yml | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| actions: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| benchmark: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: ./.github/actions/setup-pnpm | |
| with: | |
| submodules-token: ${{ secrets.GH_TOKEN }} | |
| turbo-cache-scope: benchmark | |
| - run: pnpm exec playwright install --with-deps --only-shell chromium | |
| - name: Build benchmark packages | |
| run: | | |
| pnpm --filter @master/css-schema build | |
| pnpm --filter @master/css-lexer build | |
| pnpm --filter @master/css-engine build | |
| pnpm --filter @master/css-preset build | |
| pnpm --filter @master/css-runtime build | |
| - name: Prepare benchmark output | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| branch_slug="$(printf '%s' "$GITHUB_REF_NAME" | tr '/:@ ' '----' | tr -cd 'A-Za-z0-9._-')" | |
| output_dir="$RUNNER_TEMP/master-css-benchmark" | |
| mkdir -p "$output_dir" | |
| { | |
| echo "BENCHMARK_BRANCH_SLUG=$branch_slug" | |
| echo "BENCHMARK_OUTPUT_DIR=$output_dir" | |
| echo "ENGINE_BENCHMARK_ARTIFACT=master-css-benchmark-$branch_slug-engine-$GITHUB_SHA" | |
| echo "RUNTIME_BENCHMARK_ARTIFACT=master-css-benchmark-$branch_slug-runtime-$GITHUB_SHA" | |
| } >> "$GITHUB_ENV" | |
| - name: Run engine benchmark | |
| run: pnpm --filter @master/css-engine bench --outputJson "$BENCHMARK_OUTPUT_DIR/engine-vitest.json" | |
| - name: Run runtime browser benchmark | |
| run: pnpm --filter @master/css-runtime bench --output "$BENCHMARK_OUTPUT_DIR/runtime.json" | |
| - name: Write benchmark reports | |
| run: node benchmarks/ci/write-benchmark-report.js --output "$BENCHMARK_OUTPUT_DIR" --engine "$BENCHMARK_OUTPUT_DIR/engine-vitest.json" --runtime "$BENCHMARK_OUTPUT_DIR/runtime.json" | |
| - name: Compare engine history | |
| run: node benchmarks/ci/compare-benchmark-history.js --current "$BENCHMARK_OUTPUT_DIR/engine/benchmark-results.json" --output "$BENCHMARK_OUTPUT_DIR/engine/history.md" --limit 50 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Compare runtime history | |
| run: node benchmarks/ci/compare-benchmark-history.js --current "$BENCHMARK_OUTPUT_DIR/runtime/benchmark-results.json" --output "$BENCHMARK_OUTPUT_DIR/runtime/history.md" --limit 50 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Append benchmark summary | |
| shell: bash | |
| run: | | |
| { | |
| cat "$BENCHMARK_OUTPUT_DIR/engine/benchmark-results.md" | |
| cat "$BENCHMARK_OUTPUT_DIR/engine/history.md" | |
| cat "$BENCHMARK_OUTPUT_DIR/runtime/benchmark-results.md" | |
| cat "$BENCHMARK_OUTPUT_DIR/runtime/history.md" | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.ENGINE_BENCHMARK_ARTIFACT }} | |
| path: ${{ env.BENCHMARK_OUTPUT_DIR }}/engine | |
| retention-days: 90 | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.RUNTIME_BENCHMARK_ARTIFACT }} | |
| path: ${{ env.BENCHMARK_OUTPUT_DIR }}/runtime | |
| retention-days: 90 |