fix: live pre-merge build-status revalidation (BERTE-602)#268
Merged
matthiasL-scality merged 2 commits intoJun 1, 2026
Conversation
cd4b948 to
61b5e95
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #268 +/- ##
==========================================
+ Coverage 89.31% 89.54% +0.22%
==========================================
Files 78 79 +1
Lines 10316 10522 +206
==========================================
+ Hits 9214 9422 +208
+ Misses 1102 1100 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
61b5e95 to
93143c7
Compare
Contributor
matthiasL-scality
left a comment
There was a problem hiding this comment.
Code review — non-blocking observations
matthiasL-scality
approved these changes
May 20, 2026
Documents pytest binary location, GitHub release process, and the devdocs release checklist reference. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Introduces revalidate_build_status(), called immediately before the merge/queue decision in _handle_pull_request. Unlike check_build_status, it bypasses BUILD_STATUS_CACHE and fetches live state from the GitHub Actions API, then filters workflow runs strictly to each wbranch's own head_branch before aggregating. Root cause (PR artesca#5155): a push run on the PR branch was still in_progress when bert-e polled. The run shared a SHA with development/4, which had already completed successfully. AggregatedWorkflowRuns.state returned SUCCESSFUL because it grouped by branch then returned SUCCESSFUL if *any* branch succeeded, poisoning the cache entry and hiding the in-progress run on the w-branch. New AggregatedWorkflowRuns.state_for_branch(name) filters and deduplicates within a single branch before calling branch_state(), preventing cross- branch SHA poisoning. revalidate_build_status uses this method. Hosts without get_commit_status (e.g. Bitbucket) are skipped gracefully. Tests added in test_github_build_status.py document the poisoning scenario and verify the per-branch fix. test_revalidate_build_status.py covers the full decision matrix: PR 5155 shape → BuildInProgress, clean PR → passes, bypass/no-key/no-method → skipped, failed/no-runs → appropriate exception. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
93143c7 to
3adafc9
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
revalidate_build_status(), called immediately before the merge/queue decision in_handle_pull_request. It bypassesBUILD_STATUS_CACHEand fetches live state from the GitHub Actions API, filtering workflow runs strictly to the current w-branch before aggregating.AggregatedWorkflowRuns.state_for_branch(name): filters and deduplicates within a single branch, preventing a sibling branch sharing the same SHA from producing a falseSUCCESSFUL.BuildInProgress).Root cause (artesca#5155, 2026-05-20)
The source branch was renamed; the new w-branch shared its commit SHA with the old w-branch. GitHub's API returned workflow runs for both names.
AggregatedWorkflowRuns.statepicked the best status across branches, returningSUCCESSFULbecause the old w-branch completed. That result was latched intoBUILD_STATUS_CACHE(which never overwritesSUCCESSFUL). When the peer approval landed 15 s later, Bert-E readSUCCESSFULfrom cache and merged — while the actual push CI on the new w-branch was still running.What this PR does
bert_e/git_host/github/__init__.pystate_for_branch(branch_name): filters_workflow_runstobranch_namebefore deduplicating byworkflow_id, so a sibling branch cannot mask the result. Logs the filtered run snapshot (branch + runs + conclusion) for post-mortem diagnostics.bert_e/workflow/gitwaterflow/__init__.pyrevalidate_build_status(job, wbranches): live, cache-bypassing final check at the merge decision boundary. Callsget_commit_status()directly (always hits the API), usesstate_for_branchfor GitHub Actions keys, skips gracefully for hosts withoutget_commit_status(e.g. Bitbucket)._handle_pull_requestafter the interactive confirm and beforebuild_queue_collection.Test plan
test_artesca5155_renamed_branch_inprogress_blocked— exact incident shape, assertsBuildInProgresstest_artesca5155_old_aggregator_would_have_passed— documents the pre-fix bug:AggregatedWorkflowRuns.statereturnsSUCCESSFULfor the same datatest_pr5155_shape_raises_build_in_progress— same SHA on w-branch (in_progress) and destination (success)state_for_branchunit tests: cross-branch poisoning, dedup within branch, workflow_dispatch exclusion, no-runs case🤖 Generated with Claude Code