From 77a4efbe67b654ba1309c608b3079ff0dca7f33a Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Mon, 1 Apr 2024 01:19:56 +0200 Subject: [PATCH] Add icon to in_testing, tested_on, and failed_on labels --- snapshot_manager/snapshot_manager/config.py | 4 ++ .../snapshot_manager/github_util.py | 15 ++++-- .../snapshot_manager/snapshot_manager.py | 48 ++++++++++++++----- 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/snapshot_manager/snapshot_manager/config.py b/snapshot_manager/snapshot_manager/config.py index 2ca70602..08468fc2 100644 --- a/snapshot_manager/snapshot_manager/config.py +++ b/snapshot_manager/snapshot_manager/config.py @@ -62,6 +62,10 @@ class Config: test_repo_url: str = "https://github.com/fedora-llvm-team/llvm-snapshots" """TBD""" + label_prefix_in_testing: str = "in_testing/" + label_prefix_tested_on: str = "tested_on/" + label_prefix_failed_on: str = "failed_on/" + @property def copr_projectname(self) -> str: """Takes the copr_project_tpl and replaces the YYYYMMDD placeholder (if any) with a date. diff --git a/snapshot_manager/snapshot_manager/github_util.py b/snapshot_manager/snapshot_manager/github_util.py index 82d63cba..1835e85f 100644 --- a/snapshot_manager/snapshot_manager/github_util.py +++ b/snapshot_manager/snapshot_manager/github_util.py @@ -220,15 +220,24 @@ def create_labels_for_archs(self, labels: list[str], **kw_args): def create_labels_for_in_testing(self, labels: list[str], **kw_args): self._create_labels( - labels=labels, prefix="in_testing/", color="FEF2C0", *kw_args + labels=labels, + prefix=self.config.label_prefix_in_testing, + color="FEF2C0", + *kw_args, ) def create_labels_for_tested_on(self, labels: list[str], **kw_args): self._create_labels( - labels=labels, prefix="tested_on/", color="0E8A16", *kw_args + labels=labels, + prefix=self.config.label_prefix_tested_on, + color="0E8A16", + *kw_args, ) def create_labels_for_failed_on(self, labels: list[str], **kw_args): self._create_labels( - labels=labels, prefix="failed_on/", color="D93F0B", *kw_args + labels=labels, + prefix=self.config.label_prefix_failed_on, + color="D93F0B", + *kw_args, ) diff --git a/snapshot_manager/snapshot_manager/snapshot_manager.py b/snapshot_manager/snapshot_manager/snapshot_manager.py index 0309e37b..72cee63a 100755 --- a/snapshot_manager/snapshot_manager/snapshot_manager.py +++ b/snapshot_manager/snapshot_manager/snapshot_manager.py @@ -187,17 +187,37 @@ def check_todays_builds(self): tf.TestingFarmWatchResult.TESTS_ERROR, tf.TestingFarmWatchResult.TESTS_FAILED, ]: - if f"in_testing/{chroot}" in labels_on_issue: - issue.remove_from_labels(f"in_testing/{chroot}") - if f"tested_on/{chroot}" in labels_on_issue: - issue.remove_from_labels(f"tested_on/{chroot}") - issue.add_to_labels(f"failed_on/{chroot}") + if ( + f"{self.config.label_prefix_in_testing}{chroot}" + in labels_on_issue + ): + issue.remove_from_labels( + f"{self.config.label_prefix_in_testing}{chroot}" + ) + if ( + f"{self.config.label_prefix_tested_on}{chroot}" + in labels_on_issue + ): + issue.remove_from_labels( + f"{self.config.label_prefix_tested_on}{chroot}" + ) + issue.add_to_labels(f"{self.config.label_prefix_failed_on}{chroot}") elif watch_result == tf.TestingFarmWatchResult.TESTS_PASSED: - if f"in_testing/{chroot}" in labels_on_issue: - issue.remove_from_labels(f"in_testing/{chroot}") - if f"failed_on/{chroot}" in labels_on_issue: - issue.remove_from_labels(f"failed_on/{chroot}") - issue.add_to_labels(f"tested_on/{chroot}") + if ( + f"{self.config.label_prefix_in_testing}{chroot}" + in labels_on_issue + ): + issue.remove_from_labels( + f"{self.config.label_prefix_in_testing}{chroot}" + ) + if ( + f"{self.config.label_prefix_failed_on}{chroot}" + in labels_on_issue + ): + issue.remove_from_labels( + f"{self.config.label_prefix_failed_on}{chroot}" + ) + issue.add_to_labels(f"{self.config.label_prefix_tested_on}{chroot}") else: logging.info(f"Starting tests for chroot {chroot}") request_id = tf.make_testing_farm_request( @@ -207,7 +227,7 @@ def check_todays_builds(self): ) logging.info(f"Request ID: {request_id}") testing_farm_requests[chroot] = request_id - issue.add_to_labels(f"in_testing/{chroot}") + issue.add_to_labels(f"{self.config.label_prefix_in_testing}{chroot}") if len(failed_test_cases) > 0: testing_farm_comment_body = f""" @@ -244,10 +264,12 @@ def check_todays_builds(self): logging.info("Checking if issue can be closed") # issue.update() tested_chroot_labels = [ - label.name for label in issue.labels if label.name.startswith("tested_on/") + label.name + for label in issue.labels + if label.name.startswith("{self.config.label_prefix_tested_on}") ] required_chroot_abels = [ - "tested_on/{chroot}" + "{self.config.label_prefix_tested_on}{chroot}" for chroot in all_chroots if tf.is_chroot_supported(chroot) ]