From f0ad1befcbb820e0bd116dca13016d24fb799693 Mon Sep 17 00:00:00 2001 From: Ihor Solodrai Date: Thu, 8 Oct 2026 16:08:54 -0700 Subject: [PATCH] ai-code-review-rc: skip unsampled PRs before starting CodeBuild The get-commits job starts a CodeBuild runner for every PR, even when the series is outside the shadow review sample. Move sampling to the job condition so that unsampled PRs skip both jobs before a runner is allocated. Select PRs whose head SHA starts with 0-3, approximately one in four. This replaces the series-ID modulo check with four short expressions. Keep test PRs against ai-review-base unconditional. Assisted-by: Codex:GPT-6 Signed-off-by: Ihor Solodrai --- .github/workflows/ai-code-review-rc.yml | 26 +++++++++++-------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ai-code-review-rc.yml b/.github/workflows/ai-code-review-rc.yml index ae89b712..79785b21 100644 --- a/.github/workflows/ai-code-review-rc.yml +++ b/.github/workflows/ai-code-review-rc.yml @@ -17,13 +17,20 @@ on: env: # The experiment: the bpf-ai-review ref to review with. AI_REVIEW_WRAPPER_REF: shadow/subsystem-build - # Review one in N KPD series. - AI_REVIEW_SAMPLE_EVERY: 4 jobs: get-commits-rc: - # This codition is an indicator that we are running in a context of PR owned by kernel-patches org - if: ${{ github.repository == 'kernel-patches/bpf-rc' && vars.AWS_REGION }} + # Sample about one in four KPD PRs by head SHA (first hex digit 0-3). + # Test PRs against ai-review-base always run. Decide before allocating + # a CodeBuild runner so that unsampled PRs skip the entire workflow. + if: >- + github.repository == 'kernel-patches/bpf-rc' && vars.AWS_REGION && + (github.base_ref == 'ai-review-base' || + (startsWith(github.head_ref, 'series/') && + (startsWith(github.event.pull_request.head.sha, '0') || + startsWith(github.event.pull_request.head.sha, '1') || + startsWith(github.event.pull_request.head.sha, '2') || + startsWith(github.event.pull_request.head.sha, '3')))) runs-on: - ${{ format('codebuild-bpf-ci-{0}-{1}', github.run_id, github.run_attempt) }} - image:custom-linux-ghcr.io/kernel-patches/runner:kbuilder-debian-x86_64 @@ -49,17 +56,6 @@ jobs: - name: Get PR commits id: get-commits run: | - # Review one in AI_REVIEW_SAMPLE_EVERY KPD series, by patchwork series - # ID. Test PRs against ai-review-base always run. - if [ "$GITHUB_BASE_REF" != ai-review-base ]; then - if ! [[ $GITHUB_HEAD_REF =~ ^series/([0-9]+)= ]] || - (( BASH_REMATCH[1] % AI_REVIEW_SAMPLE_EVERY )); then - echo "::notice::$GITHUB_HEAD_REF is not sampled (1 in ${AI_REVIEW_SAMPLE_EVERY} series)" - echo "commits=[]" >> "$GITHUB_OUTPUT" - echo "has-commits=false" >> "$GITHUB_OUTPUT" - exit 0 - fi - fi cd .kernel if [ "$(git log -1 --format=%s ${{ github.event.pull_request.head.sha }})" = "Dummy commit" ]; then echo "::notice::KPD Dummy commit, the series did not apply: skipping AI review"