Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip only if all macros in ExclusiveArch and ExcludeArch evaluated #3513

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions frontend/coprs_frontend/tests/test_logic/test_builds_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 12 additions & 2 deletions rpmbuild/copr_rpmbuild/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not complaining, just curious ... When we are doing this already, why do we have to report back to backend && frontend useless set of macros (some unexpanded)? Wouldn't it be better to return just empty list?

Copy link
Member Author

@FrostyX FrostyX Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, PTAL


@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):
"""
Expand Down