From a8135c6599dcdf197908567af32bce6233fe70a8 Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Mon, 18 Nov 2024 15:04:12 +0100 Subject: [PATCH 1/2] rpmbuild: skip only if all macros in ExclusiveArch and ExcludeArch evaluated Fix #3244 --- rpmbuild/copr_rpmbuild/helpers.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rpmbuild/copr_rpmbuild/helpers.py b/rpmbuild/copr_rpmbuild/helpers.py index d102765ca..193b4bff6 100644 --- a/rpmbuild/copr_rpmbuild/helpers.py +++ b/rpmbuild/copr_rpmbuild/helpers.py @@ -428,14 +428,24 @@ def exclusivearch(self): """ Evaluated %{exclusivearch} as a list """ - return self.safe_attr("exclusivearch").split() + values = self.safe_attr("exclusivearch").split() + unknown = " ".join([x for x in values if x.startswith("%")]) + if unknown: + log.warning("Unknown macros in ExclusiveArch: %s", unknown) + return [] + return values @property def excludearch(self): """ Evaluated %{excludearch} as a list """ - return self.safe_attr("excludearch").split() + values = self.safe_attr("excludearch").split() + unknown = " ".join([x for x in values if x.startswith("%")]) + if unknown: + log.warning("Unknown macros in ExcludeArch: %s", unknown) + return [] + return values def safe_attr(self, name): """ From 6a36af7a8f9161f94c4d52b083808b5030c0360c Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Mon, 18 Nov 2024 15:05:29 +0100 Subject: [PATCH 2/2] frontend: test chroot skipping --- .../tests/test_logic/test_builds_logic.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/frontend/coprs_frontend/tests/test_logic/test_builds_logic.py b/frontend/coprs_frontend/tests/test_logic/test_builds_logic.py index faf46529d..76219418c 100644 --- a/frontend/coprs_frontend/tests/test_logic/test_builds_logic.py +++ b/frontend/coprs_frontend/tests/test_logic/test_builds_logic.py @@ -655,3 +655,43 @@ def save_field(_field, file_path): build = models.Build.query.get(1) assert build.source_state == "succeeded" assert not os.path.exists(storage) + + @pytest.mark.parametrize( + "exclusivearch,states", [ + (["x86_64", "i386"], ["waiting", "waiting"]), + (["x86_64"], ["waiting", "skipped"]), + ([], ["waiting", "waiting"]), + ] + ) + @pytest.mark.usefixtures( + "f_users", "f_coprs", "f_builds", "f_mock_chroots", "f_db") + def test_skipping_chroots(self, exclusivearch, states): + build = BuildsLogic.add(self.u2, "foo", self.c2) + self.db.session.commit() + assert len(build.chroots) == 0 + data = { + "builds": [{ + "id": 5, + "task_id": 5, + "srpm_url": "http://foo", + "status": 1, + "pkg_name": "foo", + "pkg_version": 1, + "chroot": "srpm-builds", + "results": { + "epoch": None, + "excludearch": [], + "exclusivearch": exclusivearch, + "name": "biosdevname", + "release": "17", + "version": "0.7.3" + }, + }] + } + response = self.tc.post( + "/backend/update/", + headers=self.auth_header, + json=data, + ) + assert response.status_code == 200 + assert [x.state for x in build.build_chroots] == states