|
| 1 | +# This file is part of the jebel-quant/rhiza repository |
| 2 | +# (https://github.com/jebel-quant/rhiza). |
| 3 | +# |
| 4 | +# Workflow: Performance Benchmarks |
| 5 | +# |
| 6 | +# Purpose: Run performance benchmarks and detect regressions. |
| 7 | +# |
| 8 | +# Trigger: On push to main/master branches, PRs, and manual trigger. |
| 9 | +# |
| 10 | +# Regression Detection: |
| 11 | +# - Compares against previous benchmark results stored in gh-pages branch |
| 12 | +# - Alerts if performance degrades by more than 150% (configurable) |
| 13 | +# - PRs will show a warning comment but not fail |
| 14 | +# - Main branch updates the baseline for future comparisons |
| 15 | + |
| 16 | +name: (RHIZA) Benchmarks |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: write |
| 20 | + pull-requests: write |
| 21 | + |
| 22 | +on: |
| 23 | + push: |
| 24 | + branches: [ main, master ] |
| 25 | + pull_request: |
| 26 | + branches: [ main, master ] |
| 27 | + workflow_dispatch: |
| 28 | + |
| 29 | +jobs: |
| 30 | + benchmark: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + |
| 33 | + steps: |
| 34 | + - name: Checkout repository |
| 35 | + uses: actions/checkout@v6 |
| 36 | + with: |
| 37 | + lfs: true |
| 38 | + |
| 39 | + - name: Install uv |
| 40 | + uses: astral-sh/setup-uv@v7 |
| 41 | + with: |
| 42 | + version: "0.9.26" |
| 43 | + python-version: "3.12" |
| 44 | + |
| 45 | + - name: Run benchmarks |
| 46 | + env: |
| 47 | + UV_EXTRA_INDEX_URL: ${{ secrets.uv-extra-index-url }} |
| 48 | + run: | |
| 49 | + make benchmark |
| 50 | +
|
| 51 | + - name: Upload benchmark results |
| 52 | + uses: actions/upload-artifact@v6 |
| 53 | + if: always() |
| 54 | + with: |
| 55 | + name: benchmark-results |
| 56 | + path: | |
| 57 | + _benchmarks/benchmarks.json |
| 58 | + _benchmarks/benchmarks.svg |
| 59 | + _benchmarks/benchmarks.html |
| 60 | +
|
| 61 | + # Regression detection using github-action-benchmark |
| 62 | + # Stores benchmark history in gh-pages branch under /benchmarks |
| 63 | + # Alerts if performance degrades by more than 150% of baseline |
| 64 | + - name: Store benchmark result and check for regression |
| 65 | + uses: benchmark-action/github-action-benchmark@v1 |
| 66 | + # run this only if _benchmarks/benchmarks.json exists |
| 67 | + if: hashFiles('_benchmarks/benchmarks.json') != '' |
| 68 | + with: |
| 69 | + tool: 'pytest' |
| 70 | + output-file-path: _benchmarks/benchmarks.json |
| 71 | + # Store benchmark data in gh-pages branch |
| 72 | + gh-pages-branch: gh-pages |
| 73 | + benchmark-data-dir-path: benchmarks |
| 74 | + # Only update baseline on main branch push (not PRs) |
| 75 | + auto-push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} |
| 76 | + # Alert if performance degrades by more than 150% |
| 77 | + alert-threshold: '150%' |
| 78 | + # Post comment on PR if regression detected |
| 79 | + comment-on-alert: ${{ github.event_name == 'pull_request' }} |
| 80 | + # Fail workflow if regression detected (disabled for PRs to allow investigation) |
| 81 | + fail-on-alert: ${{ github.event_name == 'push' }} |
| 82 | + # GitHub token for pushing to gh-pages and commenting |
| 83 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments