Skip to content

Commit

Permalink
Handle build timeout comments
Browse files Browse the repository at this point in the history
Homu creates a message when a try or build timeout occurs. Handle this
to keep the state properly updated.
  • Loading branch information
bryanburgers committed Jul 2, 2019
1 parent a9234c7 commit 2b83596
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
6 changes: 6 additions & 0 deletions homu/pull_req_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,12 @@ def process_homu_state(self, event, command):
self.status = 'failure'
self.try_state = BuildState.FAILURE

elif state['type'] == 'TimedOut':
result.changed = True
self.status = 'failure'
# TODO: Do we need to determine if a try or a build failed?
self.try_state = BuildState.FAILURE

return result

@property
Expand Down
45 changes: 45 additions & 0 deletions homu/tests/test_process_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,51 @@ def test_try_failed(_):
assert state.try_state == BuildState.FAILURE


@unittest.mock.patch('homu.pull_req_state.assert_authorized',
side_effect=return_true)
def test_try_timed_out(_):
"""
Test that a pull request that has been tried shows up as tried
"""

state = new_state()
result = state.process_event(create_event({
'eventType': 'IssueComment',
'author': {
'login': 'bors',
},
'body': '''
:hourglass: Trying commit 065151f8b2c31d9e4ddd34aaf8d3263a997f5cfe with merge 330c85d9270b32d7703ebefc337eb37ae959f741...
<!-- homu: {"type":"TryBuildStarted","head_sha":"065151f8b2c31d9e4ddd34aaf8d3263a997f5cfe","merge_sha":"330c85d9270b32d7703ebefc337eb37ae959f741"} -->
''', # noqa
'publishedAt': '1985-04-21T00:00:00Z',
}))

assert result.changed is True
assert state.try_ is True
assert state.get_status() == 'pending'
assert state.build_state == BuildState.NONE
assert state.try_state == BuildState.PENDING

result = state.process_event(create_event({
'eventType': 'IssueComment',
'author': {
'login': 'bors',
},
'body': '''
:boom: Test timed out
<!-- homu: {"type":"TimedOut"} -->
''', # noqa
'publishedAt': '1985-04-21T00:01:00Z',
}))

assert result.changed is True
assert state.try_ is True
assert state.get_status() == 'failure'
assert state.build_state == BuildState.NONE
assert state.try_state == BuildState.FAILURE


@unittest.mock.patch('homu.pull_req_state.assert_authorized',
side_effect=return_true)
def test_try_reset_by_push(_):
Expand Down

0 comments on commit 2b83596

Please sign in to comment.