@@ -1733,6 +1733,64 @@ main = hspec $ do
1733
1733
state `shouldBe` state'
1734
1734
removeFile fname
1735
1735
1736
+ it " ignores builds on other branches" $ do
1737
+ let
1738
+ state = Project. insertPullRequest
1739
+ (PullRequestId 360 )
1740
+ (Branch " add-package" )
1741
+ masterBranch
1742
+ (Sha " c6b" )
1743
+ " Three hundred and sixtieth PR"
1744
+ (Username " tyrell" )
1745
+ $ Project. emptyProjectState
1746
+ events =
1747
+ [ CommentAdded (PullRequestId 360 ) " deckard" " @someone Thanks for your review."
1748
+ , CommentAdded (PullRequestId 360 ) " deckard" " @bot merge"
1749
+
1750
+ -- same status, ignored:
1751
+ , BuildStatusChanged [Branch " testing/360" ] (Sha " c6b" ) Project. BuildPending
1752
+ -- correct branch but different sha (old build?), ignored
1753
+ , BuildStatusChanged [Branch " testing/360" ] (Sha " ab0" ) (Project. BuildStarted " ci.example.com/diff-sha" )
1754
+ -- correct sha but different branch
1755
+ , BuildStatusChanged [Branch " add-package" ] (Sha " c6b" ) (Project. BuildStarted " ci.exmaple.com/diff-branch" )
1756
+
1757
+ -- unrecognized command to act as a separator
1758
+ , CommentAdded (PullRequestId 360 ) " deckard" " @bot do something"
1759
+
1760
+ -- correct branch and sha
1761
+ , BuildStatusChanged [Branch " testing/360" ] (Sha " c6b" ) (Project. BuildStarted " ci.example.com/correct" )
1762
+
1763
+ -- correct branch but different sha (old build?), ignored
1764
+ , BuildStatusChanged [Branch " testing/360" ] (Sha " ab0" ) (Project. BuildFailed (Just " ci.example.com/diff-sha" ))
1765
+ -- correct sha but different branch
1766
+ -- older versions would fail to merge this PR, even though it's "official" build passed
1767
+ , BuildStatusChanged [Branch " add-package" ] (Sha " c6b" ) (Project. BuildFailed (Just " ci.exmaple.com/diff-branch" ))
1768
+ -- correct branch and sha
1769
+ , BuildStatusChanged [Branch " testing/360" ] (Sha " c6b" ) Project. BuildSucceeded
1770
+ ]
1771
+ results = defaultResults{resultIntegrate = [Right (Sha " c6b" )]} -- fastforward
1772
+ run = runActionCustom results
1773
+ actions = snd $ run $ handleEventsTest events state
1774
+ actions `shouldBe`
1775
+ [ AIsReviewer " deckard"
1776
+ -- comment: @bot merge!
1777
+ , ALeaveComment (PullRequestId 360 )
1778
+ " Pull request approved for merge by @deckard, rebasing now."
1779
+ , ATryIntegrate " Merge #360: Three hundred and sixtieth PR\n\n \
1780
+ \Approved-by: deckard\n \
1781
+ \Auto-deploy: false\n "
1782
+ (PullRequestId 360 , Branch " refs/pull/360/head" , Sha " c6b" )
1783
+ False
1784
+ , ALeaveComment (PullRequestId 360 ) " Rebased as c6b, waiting for CI …"
1785
+ -- incorrect CI link webhooks arrive
1786
+ -- comment: @bot do something!
1787
+ , ALeaveComment (PullRequestId 360 ) " `do something` was not recognized as a valid command."
1788
+ -- correct CI link webhook arrives
1789
+ , ALeaveComment (PullRequestId 360 ) " [CI job](ci.example.com/correct) started."
1790
+ , ATryPromote (Branch " add-package" ) (Sha " c6b" )
1791
+ , ACleanupTestBranch (PullRequestId 360 )
1792
+ ]
1793
+
1736
1794
it " handles a sequence of merges: success, success, success" $ do
1737
1795
-- An afternoon of work on PRs:
1738
1796
-- * three PRs are merged and approved in order
0 commit comments