From 80e0305227081da4d5de19be374cfd17cde90aa5 Mon Sep 17 00:00:00 2001 From: Erwan Bernard Date: Thu, 28 Apr 2022 14:47:05 +0200 Subject: [PATCH] [BERTE-565] Fix keyerror when workflow dispatch is triggered on the commit_status checked --- CHANGELOG | 4 ++++ bert_e/git_host/github/__init__.py | 12 ++++++++---- bert_e/git_host/github/schema.py | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index bd56f149..2a8b66b0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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. diff --git a/bert_e/git_host/github/__init__.py b/bert_e/git_host/github/__init__.py index d7ccf4ac..72634f03 100644 --- a/bert_e/git_host/github/__init__.py +++ b/bert_e/git_host/github/__init__.py @@ -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'] @@ -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): @@ -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( diff --git a/bert_e/git_host/github/schema.py b/bert_e/git_host/github/schema.py index 5a180051..f5ff372e 100644 --- a/bert_e/git_host/github/schema.py +++ b/bert_e/git_host/github/schema.py @@ -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):