set auto hotkey per subnet #91
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] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| actions: read # required to list & download artifacts across workflows | |
| 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: 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 | |
| run: | | |
| set -euo pipefail | |
| 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}" | |
| - 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 |