# SPDX-License-Identifier: MPL-2.0 # This workflow is managed by gh actions-lock. name: Performance Benchmarks on: pull_request: branches: [ main, develop ] workflow_dispatch: permissions: actions: read contents: read jobs: benchmark: name: Run Benchmarks runs-on: ubuntu-latest permissions: contents: read pull-requests: write steps: - name: Checkout code uses: actions/checkout@v7.0.1 - name: Checkout base branch if: github.event_name == 'pull_request' uses: actions/checkout@v7.0.1 with: ref: ${{ github.base_ref }} path: base - name: Setup Bun uses: oven-sh/setup-bun@v2.2.0 with: bun-version: latest - name: Run translation benchmarks run: | if [ ! -f index.js ]; then echo "No library entry (index.js); skip translation benches" echo "skipped" > bench-translation.txt exit 0 fi bun benchmarks/translation-bench.js > bench-translation.txt - name: Run comparison benchmarks run: | if [ ! -f index.js ]; then echo "No library entry (index.js); skip comparison benches" echo "skipped" > bench-comparison.txt exit 0 fi bun benchmarks/comparison-bench.js > bench-comparison.txt - name: Combine benchmark results run: | echo "# Benchmark Results" > benchmark-results.md echo "" >> benchmark-results.md echo "## Translation Benchmarks" >> benchmark-results.md echo "\`\`\`" >> benchmark-results.md cat bench-translation.txt >> benchmark-results.md echo "\`\`\`" >> benchmark-results.md echo "" >> benchmark-results.md echo "## Configuration Comparison" >> benchmark-results.md echo "\`\`\`" >> benchmark-results.md cat bench-comparison.txt >> benchmark-results.md echo "\`\`\`" >> benchmark-results.md - name: Upload benchmark results uses: actions/upload-artifact@v7.0.2 with: name: benchmark-results path: | benchmark-results.md bench-translation.txt bench-comparison.txt - name: Comment benchmark results on PR if: github.event_name == 'pull_request' uses: actions/github-script@v9.0.0 with: script: | const fs = require('fs'); const results = fs.readFileSync('benchmark-results.md', 'utf8'); github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: results }); - name: Performance regression check if: github.event_name == 'pull_request' run: | echo "Performance regression check would run here" echo "Compare current benchmarks with base branch"