|
| 1 | +name: Benchmark PR |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read # Read access for repository contents |
| 9 | + pull-requests: write # Write access for pull requests |
| 10 | + |
| 11 | +env: |
| 12 | + PYTHON_VERSION: "3.10" |
| 13 | + WORKING_DIR: ${{ github.workspace }}/benchmarks |
| 14 | + |
| 15 | +jobs: |
| 16 | + benchmark-pr: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + defaults: |
| 20 | + run: |
| 21 | + working-directory: ${{ env.WORKING_DIR }} |
| 22 | + |
| 23 | + steps: |
| 24 | + |
| 25 | + - name: Checkout repository |
| 26 | + uses: actions/checkout@v3 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + |
| 30 | + - name: Set up Python |
| 31 | + uses: actions/setup-python@v4 |
| 32 | + with: |
| 33 | + python-version: ${{ env.PYTHON_VERSION }} |
| 34 | + |
| 35 | + - name: Install dependencies |
| 36 | + run: | |
| 37 | + python -m pip install --upgrade pip |
| 38 | + pip install asv virtualenv lf-asv-formatter |
| 39 | +
|
| 40 | + - name: Create ASV machine config file |
| 41 | + run: asv machine --machine gh-runner --yes |
| 42 | + |
| 43 | + - name: Save comparison of PR against main branch |
| 44 | + run: | |
| 45 | + # prepare main branch for comparison |
| 46 | + git remote add upstream https://github.com/${{ github.repository }}.git |
| 47 | + git fetch upstream main |
| 48 | +
|
| 49 | + # Run benchmarks, writing comment contents to ./output |
| 50 | + asv continuous upstream/main HEAD \ |
| 51 | + --factor 1.1 --sort ratio --split --interleave-rounds -a repeat=7 |
| 52 | + asv compare upstream/main HEAD --factor 1.1 --sort ratio --split | tee output |
| 53 | + python -m lf_asv_formatter --asv_version "$(echo asv --version)" |
| 54 | + printf "Benchmark Suite Results:\n\n" >> comment_body |
| 55 | + cat output >> comment_body |
| 56 | +
|
| 57 | + # from https://github.com/hombit/load_ztfdr_for_tape/blob/9acf7c83/.github/workflows/asv-pr.yml |
| 58 | + - name: Find benchmarks comment |
| 59 | + uses: peter-evans/find-comment@v2 |
| 60 | + id: find-comment |
| 61 | + with: |
| 62 | + issue-number: ${{ github.event.pull_request.number }} |
| 63 | + comment-author: 'github-actions[bot]' |
| 64 | + body-includes: Benchmark Suite Results |
| 65 | + |
| 66 | + - name: Create or update benchmarks comment |
| 67 | + uses: peter-evans/create-or-update-comment@v3 |
| 68 | + with: |
| 69 | + comment-id: ${{ steps.find-comment.outputs.comment-id }} |
| 70 | + issue-number: ${{ github.event.pull_request.number }} |
| 71 | + body-path: ${{ env.WORKING_DIR }}/comment_body |
| 72 | + edit-mode: replace |
0 commit comments