Use combined status for Github status checks

When checking the required status checks we currently get all statuses
and get the successful of them. However Github returns all historic
status changes there. So a change that get a successful check, then a
recheck and then a failed check still enters the gate but will be
prohibited by Github to merge in the end. However github also offers
us a combined status call that only returns the current state of the
statuses. Using this fixes the issue.

Change-Id: Iec3b2a3dfc8626870381604badd40de71e7257b9
This commit is contained in:
Tobias Henkel
2018-12-07 08:50:43 +01:00
parent ced4584c43
commit 9fa93fdefa
3 changed files with 39 additions and 3 deletions

View File

@@ -896,8 +896,25 @@ class TestGithubDriver(ZuulTestCase):
# job is expected
self.assertEqual(0, len(self.history))
# now set the required status 'tenant-one/check'
# now set a failing status 'tenant-one/check'
repo = github.repo_from_project('org/project')
repo.create_status(A.head_sha, 'failed', 'example.com', 'description',
'tenant-one/check')
self.fake_github.emitEvent(A.getPullRequestOpenedEvent())
self.waitUntilSettled()
self.assertEqual(0, len(self.history))
# now set a successful status followed by a failing status to check
# that the later failed status wins
repo.create_status(A.head_sha, 'success', 'example.com', 'description',
'tenant-one/check')
repo.create_status(A.head_sha, 'failed', 'example.com', 'description',
'tenant-one/check')
self.fake_github.emitEvent(A.getPullRequestOpenedEvent())
self.waitUntilSettled()
self.assertEqual(0, len(self.history))
# now set the required status 'tenant-one/check'
repo.create_status(A.head_sha, 'success', 'example.com', 'description',
'tenant-one/check')