Skip to content

Commit 45adce6

Browse files
authored
Merge pull request #29 from scality/bugfix/BERTE-547/github-action-stastus-error
[berte-547] GitHub action status error
2 parents 4f9eaad + a194dd5 commit 45adce6

3 files changed

Lines changed: 22 additions & 53 deletions

File tree

CHANGELOG

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [3.6.1] - 2021-05-26
5+
# Fixed
6+
- API call error was returning to much information, now it return only action results.
7+
48
## [3.6.0] - 2021-04-27
59
# Added
610
- Support GitHub Action CI thanks to a new build key config `github_actions`
711

8-
9-
1012
## [3.5.0] - 2021-04-27
1113
# Added
1214
- Add "pr_author_options" option to config, which add bypass to a specifique user

bert_e/git_host/github/__init__.py

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,9 @@ def get_commit_status(self, ref):
355355
owner=self.owner,
356356
repo=self.slug, ref=ref)
357357

358-
actions = AggregatedCheckSuites.get(self.client,
359-
owner=self.owner,
360-
repo=self.slug, ref=ref)
358+
actions = AggregatedCheckRuns.get(self.client,
359+
owner=self.owner,
360+
repo=self.slug, ref=ref)
361361
combined.status[actions.key] = actions
362362

363363
except HTTPError as err:
@@ -507,62 +507,41 @@ def __str__(self) -> str:
507507
return self.state
508508

509509

510-
class AggregatedCheckRuns(base.AbstractGitHostObject):
510+
class AggregatedCheckRuns(base.AbstractGitHostObject,
511+
base.AbstractBuildStatus):
512+
511513
"""
512514
The Endpoint to have access infos about github actions runs
513515
"""
514516
GET_URL = '/repos/{owner}/{repo}/commits/{ref}/check-runs'
515517
SCHEMA = schema.AggregateCheckRuns
516518

517-
@property
518-
def html_url(self):
519-
if self.data['total_count']:
520-
return self.data['check_runs'][0]['html_url']
521-
return ''
522-
523-
524-
class AggregatedCheckSuites(base.AbstractGitHostObject,
525-
base.AbstractBuildStatus):
526-
"""
527-
The Endpoint to have access infos about github actions suites
528-
"""
529-
GET_URL = '/repos/{owner}/{repo}/commits/{ref}/check-suites'
530-
SCHEMA = schema.AggregateCheckSuites
531-
532519
def __init__(self, *args, **kwargs):
533520
super().__init__(*args, **kwargs)
534-
self._check_suites = [elem for elem in self.data['check_suites']]
535-
536-
@classmethod
537-
def get(cls, client, url=None, params={}, headers={}, **kwargs):
538-
res = super(AggregatedCheckSuites, cls)\
539-
.get(client, url, params, headers, **kwargs)
540-
541-
html_url = AggregatedCheckRuns\
542-
.get(client, url, params, headers, **kwargs).html_url
543-
res.data['html_url'] = html_url
544-
return res
521+
self._check_runs = [elem for elem in self.data['check_runs']]
545522

546523
@property
547524
def url(self):
548-
return self.data['html_url']
525+
if len(self.data['check_runs']):
526+
return self.data['check_runs'][0]['html_url']
527+
return ''
549528

550529
@property
551530
def state(self):
552531
queued = any(
553-
elem['status'] == 'queued' for elem in self._check_suites
532+
elem['status'] == 'queued' for elem in self._check_runs
554533
)
555534
all_complete = all(
556-
elem['status'] == 'completed' for elem in self._check_suites
535+
elem['status'] == 'completed' for elem in self._check_runs
557536
)
558537
all_success = all(
559-
elem['conclusion'] == 'success' for elem in self._check_suites
538+
elem['conclusion'] == 'success' for elem in self._check_runs
560539
)
561-
if self._check_suites.__len__() > 0 and queued:
540+
if self._check_runs.__len__() > 0 and queued:
562541
return 'NOTSTARTED'
563-
elif self._check_suites.__len__() > 0 and not all_complete:
542+
elif self._check_runs.__len__() > 0 and not all_complete:
564543
return 'INPROGRESS'
565-
elif self._check_suites.__len__() > 0 and all_complete and all_success:
544+
elif self._check_runs.__len__() > 0 and all_complete and all_success:
566545
return 'SUCCESSFUL'
567546
else:
568547
return 'FAILED'
@@ -577,8 +556,8 @@ def key(self) -> str:
577556

578557
@property
579558
def commit(self):
580-
if self._check_suites.__len__() > 0:
581-
return self._check_suites[0]["head_sha"]
559+
if self._check_runs.__len__() > 0:
560+
return self._check_runs[0]["head_sha"]
582561
else:
583562
return None
584563

bert_e/git_host/github/schema.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,6 @@ class Branch(Schema):
7878
repo = fields.Nested(Repo)
7979

8080

81-
class CheckSuites(Schema):
82-
id = fields.Integer()
83-
head_sha = fields.Str()
84-
status = fields.Str()
85-
conclusion = fields.Str(allow_none=True)
86-
87-
88-
class AggregateCheckSuites(Schema):
89-
total_count = fields.Integer()
90-
check_suites = fields.Nested(CheckSuites, many=True)
91-
92-
9381
class CheckRuns(Schema):
9482
id = fields.Integer()
9583
head_sha = fields.Str()

0 commit comments

Comments
 (0)