chore: Memory benchmark workflow #2
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: Memory benchmark | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - reopened | |
| - synchronize | |
| - labeled | |
| permissions: | |
| contents: read | |
| jobs: | |
| memory-benchmark: | |
| name: Memory benchmark (memray) | |
| runs-on: ubuntu-latest # GitHub-hosted; Docker preinstalled | |
| # Only runs when the PR carries the label. The 'labeled' trigger above lets | |
| # adding the label to an open PR start the run immediately; every other PR | |
| # event is a no-op for this job. | |
| if: contains(github.event.pull_request.labels.*.name, 'check-memory-benchmark') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # No setup-python / pip install on the host: the Docker image | |
| # (python-3.12-slim-perf-Dockerfile) already has Python 3.12 + memray + | |
| # deps, and entrypoint.sh downloads the native lib at container start. | |
| # baseline.json comes from the repo. This is the exact path devs run | |
| # locally via `make memory-use-bench`. Exits non-zero on regression | |
| # (> baseline * threshold) -> the check goes red. The Makefile forwards | |
| # GITHUB_TOKEN and GITHUB_STEP_SUMMARY into the container. | |
| - name: Run memory benchmark | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: make memory-use-bench | |
| # Upload all three flamegraph views per scenario (peak/leaks/temporary). | |
| # if: always() so the reports are available even when the run failed on a | |
| # regression -- exactly when they are most useful. | |
| - name: Upload flamegraph reports | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: memray-flamegraphs | |
| path: tests/perf/reports/*.html | |
| if-no-files-found: warn |