diff --git a/CHANGELOG b/CHANGELOG index f407ac74..3d453268 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.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 diff --git a/bert_e/git_host/github/__init__.py b/bert_e/git_host/github/__init__.py index ee026cc6..be30f651 100644 --- a/bert_e/git_host/github/__init__.py +++ b/bert_e/git_host/github/__init__.py @@ -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 @@ -509,7 +510,6 @@ def __str__(self) -> str: class AggregatedCheckRuns(base.AbstractGitHostObject, base.AbstractBuildStatus): - """ The Endpoint to have access infos about github actions runs """ @@ -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 ''