Skip to content

Commit

Permalink
rpmbuild: rename fedora-review results even if the command fails
Browse files Browse the repository at this point in the history
Fix FrostyX/fedora-review-service#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.
  • Loading branch information
FrostyX committed Aug 7, 2023
1 parent 9d835f8 commit 9c6e396
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rpmbuild/copr_rpmbuild/automation/fedora_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -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:
Expand Down

0 comments on commit 9c6e396

Please sign in to comment.