[storage] More Exoware Helpers #1550
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 | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| permissions: | |
| actions: read | |
| contents: read | |
| issues: write | |
| pull-requests: write | |
| concurrency: | |
| group: check-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| check: | |
| name: Check | |
| runs-on: ubuntu-latest-8 | |
| timeout-minutes: 180 | |
| env: | |
| BENCHMARK_TRACKING_CONFIG: .github/benchmark-tracking.toml | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 | |
| - name: Find latest main benchmark artifact | |
| if: github.event_name == 'pull_request' | |
| id: baseline | |
| uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0 | |
| with: | |
| script: | | |
| const {owner, repo} = context.repo; | |
| const artifacts = await github.paginate(github.rest.actions.listArtifactsForRepo, { | |
| owner, | |
| repo, | |
| name: 'benchmark-tracking-results', | |
| per_page: 100, | |
| }); | |
| artifacts.sort((a, b) => new Date(b.created_at) - new Date(a.created_at)); | |
| const artifact = artifacts.find((candidate) => | |
| !candidate.expired && candidate.workflow_run?.head_branch === 'main' | |
| ); | |
| if (artifact) { | |
| core.setOutput('found', 'true'); | |
| core.setOutput('run_id', String(artifact.workflow_run.id)); | |
| } else { | |
| core.warning('No benchmark-tracking artifact found for main'); | |
| core.setOutput('found', 'false'); | |
| } | |
| - name: Download main benchmark artifact | |
| if: github.event_name == 'pull_request' && steps.baseline.outputs.found == 'true' | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| name: benchmark-tracking-results | |
| path: benchmark-tracking-baseline | |
| run-id: ${{ steps.baseline.outputs.run_id }} | |
| github-token: ${{ github.token }} | |
| - name: Run setup | |
| uses: ./.github/actions/setup | |
| with: | |
| toolchain: nightly | |
| - name: Run benchmark tracking | |
| id: run | |
| run: | | |
| args=() | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| if [ -f benchmark-tracking-baseline/current.toml ]; then | |
| args=(--baseline benchmark-tracking-baseline/current.toml) | |
| fi | |
| else | |
| args=(--no-compare) | |
| fi | |
| python3 .github/scripts/benchmark-tracking.py \ | |
| --config "$BENCHMARK_TRACKING_CONFIG" \ | |
| --output-dir benchmark-tracking-results \ | |
| "${args[@]}" | |
| - name: Upload benchmark results | |
| if: always() && github.ref == 'refs/heads/main' && steps.run.outcome == 'success' | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: benchmark-tracking-results | |
| path: benchmark-tracking-results | |
| if-no-files-found: error | |
| - name: Add benchmark summary | |
| if: always() && github.event_name == 'pull_request' && steps.run.outcome == 'success' | |
| run: cat benchmark-tracking-results/comment.md >> "$GITHUB_STEP_SUMMARY" | |
| - name: Comment on pull request | |
| if: always() && github.event_name == 'pull_request' && steps.run.outcome == 'success' | |
| continue-on-error: true | |
| uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const marker = '<!-- commonware-benchmark-tracking-results -->'; | |
| const body = fs.readFileSync('benchmark-tracking-results/comment.md', 'utf8'); | |
| const {owner, repo} = context.repo; | |
| const issue_number = context.payload.pull_request.number; | |
| const comments = await github.paginate(github.rest.issues.listComments, { | |
| owner, | |
| repo, | |
| issue_number, | |
| per_page: 100, | |
| }); | |
| const previous = comments.find((comment) => | |
| comment.user.type === 'Bot' && comment.body.includes(marker) | |
| ); | |
| if (previous) { | |
| await github.rest.issues.updateComment({ | |
| owner, | |
| repo, | |
| comment_id: previous.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({owner, repo, issue_number, body}); | |
| } | |
| - name: Fail on benchmark regression | |
| if: always() && github.event_name == 'pull_request' && steps.run.outcome == 'success' | |
| run: | | |
| python3 - <<'PY' | |
| import sys | |
| import tomllib | |
| with open('benchmark-tracking-results/summary.toml', 'rb') as f: | |
| summary = tomllib.load(f) | |
| regressions = summary.get('regression_count', 0) | |
| if regressions: | |
| print(f'{regressions} benchmark(s) exceeded the configured threshold') | |
| sys.exit(1) | |
| PY |