Skip to content

Commit 91db33e

Browse files
committed
se "higher stream" rather than Y-Stream
For EUS branches the base release number comes from the higher Z-Stream, not Y-Stream. Even though the code works with EUS branches just fine, variables and functions still reference Y-Stream which is not accurate. Signed-off-by: Nikola Forró <[email protected]>
1 parent dbce0ac commit 91db33e

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

agents/tests/unit/test_tools.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,22 +137,17 @@ def autorelease_spec(tmp_path):
137137
[False, True],
138138
)
139139
@pytest.mark.parametrize(
140-
"dist_git_branch, ystream_dist",
141-
[
142-
("c9s", ".el9"),
143-
("c10s", ".el10"),
144-
("rhel-9.6.0", ".el9"),
145-
("rhel-10.0", ".el10"),
146-
],
140+
"dist_git_branch",
141+
["c9s", "c10s", "rhel-9.6.0", "rhel-10.0"],
147142
)
148143
@pytest.mark.asyncio
149-
async def test_update_release(rebase, dist_git_branch, ystream_dist, minimal_spec, autorelease_spec):
144+
async def test_update_release(rebase, dist_git_branch, minimal_spec, autorelease_spec):
150145
package = "test"
151146

152-
async def _get_latest_ystream_build(*_, **__):
153-
return EVR(version="0.1", release="2" + ystream_dist)
147+
async def _get_latest_higher_stream_build(*_, **__):
148+
return EVR(version="0.1", release="2.elX")
154149

155-
flexmock(UpdateReleaseTool).should_receive("_get_latest_ystream_build").replace_with(_get_latest_ystream_build)
150+
flexmock(UpdateReleaseTool).should_receive("_get_latest_higher_stream_build").replace_with(_get_latest_higher_stream_build)
156151

157152
tool = UpdateReleaseTool()
158153

agents/tools/specfile.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@ def _process_zstream_branch(dist_git_branch: str) -> tuple[str, str] | None:
8181
if not (m := re.match(r"^(?P<prefix>rhel-(?P<x>\d+)\.)(?P<y>\d+)(?P<suffix>\.\d+)?$", dist_git_branch)):
8282
# not a Z-Stream branch
8383
return None
84-
ystream_candidate_tag = (
84+
higher_stream_candidate_tag = (
8585
m.group("prefix")
8686
# y++, up to 10 (highest RHEL minor version)
8787
+ str(min(int(m.group("y")) + 1, 10))
8888
+ (m.group("suffix") or "")
8989
+ "-candidate"
9090
)
91-
return ystream_candidate_tag
91+
return higher_stream_candidate_tag
9292

9393
@staticmethod
94-
async def _get_latest_ystream_build(package: str, candidate_tag: str) -> EVR:
94+
async def _get_latest_higher_stream_build(package: str, candidate_tag: str) -> EVR:
9595
builds = await asyncio.to_thread(
9696
koji.ClientSession(BREWHUB_URL).listTagged,
9797
package=package,
@@ -101,7 +101,7 @@ async def _get_latest_ystream_build(package: str, candidate_tag: str) -> EVR:
101101
strict=True,
102102
)
103103
if not builds:
104-
raise RuntimeError(f"There are no Y-Stream builds of {package} in {candidate_tag}")
104+
raise RuntimeError(f"There are no builds of {package} in {candidate_tag}")
105105
[build] = builds
106106
return EVR(epoch=build["epoch"] or 0, version=build["version"], release=build["release"])
107107

@@ -119,11 +119,10 @@ async def _set_zstream_release(
119119
spec_path: Path,
120120
package: str,
121121
rebase: bool,
122-
ystream_candidate_tag: str,
122+
higher_stream_candidate_tag: str,
123123
) -> None:
124-
latest_ystream_build = await cls._get_latest_ystream_build(package, ystream_candidate_tag)
125-
ystream_base_release, suffix = latest_ystream_build.release.rsplit(".el", maxsplit=1)
126-
ystream_release_suffix = f".el{suffix}"
124+
latest_higher_stream_build = await cls._get_latest_higher_stream_build(package, higher_stream_candidate_tag)
125+
higher_stream_base_release, _ = latest_higher_stream_build.release.rsplit(".el", maxsplit=1)
127126
with Specfile(spec_path) as spec:
128127
current_release = spec.raw_release
129128
nodes = list(ValueParser.flatten(ValueParser.parse(current_release)))
@@ -147,8 +146,8 @@ def find_macro(name):
147146
# %autorelease after %dist, most likely already a Z-Stream release, no change needed
148147
release = current_release
149148
else:
150-
# no %dist or %autorelease before it, let's create a new release based on Y-Stream
151-
release = ystream_base_release + "%{?dist}.%{autorelease -n}"
149+
# no %dist or %autorelease before it, let's create a new release based on the higher stream
150+
release = higher_stream_base_release + "%{?dist}.%{autorelease -n}"
152151
else:
153152
if rebase:
154153
# no %autorelease, rebase, reset the release
@@ -163,8 +162,8 @@ def find_macro(name):
163162
# no %autorelease and existing Z-Stream counter after %dist, increase it
164163
release = prefix + "." + str(int(m.group(1)) + 1)
165164
else:
166-
# invalid Z-Stream counter, let's try to create a new release based on Y-Stream
167-
release = ystream_base_release + "%{?dist}.1"
165+
# invalid Z-Stream counter, let's try to create a new release based on the higher stream
166+
release = higher_stream_base_release + "%{?dist}.1"
168167
else:
169168
# no %autorelease, %dist present, add Z-Stream counter
170169
release = current_release + ".1"
@@ -180,10 +179,15 @@ async def _run(
180179
) -> StringToolOutput:
181180
spec_path = get_absolute_path(tool_input.spec, self)
182181
try:
183-
if not (ystream_candidate_tag := self._process_zstream_branch(tool_input.dist_git_branch)):
182+
if not (higher_stream_candidate_tag := self._process_zstream_branch(tool_input.dist_git_branch)):
184183
await self._bump_or_reset_release(spec_path, tool_input.rebase)
185184
else:
186-
await self._set_zstream_release(spec_path, tool_input.package, tool_input.rebase, ystream_candidate_tag)
185+
await self._set_zstream_release(
186+
spec_path,
187+
tool_input.package,
188+
tool_input.rebase,
189+
higher_stream_candidate_tag,
190+
)
187191
except Exception as e:
188192
raise ToolError(f"Failed to update release: {e}") from e
189193
return StringToolOutput(result=f"Successfully updated release in {spec_path}")

0 commit comments

Comments
 (0)