diff --git a/homu/pull_req_state.py b/homu/pull_req_state.py index 44b42e2..c544053 100644 --- a/homu/pull_req_state.py +++ b/homu/pull_req_state.py @@ -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 diff --git a/homu/tests/test_process_event.py b/homu/tests/test_process_event.py index 3ed5b7b..5c0deb4 100644 --- a/homu/tests/test_process_event.py +++ b/homu/tests/test_process_event.py @@ -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... + + ''', # 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 + + ''', # 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(_):