auto spec version bump #203
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
| # .github/workflows/apply-benchmark-patch.yml | |
| name: Apply-Benchmark-Patch | |
| on: | |
| pull_request: | |
| types: [labeled] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| actions: write # re-trigger downstream workflows after applying the patch | |
| jobs: | |
| apply: | |
| if: ${{ github.event.label.name == 'apply-benchmark-patch' }} | |
| runs-on: Benchmarking | |
| steps: | |
| - name: Check out PR branch | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| fetch-depth: 0 | |
| - name: Check out automation helpers from base branch | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.repository }} | |
| ref: ${{ github.event.pull_request.base.ref }} | |
| path: ci-tools | |
| fetch-depth: 1 | |
| - name: Install GitHub CLI | |
| run: | | |
| sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get update | |
| sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get install -y --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" gh | |
| echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token | |
| - name: Download latest bench patch artifact from heavy workflow | |
| uses: dawidd6/action-download-artifact@v3 | |
| with: | |
| workflow: run-benchmarks.yml | |
| pr: ${{ github.event.pull_request.number }} | |
| name: bench-patch | |
| path: . | |
| allow_forks: true | |
| check_artifacts: true | |
| search_artifacts: true | |
| workflow_conclusion: "" | |
| if_no_artifact_found: warn | |
| - name: Extract bench patch archive | |
| run: | | |
| set -euo pipefail | |
| if [ -f "bench-patch.tgz" ]; then | |
| tar -xzf bench-patch.tgz | |
| elif [ -f "bench-patch/bench-patch.tgz" ]; then | |
| tar -xzf bench-patch/bench-patch.tgz | |
| else | |
| echo "No bench-patch.tgz found after download." | |
| exit 0 | |
| fi | |
| ls -la .bench_patch || true | |
| - name: Apply and commit patch | |
| id: apply_patch | |
| run: | | |
| set -euo pipefail | |
| echo "changes_applied=false" >> "$GITHUB_OUTPUT" | |
| if [ ! -d ".bench_patch" ]; then | |
| echo "No .bench_patch directory found after extraction." | |
| exit 0 | |
| fi | |
| if [ -f ".bench_patch/summary.txt" ]; then | |
| echo "==== summary.txt ====" | |
| sed -n '1,200p' .bench_patch/summary.txt || true | |
| echo "=====================" | |
| fi | |
| if [ ! -f ".bench_patch/benchmark_patch.diff" ]; then | |
| echo "No benchmark_patch.diff found (no auto-patch created)." | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| if ! git apply --index --3way .bench_patch/benchmark_patch.diff; then | |
| echo "Patch failed to apply cleanly. Please re-run Validate-Benchmarks to regenerate." | |
| exit 1 | |
| fi | |
| if git diff --cached --quiet; then | |
| echo "Patch applied but produced no changes (already up to date)." | |
| exit 0 | |
| fi | |
| echo "==== diff preview ====" | |
| git diff --cached --stat | |
| git diff --cached | head -n 120 || true | |
| echo "======================" | |
| branch=$(git symbolic-ref --quiet --short HEAD || true) | |
| if [ -z "$branch" ]; then | |
| echo "Not on a branch - cannot push" >&2 | |
| exit 1 | |
| fi | |
| git commit -m "auto-update benchmark weights" | |
| git push origin "HEAD:${branch}" | |
| new_sha=$(git rev-parse HEAD) | |
| echo "changes_applied=true" >> "$GITHUB_OUTPUT" | |
| echo "head_sha=${new_sha}" >> "$GITHUB_OUTPUT" | |
| - name: Re-run pull_request workflows (except Validate-Benchmarks) | |
| if: steps.apply_patch.outputs.changes_applied == 'true' | |
| run: python3 ci-tools/scripts/ci/rerun_pr_workflows.py | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| PR_HEAD_SHA: ${{ steps.apply_patch.outputs.head_sha }} | |
| EXTRA_SKIP_WORKFLOWS: Apply-Benchmark-Patch | |
| - name: Remove apply-benchmark-patch label | |
| if: ${{ success() }} | |
| run: | | |
| gh pr edit ${{ github.event.pull_request.number }} \ | |
| --repo "${{ github.repository }}" \ | |
| --remove-label "apply-benchmark-patch" || true |