Skip to content

Commit

Permalink
Merge pull request #8 from majamassarini/main
Browse files Browse the repository at this point in the history
Fix failing checks and improve resilience
  • Loading branch information
majamassarini authored Feb 13, 2024
2 parents 7bb33e9 + 99e6e91 commit 26521b2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
23 changes: 14 additions & 9 deletions src/validation/testcase/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ def run_test(self):
opening PR close it.
:return:
"""
self.run_checks()
if self.failure_msg:
message = f"{self.pr.title} ({self.pr.url}) failed: {self.failure_msg}"
try:
self.run_checks()
if self.failure_msg:
message = f"{self.pr.title} ({self.pr.url}) failed: {self.failure_msg}"

log_failure(message)
log_failure(message)

if self.trigger == Trigger.pr_opened:
self.pr.close()
self.pr_branch_ref.delete()
if self.trigger == Trigger.pr_opened:
self.pr.close()
self.pr_branch_ref.delete()
except Exception as e:
msg = f"Validation test {self.pr.title} ({self.pr.url}) failed: {e}"
logging.error(msg)

def trigger_build(self):
"""
Expand Down Expand Up @@ -210,9 +214,10 @@ def check_build_submitted(self):
self.deployment.copr_user,
self.copr_project_name,
)
except Exception:
except Exception as e:
# project does not exist yet
logging.info("Copr project doesn't exist yet")
msg = f"Copr project doesn't exist yet: {e}"
logging.warning(msg)
continue

if len(new_builds) >= old_build_len + 1:
Expand Down
2 changes: 1 addition & 1 deletion src/validation/testcase/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_status_name(self, status: CommitFlag) -> str:
return status.context

def construct_copr_project_name(self) -> str:
return f"gitlab.com-packit-service-hello-world-{self.pr.id}"
return f"{self.project.service.hostname}-{self.project.namespace}-hello-world-{self.pr.id}"

def create_file_in_new_branch(self, branch: str):
self.pr_branch_ref = self.project.gitlab_repo.branches.create(
Expand Down
17 changes: 14 additions & 3 deletions src/validation/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ class Tests:
test_case_kls: type

def run(self):
logging.info("Run testcases where the build is triggered by a ‹vm-image-build› comment")
prs_for_comment = [
pr for pr in self.project.get_pr_list() if pr.title.startswith("Test VM Image builds")
]
if prs_for_comment:
logging.info("Run testcases where the build is triggered by a ‹vm-image-build› comment")
else:
logging.warning(
"No testcases found where the build is triggered by a ‹vm-image-build› comment",
)
for pr in prs_for_comment:
self.test_case_kls(
project=self.project,
Expand All @@ -28,10 +33,13 @@ def run(self):
comment=DEPLOYMENT.pr_comment_vm_image_build,
).run_test()

logging.info("Run testcases where the build is triggered by a ‹build› comment")
prs_for_comment = [
pr for pr in self.project.get_pr_list() if pr.title.startswith("Basic test case:")
]
if prs_for_comment:
logging.info("Run testcases where the build is triggered by a ‹build› comment")
else:
logging.warning("No testcases found where the build is triggered by a ‹build› comment")
for pr in prs_for_comment:
self.test_case_kls(
project=self.project,
Expand All @@ -40,12 +48,15 @@ def run(self):
deployment=DEPLOYMENT,
).run_test()

logging.info("Run testcase where the build is triggered by push")
pr_for_push = [
pr
for pr in self.project.get_pr_list()
if pr.title.startswith(DEPLOYMENT.push_trigger_tests_prefix)
]
if pr_for_push:
logging.info("Run testcase where the build is triggered by push")
else:
logging.warning("No testcase found where the build is triggered by push")
if pr_for_push:
self.test_case_kls(
project=self.project,
Expand Down

0 comments on commit 26521b2

Please sign in to comment.