Skip to content

Commit 08490be

Browse files
sbryngelsonclaude
andcommitted
Skip build cache for benchmarks and fix benchmark trigger logic
Benchmarks build PR and master in parallel — sharing a cache key causes collisions. Skip cache setup when run_bench=="bench" so each benchmark builds from scratch. Also fix two issues in the benchmark workflow trigger: - Cross-repo PRs don't populate pull_requests[]; fall back to searching by head SHA so the PR author is correctly detected. - Only count approvals from users with write/maintain/admin permission, filtering out AI bot approvals (Copilot, Qodo). - Remove wilfonba auto-run; only sbryngelson auto-runs benchmarks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bb7f705 commit 08490be

3 files changed

Lines changed: 30 additions & 14 deletions

File tree

.github/workflows/bench.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,34 @@ jobs:
4646
else
4747
# Get PR number from workflow_run
4848
PR_NUMBER="${{ github.event.workflow_run.pull_requests[0].number }}"
49+
if [ -z "$PR_NUMBER" ]; then
50+
# Cross-repo PRs don't populate pull_requests[]. Search by head SHA.
51+
HEAD_SHA="${{ github.event.workflow_run.head_sha }}"
52+
PR_NUMBER=$(gh api "repos/${{ github.repository }}/pulls?state=open&sort=updated&direction=desc&per_page=30" \
53+
--jq ".[] | select(.head.sha == \"$HEAD_SHA\") | .number" | head -1)
54+
fi
55+
4956
if [ -n "$PR_NUMBER" ]; then
5057
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
5158
5259
# Fetch actual PR author from API (workflow_run.actor is the re-runner, not PR author)
5360
PR_AUTHOR=$(gh api repos/${{ github.repository }}/pulls/$PR_NUMBER --jq '.user.login')
5461
echo "author=$PR_AUTHOR" >> $GITHUB_OUTPUT
5562
56-
# Check if PR is approved
57-
APPROVED=$(gh api repos/${{ github.repository }}/pulls/$PR_NUMBER/reviews \
58-
--jq '[.[] | select(.state == "APPROVED")] | length')
59-
if [ "$APPROVED" -gt 0 ]; then
60-
echo "approved=true" >> $GITHUB_OUTPUT
61-
else
62-
echo "approved=false" >> $GITHUB_OUTPUT
63-
fi
63+
# Check if PR is approved by a maintainer/admin (ignore AI bot approvals)
64+
APPROVERS=$(gh api "repos/${{ github.repository }}/pulls/$PR_NUMBER/reviews" \
65+
--jq '[.[] | select(.state == "APPROVED") | .user.login] | unique | .[]')
66+
APPROVED="false"
67+
for approver in $APPROVERS; do
68+
PERM=$(gh api "repos/${{ github.repository }}/collaborators/$approver/permission" \
69+
--jq '.permission' 2>/dev/null || echo "none")
70+
if [ "$PERM" = "admin" ] || [ "$PERM" = "maintain" ] || [ "$PERM" = "write" ]; then
71+
echo " Approved by $approver (permission: $PERM)"
72+
APPROVED="true"
73+
break
74+
fi
75+
done
76+
echo "approved=$APPROVED" >> $GITHUB_OUTPUT
6477
else
6578
echo "pr_number=" >> $GITHUB_OUTPUT
6679
echo "approved=false" >> $GITHUB_OUTPUT
@@ -76,8 +89,7 @@ jobs:
7689
(
7790
github.event_name == 'workflow_dispatch' ||
7891
needs.file-changes.outputs.pr_approved == 'true' ||
79-
needs.file-changes.outputs.pr_author == 'sbryngelson' ||
80-
needs.file-changes.outputs.pr_author == 'wilfonba'
92+
needs.file-changes.outputs.pr_author == 'sbryngelson'
8193
)
8294
needs: [file-changes]
8395
strategy:

.github/workflows/frontier/build.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ fi
1818

1919
. ./mfc.sh load -c f -m g
2020

21-
# Set up persistent build cache
22-
source .github/scripts/setup-build-cache.sh frontier "$job_device" "$job_interface"
21+
# Only set up build cache for test suite, not benchmarks
22+
if [ "$run_bench" != "bench" ]; then
23+
source .github/scripts/setup-build-cache.sh frontier "$job_device" "$job_interface"
24+
fi
2325

2426
max_attempts=3
2527
attempt=1

.github/workflows/frontier_amd/build.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ fi
1818

1919
. ./mfc.sh load -c famd -m g
2020

21-
# Set up persistent build cache
22-
source .github/scripts/setup-build-cache.sh frontier_amd "$job_device" "$job_interface"
21+
# Only set up build cache for test suite, not benchmarks
22+
if [ "$run_bench" != "bench" ]; then
23+
source .github/scripts/setup-build-cache.sh frontier_amd "$job_device" "$job_interface"
24+
fi
2325

2426
max_attempts=3
2527
attempt=1

0 commit comments

Comments
 (0)