Benchmark #18
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: | |
| workflow_run: | |
| workflows: ["Publish"] | |
| types: [completed] | |
| workflow_dispatch: | |
| permissions: {} | |
| jobs: | |
| benchmark: | |
| runs-on: ubuntu-latest | |
| if: >- | |
| github.event_name == 'workflow_dispatch' || | |
| github.event.workflow_run.conclusion == 'success' | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: main | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| - run: npm install | |
| - name: Run benchmark | |
| run: node scripts/benchmark.js 2>/dev/null > benchmark-result.json | |
| - name: Update report | |
| run: node scripts/update-benchmark-report.js benchmark-result.json | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| if git diff --quiet HEAD -- generated/BENCHMARKS.md README.md; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Commit and push via PR | |
| if: steps.changes.outputs.changed == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| BRANCH="benchmark/update-$(date +%Y%m%d-%H%M%S)" | |
| git checkout -b "$BRANCH" | |
| git add generated/BENCHMARKS.md README.md | |
| git commit -m "docs: update performance benchmarks" | |
| git push origin "$BRANCH" | |
| gh pr create \ | |
| --base main \ | |
| --head "$BRANCH" \ | |
| --title "docs: update performance benchmarks" \ | |
| --body "Automated benchmark update from workflow run [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})." | |
| - name: Upload result artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-result | |
| path: benchmark-result.json |