Skip to content

Commit

Permalink
[BERTE-565] Fix keyerror when workflow dispatch is triggered on the c…
Browse files Browse the repository at this point in the history
…ommit_status checked
  • Loading branch information
erwan-b committed Apr 28, 2022
1 parent 1b920f5 commit 80e0305
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file.

## [3.6.9] - 2022-04-25
# Fixed
- Fix Key error when workflow dispatch is triggered on the commit_status checked

## [3.6.9] - 2022-04-25
# Fixed
- Handle GitHub Actions status when workflow is pending.
Expand Down
12 changes: 8 additions & 4 deletions bert_e/git_host/github/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ def _get_check_suite_ids(self, workflow_runs):
map(lambda elem: elem['check_suite_id'], workflow_runs)
)

def _get_aggregate_workflow_dispatched(self):
def _get_aggregate_workflow_dispatched(self, page):
ref = self._check_suites[0]['head_sha']
repo = self._check_suites[0]['repository']['name']
owner = self._check_suites[0]['repository']['owner']['login']
Expand All @@ -580,7 +580,8 @@ def _get_aggregate_workflow_dispatched(self):
owner=owner, repo=repo, ref=ref,
params={
'event': 'workflow_dispatch',
'branch': self._check_suites[0]['head_branch']
'branch': self._check_suites[0]['head_branch'],
'page': page
})

def remove_unwanted_workflows(self):
Expand All @@ -592,10 +593,13 @@ def remove_unwanted_workflows(self):
if self._check_suites.__len__() == 0:
return

response = self._get_aggregate_workflow_dispatched()
page = 1
response = self._get_aggregate_workflow_dispatched(page)
dispatched = self._get_check_suite_ids(response.workflow_runs)

while len(dispatched) < response.total_count:
response = self._get_aggregate_workflow_dispatched()
page += 1
response = self._get_aggregate_workflow_dispatched(page)
dispatched += self._get_check_suite_ids(response.workflow_runs)

self._check_suites = list(filter(
Expand Down
1 change: 1 addition & 0 deletions bert_e/git_host/github/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class WorkflowRun(Schema):
head_sha = fields.Str()
head_branch = fields.Str()
status = fields.Str()
check_suite_id = fields.Integer()


class AggregateWorkflowRuns(Schema):
Expand Down

0 comments on commit 80e0305

Please sign in to comment.