Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Ruth Netser <[email protected]>
Co-authored-by: Miles Dunn <[email protected]>
  • Loading branch information
3 people committed Jan 22, 2024
1 parent a384f04 commit b1a80b6
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 269 deletions.
1 change: 1 addition & 0 deletions cli/objects/failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(
failure_type (str): The failure type
failed_test_name (Optional[str], optional): The failed test name. Defaults to None.
failed_test_junit_path (Optional[str], optional): The path to the failed test's junit file. Defaults to None.
ignore (bool): Flag to indicate that the failure should be ignored.
"""
self.logger = get_logger(__name__)

Expand Down
13 changes: 4 additions & 9 deletions cli/objects/failure_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,9 @@ def _get_ignore(self, rule_dict: dict[Any, Any]) -> bool:
)
exit(1)

def matches_failure(self, failure: "Failure") -> bool:
if (
def matches_failure(self, failure: Failure) -> bool:
return (
hasattr(self, "step")
and fnmatch.fnmatch(failure.step, self.step)
and (
(failure.failure_type == self.failure_type)
or self.failure_type == "all"
)
):
return True
return False
and failure.failure_type in (self.failure_type, "all")
)
12 changes: 5 additions & 7 deletions cli/objects/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import itertools
import json
import os
from typing import Any
Expand Down Expand Up @@ -324,13 +323,12 @@ def _find_failures(self, logs_dir: str, junit_dir: str) -> Optional[list[Failure
unique_steps_with_failures = set()

# Combine lists into one list
for failure in itertools.chain(test_failures, pod_failures):
for failure in test_failures + pod_failures:
if failure.step not in unique_steps_with_failures:
unique_steps_with_failures.update([failure.step])
if self.firewatch_config.failure_rules:
for rule in self.firewatch_config.failure_rules:
if rule.matches_failure(failure) and rule.ignore:
failure.ignore = True
unique_steps_with_failures.add(failure.step)
if failure_rules := self.firewatch_config.failure_rules:
for rule in failure_rules:
failure.ignore = rule.matches_failure(failure) and rule.ignore
failures_list.append(failure)

if len(failures_list) > 0:
Expand Down
Loading

0 comments on commit b1a80b6

Please sign in to comment.