Skip to content

Commit 2b83596

Browse files
committed
Handle build timeout comments
Homu creates a message when a try or build timeout occurs. Handle this to keep the state properly updated.
1 parent a9234c7 commit 2b83596

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

homu/pull_req_state.py

+6
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,12 @@ def process_homu_state(self, event, command):
880880
self.status = 'failure'
881881
self.try_state = BuildState.FAILURE
882882

883+
elif state['type'] == 'TimedOut':
884+
result.changed = True
885+
self.status = 'failure'
886+
# TODO: Do we need to determine if a try or a build failed?
887+
self.try_state = BuildState.FAILURE
888+
883889
return result
884890

885891
@property

homu/tests/test_process_event.py

+45
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,51 @@ def test_try_failed(_):
392392
assert state.try_state == BuildState.FAILURE
393393

394394

395+
@unittest.mock.patch('homu.pull_req_state.assert_authorized',
396+
side_effect=return_true)
397+
def test_try_timed_out(_):
398+
"""
399+
Test that a pull request that has been tried shows up as tried
400+
"""
401+
402+
state = new_state()
403+
result = state.process_event(create_event({
404+
'eventType': 'IssueComment',
405+
'author': {
406+
'login': 'bors',
407+
},
408+
'body': '''
409+
:hourglass: Trying commit 065151f8b2c31d9e4ddd34aaf8d3263a997f5cfe with merge 330c85d9270b32d7703ebefc337eb37ae959f741...
410+
<!-- homu: {"type":"TryBuildStarted","head_sha":"065151f8b2c31d9e4ddd34aaf8d3263a997f5cfe","merge_sha":"330c85d9270b32d7703ebefc337eb37ae959f741"} -->
411+
''', # noqa
412+
'publishedAt': '1985-04-21T00:00:00Z',
413+
}))
414+
415+
assert result.changed is True
416+
assert state.try_ is True
417+
assert state.get_status() == 'pending'
418+
assert state.build_state == BuildState.NONE
419+
assert state.try_state == BuildState.PENDING
420+
421+
result = state.process_event(create_event({
422+
'eventType': 'IssueComment',
423+
'author': {
424+
'login': 'bors',
425+
},
426+
'body': '''
427+
:boom: Test timed out
428+
<!-- homu: {"type":"TimedOut"} -->
429+
''', # noqa
430+
'publishedAt': '1985-04-21T00:01:00Z',
431+
}))
432+
433+
assert result.changed is True
434+
assert state.try_ is True
435+
assert state.get_status() == 'failure'
436+
assert state.build_state == BuildState.NONE
437+
assert state.try_state == BuildState.FAILURE
438+
439+
395440
@unittest.mock.patch('homu.pull_req_state.assert_authorized',
396441
side_effect=return_true)
397442
def test_try_reset_by_push(_):

0 commit comments

Comments
 (0)