Files
cfw-autumn/archives/benchmark.yml

79 lines
2.4 KiB
YAML

# name: Benchmark Server PR
# on:
# pull_request:
# types: [opened, synchronize, reopened]
# paths:
# - 'server/**'
# - 'pnpm-lock.yaml'
# - 'package.json'
# permissions:
# contents: read
# pull-requests: write
# jobs:
# benchmark:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - name: Setup pnpm
# uses: pnpm/action-setup@v2
# with:
# version: latest
# - name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: '20'
# cache: 'pnpm'
# - name: Install dependencies
# run: pnpm i --no-frozen-lockfile
# - name: Run benchmark
# id: benchmark
# working-directory: ./server
# run: |
# echo "BENCHMARK_OUTPUT<<EOF" >> $GITHUB_OUTPUT
# FULL_OUTPUT=$(pnpm run benchmark 2>&1)
# FILTERED_OUTPUT=$(echo "$FULL_OUTPUT" | grep -v "^> @.*benchmark" | grep -v "^> tsx benchmarks" | grep -v "Benchmark completed successfully")
# echo "$FILTERED_OUTPUT" >> $GITHUB_OUTPUT
# echo "EOF" >> $GITHUB_OUTPUT
# if echo "$FULL_OUTPUT" | grep -q "Benchmark completed successfully"; then
# echo "BENCHMARK_STATUS=✅ Passed" >> $GITHUB_OUTPUT
# else
# echo "BENCHMARK_STATUS=❌ Failed" >> $GITHUB_OUTPUT
# fi
# - name: Comment PR
# uses: actions/github-script@v7
# with:
# script: |
# const output = `${{ steps.benchmark.outputs.BENCHMARK_OUTPUT }}`;
# const status = `${{ steps.benchmark.outputs.BENCHMARK_STATUS }}`;
# const body = `## 📊 Benchmark Results
# **Benchmark CI:** ${status}
# <details>
# <summary>Click to view benchmark results</summary>
# \`\`\`javascript
# ${output}
# \`\`\`
# </details>
# *Benchmark run for commit ${{ github.sha }}*`;
# github.rest.issues.createComment({
# issue_number: context.issue.number,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: body
# });