Introduce PR Benchmark Workflow #5
Workflow file for this run
This file contains 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 PR | |
on: | |
pull_request: | |
branches: [main] | |
env: | |
PYTHON_VERSION: "3.10" | |
WORKING_DIR: ${{ github.workspace }}/benchmarks | |
FAIL_THRSHOLD: 1.1 | |
jobs: | |
benchmark-pr: | |
runs-on: ubuntu-latest | |
if: contains(github.event.pull_request.labels.*.name, 'run_benchmarks') | |
defaults: | |
run: | |
working-directory: ${{ env.WORKING_DIR }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install asv virtualenv lf-asv-formatter | |
- name: Create ASV machine config file | |
run: asv machine --machine gh-runner --yes | |
- name: Save comparison of PR against main branch | |
run: | | |
# prepare main branch for comparison | |
git remote add upstream https://github.com/${{ github.repository }}.git | |
git fetch upstream main | |
# Run benchmarks, writing comment contents to ./output | |
asv continuous upstream/main HEAD \ | |
--factor 1.1 --sort ratio --split --interleave-rounds -a repeat=3 | |
asv compare upstream/main HEAD --sort ratio --split | tee output | |
python -m lf_asv_formatter --asv_version "$(echo asv --version)" | |
printf "Benchmark Suite Results:\n\n" >> comment_body | |
cat output >> comment_body | |
- name: Upload benchmark results | |
uses: actions/upload-artifact@v2 | |
with: | |
name: benchmark-results-${{ github.sha }} | |
path: comment_body | |
- name: Create summary with artifact link | |
run: | | |
echo "### Benchmark Results" >> $GITHUB_STEP_SUMMARY | |
echo "The benchmark results are available as an artifact. You can download them [here](../actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY |