slub
slub copied to clipboard
Fix: Prevent duplicate CI failure notifications on branch updates
Problem
When pushing new commits or updating a branch, users receive duplicate "CI Failed" notifications in Slack for the old failure, not the new commit.
Root Cause: When a PR transitions to PENDING (new commit pushed), the previous build link was cleared. GitHub then sends a webhook with the old failure status, and the bot treats it as a new failure.
Solution
1. Preserve build link when going PENDING (PR.php:272-276)
$previousBuildLink = $this->CIStatus->buildLink();
$this->CIStatus = CIStatus::endedWith(BuildResult::pending(), $previousBuildLink);
2. Detect and ignore stale webhooks (PR.php:254-255)
if ($this->CIStatus->isPendingWithLink($buildLink)) {
return; // Stale webhook from old CI run - ignore it
}
3. Added helper methods (CIStatus.php)
-
isPendingWithLink()– Check if PENDING with specific build link -
buildLink()– Getter for build link - Fixed
isRedWithLink()– Now checks both status and link
🧪 Test Coverage
Added 3 tests in PRTest.php:
- Duplicate RED with same link (line 363–377)
- Different build links create new events (line 382–399)
- Stale webhook scenario – the bug fix (line 404–421)