feat(uv): cross-compile maturin (Cargo/PyO3) sdists #1118
Workflow file for this run
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: Performance Benchmark | |
| on: | |
| pull_request: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| # Superseded runs of the same PR measure a stale commit; cancel them. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| env: | |
| BCR_VERSION: "1.11.7" | |
| ANALYSIS_BCR_VERSION: "2.0.0-alpha.6" | |
| jobs: | |
| startup: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout PR | |
| uses: actions/checkout@v6 | |
| with: | |
| path: rules_py_pr | |
| - name: Checkout HEAD main | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| path: rules_py_main | |
| - name: Restore repository cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/bazel-repo | |
| key: bazel-repo-startup-${{ env.BCR_VERSION }}-${{ hashFiles('rules_py_pr/benchmark/startup/**') }} | |
| restore-keys: | | |
| bazel-repo-startup- | |
| - name: Install hyperfine | |
| run: | | |
| set -euo pipefail | |
| HYPERFINE_VERSION="1.18.0" | |
| DEB="hyperfine_${HYPERFINE_VERSION}_amd64.deb" | |
| URL="https://github.com/sharkdp/hyperfine/releases/download/v${HYPERFINE_VERSION}/${DEB}" | |
| wget -qO "$DEB" "$URL" | |
| sudo dpkg -i "$DEB" | |
| rm -f "$DEB" | |
| hyperfine --version | |
| - name: Benchmark BCR ${{ env.BCR_VERSION }} | |
| run: rules_py_pr/benchmark/startup/bench.sh bcr bcr --version "${BCR_VERSION}" | |
| - name: Benchmark HEAD main | |
| run: rules_py_pr/benchmark/startup/bench.sh main local --path "$GITHUB_WORKSPACE/rules_py_main" | |
| - name: Benchmark current PR | |
| run: rules_py_pr/benchmark/startup/bench.sh pr local --path "$GITHUB_WORKSPACE/rules_py_pr" | |
| # ── Compare ───────────────────────────────────────────────────────────── | |
| - name: Compare startup results | |
| id: compare | |
| continue-on-error: true | |
| run: | | |
| set -euo pipefail | |
| python3 rules_py_pr/benchmark/startup/compare.py \ | |
| --output-table startup-table.txt \ | |
| bcr.json main.json pr.json | |
| - name: Save PR number | |
| if: github.event_name == 'pull_request' | |
| run: echo "${{ github.event.pull_request.number }}" > pr-number.txt | |
| - name: Upload startup artifacts | |
| if: github.event_name == 'pull_request' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: startup-benchmark-results | |
| path: | | |
| startup-table.txt | |
| pr-number.txt | |
| if-no-files-found: warn | |
| - name: Fail on regression | |
| if: steps.compare.outcome == 'failure' | |
| run: exit 1 | |
| analysis: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout PR | |
| uses: actions/checkout@v6 | |
| with: | |
| path: rules_py_pr | |
| - name: Checkout HEAD main | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| path: rules_py_main | |
| - name: Restore repository cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/bazel-repo | |
| key: bazel-repo-analysis-${{ env.ANALYSIS_BCR_VERSION }}-${{ hashFiles('rules_py_pr/benchmark/analysis/**') }} | |
| restore-keys: | | |
| bazel-repo-analysis- | |
| - name: Install hyperfine | |
| run: | | |
| set -euo pipefail | |
| HYPERFINE_VERSION="1.18.0" | |
| DEB="hyperfine_${HYPERFINE_VERSION}_amd64.deb" | |
| URL="https://github.com/sharkdp/hyperfine/releases/download/v${HYPERFINE_VERSION}/${DEB}" | |
| wget -qO "$DEB" "$URL" | |
| sudo dpkg -i "$DEB" | |
| rm -f "$DEB" | |
| hyperfine --version | |
| - name: Benchmark BCR ${{ env.ANALYSIS_BCR_VERSION }} | |
| run: rules_py_pr/benchmark/analysis/bench.sh bcr bcr --version "${ANALYSIS_BCR_VERSION}" | |
| - name: Benchmark HEAD main | |
| run: rules_py_pr/benchmark/analysis/bench.sh main local --path "$GITHUB_WORKSPACE/rules_py_main" | |
| - name: Benchmark current PR | |
| run: rules_py_pr/benchmark/analysis/bench.sh pr local --path "$GITHUB_WORKSPACE/rules_py_pr" | |
| # ── Compare ───────────────────────────────────────────────────────────── | |
| - name: Compare analysis results | |
| id: compare | |
| continue-on-error: true | |
| run: | | |
| set -euo pipefail | |
| python3 rules_py_pr/benchmark/analysis/compare.py \ | |
| --output-table analysis-table.txt \ | |
| bcr.json main.json pr.json | |
| - name: Upload analysis artifacts | |
| if: github.event_name == 'pull_request' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: analysis-benchmark-results | |
| path: | | |
| analysis-table.txt | |
| if-no-files-found: warn | |
| - name: Fail on regression | |
| if: steps.compare.outcome == 'failure' | |
| run: exit 1 | |
| image-layers: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout PR | |
| uses: actions/checkout@v6 | |
| with: | |
| path: rules_py_pr | |
| - name: Checkout HEAD main | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| path: rules_py_main | |
| - name: Restore repository cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/bazel-repo | |
| key: bazel-repo-image-layers-${{ env.ANALYSIS_BCR_VERSION }}-${{ hashFiles('rules_py_pr/benchmark/analysis/**', 'rules_py_pr/benchmark/image_layers/**') }} | |
| restore-keys: | | |
| bazel-repo-image-layers- | |
| - name: Install hyperfine | |
| run: | | |
| set -euo pipefail | |
| HYPERFINE_VERSION="1.18.0" | |
| DEB="hyperfine_${HYPERFINE_VERSION}_amd64.deb" | |
| URL="https://github.com/sharkdp/hyperfine/releases/download/v${HYPERFINE_VERSION}/${DEB}" | |
| wget -qO "$DEB" "$URL" | |
| sudo dpkg -i "$DEB" | |
| rm -f "$DEB" | |
| hyperfine --version | |
| - name: Benchmark BCR ${{ env.ANALYSIS_BCR_VERSION }} | |
| run: rules_py_pr/benchmark/image_layers/bench.sh bcr bcr --version "${ANALYSIS_BCR_VERSION}" | |
| - name: Benchmark HEAD main | |
| run: rules_py_pr/benchmark/image_layers/bench.sh main local --path "$GITHUB_WORKSPACE/rules_py_main" | |
| - name: Benchmark current PR | |
| run: rules_py_pr/benchmark/image_layers/bench.sh pr local --path "$GITHUB_WORKSPACE/rules_py_pr" | |
| - name: Compare image-layers results | |
| id: compare | |
| continue-on-error: true | |
| run: | | |
| set -euo pipefail | |
| python3 rules_py_pr/benchmark/image_layers/compare.py \ | |
| --output-table image-layers-table.txt \ | |
| bcr main pr | |
| - name: Upload image-layers artifacts | |
| if: github.event_name == 'pull_request' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: image-layers-benchmark-results | |
| path: | | |
| image-layers-table.txt | |
| *-analysis-actions.json | |
| *-inc-source-actions.json | |
| *-inc-wheel-actions.json | |
| if-no-files-found: warn | |
| - name: Fail on regression | |
| if: steps.compare.outcome == 'failure' | |
| run: exit 1 | |
| comment: | |
| runs-on: ubuntu-latest | |
| needs: [startup, analysis, image-layers] | |
| if: always() && github.event_name == 'pull_request' && (needs.startup.result == 'success' || needs.startup.result == 'failure') && (needs.analysis.result == 'success' || needs.analysis.result == 'failure') && (needs['image-layers'].result == 'success' || needs['image-layers'].result == 'failure') | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Download startup artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: startup-benchmark-results | |
| - name: Download analysis artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: analysis-benchmark-results | |
| - name: Download image-layers artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: image-layers-benchmark-results | |
| - name: Post combined benchmark comment | |
| # Fork PRs get a read-only GITHUB_TOKEN; posting the comment 403s. | |
| if: github.event.pull_request.head.repo.full_name == github.repository | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const startup = fs.readFileSync('startup-table.txt', 'utf8').trim(); | |
| const analysis = fs.readFileSync('analysis-table.txt', 'utf8').trim(); | |
| const imageLayers = fs.readFileSync('image-layers-table.txt', 'utf8').trim(); | |
| const prNumber = parseInt(fs.readFileSync('pr-number.txt', 'utf8').trim()); | |
| const header = '<!-- performance-benchmark -->'; | |
| const body = `${header}\n\n${startup}\n\n${analysis}\n\n${imageLayers}`; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| }); | |
| const existing = comments.find(c => c.body && c.body.includes(header)); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body: body, | |
| }); | |
| console.log(`Updated comment ${existing.id}`); | |
| } else { | |
| const { data: created } = await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| body: body, | |
| }); | |
| console.log(`Created comment ${created.id}`); | |
| } | |
| - name: Fail if any benchmark regressed | |
| if: needs.startup.result == 'failure' || needs.analysis.result == 'failure' || needs['image-layers'].result == 'failure' | |
| run: exit 1 |