Skip to content

Commit

Permalink
[BERTE-560] Allways get the latest check-runs link
Browse files Browse the repository at this point in the history
  • Loading branch information
erwan-b committed Jan 7, 2022
1 parent 598c44b commit 0777b80
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 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.8] - 2021-11-09
# Fixed
- Allways get the latest check-runs link status

## [3.6.7] - 2021-11-09
# Changed
- Allow jira issue keys to be lowercase
Expand Down
16 changes: 14 additions & 2 deletions bert_e/git_host/github/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
import json
import logging
from datetime import datetime
from collections import defaultdict, namedtuple

from requests import HTTPError
Expand Down Expand Up @@ -509,7 +510,6 @@ def __str__(self) -> str:

class AggregatedCheckRuns(base.AbstractGitHostObject,
base.AbstractBuildStatus):

"""
The Endpoint to have access infos about github actions runs
"""
Expand All @@ -522,7 +522,19 @@ def __init__(self, *args, **kwargs):

@property
def url(self):
if len(self.data['check_runs']):
def sort_f(check_run):
date = check_run.get('started_at')
if date:
return datetime.strptime(date, '%Y-%m-%dT%H:%M:%SZ')
return datetime(year=1962, month=1, day=1)

self.data['check_runs'].sort(key=sort_f, reverse=True)

failed_c = [elem for elem in self.data['check_runs']
if elem['conclusion'] != 'success']
if len(failed_c):
return failed_c[0]['html_url']
elif len(failed_c) and len(self.data['check_runs']):
return self.data['check_runs'][0]['html_url']
return ''

Expand Down

0 comments on commit 0777b80

Please sign in to comment.