This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git
The following commit(s) were added to refs/heads/main by this push:
new cc7edff Take check ignores into account on compose pages
cc7edff is described below
commit cc7edff23a98096955e4507bd2019db81874eb48
Author: Sean B. Palmer <[email protected]>
AuthorDate: Wed Jul 30 15:08:05 2025 +0100
Take check ignores into account on compose pages
---
atr/storage/readers/checks.py | 38 ++++++++++++------------
atr/storage/readers/releases.py | 43 +++++++++++++++++++++-------
atr/storage/types.py | 8 ++++++
atr/templates/check-selected-path-table.html | 2 +-
4 files changed, 60 insertions(+), 31 deletions(-)
diff --git a/atr/storage/readers/checks.py b/atr/storage/readers/checks.py
index 3a158d9..fbe8ed3 100644
--- a/atr/storage/readers/checks.py
+++ b/atr/storage/readers/checks.py
@@ -63,7 +63,7 @@ class GeneralPublic:
# Filter out any results that are ignored
unignored_checks = []
ignored_checks = []
- match_ignore = await
self.__check_ignores_matcher(release.committee.name, self.__data)
+ match_ignore = await self.ignores_matcher(release.committee.name)
for cr in all_check_results:
if not match_ignore(cr):
unignored_checks.append(cr)
@@ -87,6 +87,23 @@ class GeneralPublic:
member_results_list[member_rel_path].sort(key=lambda r: r.checker)
return types.CheckResults(primary_results_list, member_results_list,
ignored_checks)
+ async def ignores_matcher(
+ self,
+ committee_name: str,
+ ) -> Callable[[sql.CheckResult], bool]:
+ ignores = await self.__data.check_result_ignore(
+ committee_name=committee_name,
+ ).all()
+
+ def match(cr: sql.CheckResult) -> bool:
+ for ignore in ignores:
+ if self.__check_ignore_match(cr, ignore):
+ # log.info(f"Ignoring check result {cr} due to ignore
{ignore}")
+ return True
+ return False
+
+ return match
+
def __check_ignore_match(self, cr: sql.CheckResult, cri:
sql.CheckResultIgnore) -> bool:
# Does not check that the committee name matches
if cr.status == sql.CheckResultStatus.SUCCESS:
@@ -125,22 +142,3 @@ class GeneralPublic:
# Should also handle ^ and $
# And maybe .replace(r"\?", ".?")
return re.match(pattern, value) is not None
-
- async def __check_ignores_matcher(
- self,
- committee_name: str,
- data: db.Session | None = None,
- ) -> Callable[[sql.CheckResult], bool]:
- async with db.ensure_session(data) as data:
- ignores = await data.check_result_ignore(
- committee_name=committee_name,
- ).all()
-
- def match(cr: sql.CheckResult) -> bool:
- for ignore in ignores:
- if self.__check_ignore_match(cr, ignore):
- # log.info(f"Ignoring check result {cr} due to ignore
{ignore}")
- return True
- return False
-
- return match
diff --git a/atr/storage/readers/releases.py b/atr/storage/readers/releases.py
index fff6e7a..b931cdd 100644
--- a/atr/storage/readers/releases.py
+++ b/atr/storage/readers/releases.py
@@ -60,33 +60,56 @@ class GeneralPublic:
async def __successes_errors_warnings(
self, release: sql.Release, latest_revision_number: str, info:
types.PathInfo
) -> None:
- # Get successes, warnings, and errors
+ if release.committee is None:
+ raise ValueError("Release has no committee")
+
+ match_ignore = await
self.__credentials.checks.ignores_matcher(release.committee.name)
+
+ cs = types.ChecksSubset(
+ release=release,
+ latest_revision_number=latest_revision_number,
+ info=info,
+ match_ignore=match_ignore,
+ )
+ await self.__successes(cs)
+ await self.__warnings(cs)
+ await self.__errors(cs)
+
+ async def __successes(self, cs: types.ChecksSubset) -> None:
successes = await self.__data.check_result(
- release_name=release.name,
- revision_number=latest_revision_number,
+ release_name=cs.release.name,
+ revision_number=cs.latest_revision_number,
member_rel_path=None,
status=sql.CheckResultStatus.SUCCESS,
).all()
for success in successes:
+ if cs.match_ignore(success):
+ continue
if primary_rel_path := success.primary_rel_path:
- info.successes.setdefault(pathlib.Path(primary_rel_path),
[]).append(success)
+ cs.info.successes.setdefault(pathlib.Path(primary_rel_path),
[]).append(success)
+ async def __warnings(self, cs: types.ChecksSubset) -> None:
warnings = await self.__data.check_result(
- release_name=release.name,
- revision_number=latest_revision_number,
+ release_name=cs.release.name,
+ revision_number=cs.latest_revision_number,
member_rel_path=None,
status=sql.CheckResultStatus.WARNING,
).all()
for warning in warnings:
+ if cs.match_ignore(warning):
+ continue
if primary_rel_path := warning.primary_rel_path:
- info.warnings.setdefault(pathlib.Path(primary_rel_path),
[]).append(warning)
+ cs.info.warnings.setdefault(pathlib.Path(primary_rel_path),
[]).append(warning)
+ async def __errors(self, cs: types.ChecksSubset) -> None:
errors = await self.__data.check_result(
- release_name=release.name,
- revision_number=latest_revision_number,
+ release_name=cs.release.name,
+ revision_number=cs.latest_revision_number,
member_rel_path=None,
status=sql.CheckResultStatus.FAILURE,
).all()
for error in errors:
+ if cs.match_ignore(error):
+ continue
if primary_rel_path := error.primary_rel_path:
- info.errors.setdefault(pathlib.Path(primary_rel_path),
[]).append(error)
+ cs.info.errors.setdefault(pathlib.Path(primary_rel_path),
[]).append(error)
diff --git a/atr/storage/types.py b/atr/storage/types.py
index ef05592..478addf 100644
--- a/atr/storage/types.py
+++ b/atr/storage/types.py
@@ -259,6 +259,14 @@ class PathInfo(schema.Strict):
warnings: dict[pathlib.Path, list[sql.CheckResult]] = schema.factory(dict)
[email protected]
+class ChecksSubset:
+ release: sql.Release
+ latest_revision_number: str
+ info: PathInfo
+ match_ignore: Callable[[sql.CheckResult], bool]
+
+
class PublicKeyError(Exception):
def __init__(self, key: Key, original_error: Exception):
self.__key = key
diff --git a/atr/templates/check-selected-path-table.html
b/atr/templates/check-selected-path-table.html
index 4e94786..fed8cc3 100644
--- a/atr/templates/check-selected-path-table.html
+++ b/atr/templates/check-selected-path-table.html
@@ -76,7 +76,7 @@
class="btn btn-sm btn-outline-success"
title="Show report for {{ path }}">Show report</a>
{% else %}
- <span class="btn btn-sm btn-outline-secondary disabled">No
checks run</span>
+ <span class="btn btn-sm btn-outline-secondary disabled">No
checks</span>
{% endif %}
{% if phase == "release_candidate_draft" %}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]