From d76cb0839eaa706da0aa71c045ea19d11ebafae4 Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Tue, 8 Aug 2023 00:59:43 +0200 Subject: [PATCH] rpmbuild: rename fedora-review results even if the command fails Fix https://github.com/FrostyX/fedora-review-service/issues/28 Fix https://pagure.io/FedoraReview/issue/486 There is no fedora-review parameter for specifying the output directory. As a work-around we are renaming its results directory to "fedora-review" after the command finishes. However, our error handling is wrong and if the `fedora-review` command fails, the rename doesn't happend. Therefore, broken links. This commit fixes it. --- rpmbuild/copr_rpmbuild/automation/fedora_review.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rpmbuild/copr_rpmbuild/automation/fedora_review.py b/rpmbuild/copr_rpmbuild/automation/fedora_review.py index 8042e1b9b..0d9dd91ee 100644 --- a/rpmbuild/copr_rpmbuild/automation/fedora_review.py +++ b/rpmbuild/copr_rpmbuild/automation/fedora_review.py @@ -48,11 +48,11 @@ def run(self): try: result = run_cmd(cmd, cwd=self.resultdir) self.log.info(result.stdout) - self._filter_results_directory() except RuntimeError as ex: self.log.warning("Fedora review failed\nerr:\n%s", ex) self.log.warning("The build itself will not be marked " "as failed because of this") + self._filter_results_directory() def _filter_results_directory(self): """ @@ -66,6 +66,13 @@ def _filter_results_directory(self): srcdir = os.path.join(self.resultdir, self.package_name) dstdir = os.path.join(self.resultdir, "fedora-review") os.makedirs(dstdir, exist_ok=True) + + # The fedora-review command failed so early that it didn't even create + # the resultdir. Nothing to do here. + if not os.path.exists(srcdir): + self.log.error("Can't find fedora-review results: %s", srcdir) + return + results = ["review.txt", "licensecheck.txt", "rpmlint.txt", "files.dir"] for result in results: try: