Skip to content

Commit 7db5cb6

Browse files
committed
Add support for RHEL8 install test
1 parent f106157 commit 7db5cb6

7 files changed

Lines changed: 109 additions & 15 deletions

.github/workflows/multi_arch_ci_linux.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,23 @@ jobs:
200200
contents: read
201201
id-token: write
202202

203+
test_native_packages_rhel8:
204+
needs: [build_native_rpm_packages]
205+
name: Test RPM Install - rhel8
206+
if: ${{ !failure() && !cancelled() && fromJSON(inputs.build_config).build_native_linux == true }}
207+
uses: ./.github/workflows/test_native_linux_packages_install.yml
208+
with:
209+
package_install_url: ${{ needs.build_native_rpm_packages.outputs.package_repository_url }}
210+
release_type: ci
211+
os_profile: rhel8
212+
artifact_group: ${{ fromJSON(inputs.build_config).dist_amdgpu_families }}
213+
test_type: sanity
214+
repository: ${{ inputs.repository }}
215+
ref: ${{ inputs.ref }}
216+
permissions:
217+
contents: read
218+
id-token: write
219+
203220
test_native_packages_rhel10:
204221
needs: [build_native_rpm_packages]
205222
name: Test RPM Install - rhel10

.github/workflows/multi_arch_release_linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ jobs:
213213
strategy:
214214
fail-fast: false
215215
matrix:
216-
os_profile: [ubuntu2404, rhel10, sles16]
216+
os_profile: [ubuntu2404, rhel8, rhel10, sles16]
217217
steps:
218218
- name: Trigger test_native_linux_packages_install
219219
uses: benc-uk/workflow-dispatch@31e2b3319479a63f0ab15bf800eff9e913504e26 # v1.3.2

.github/workflows/test_native_linux_packages_install.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
type: string
2121
default: ""
2222
os_profile:
23-
description: OS profile (e.g., ubuntu2404, rhel10, sles16). Package type (deb/rpm) is derived from this.
23+
description: OS profile (e.g., ubuntu2404, rhel8, rhel10, sles16). Package type (deb/rpm) is derived from this.
2424
required: true
2525
type: string
2626
artifact_group:
@@ -69,6 +69,7 @@ on:
6969
type: choice
7070
options:
7171
- ubuntu2404
72+
- rhel8
7273
- rhel10
7374
- sles16
7475
artifact_group:
@@ -176,7 +177,7 @@ jobs:
176177
zypper install -y pciutils kmod
177178
fi
178179
else
179-
# rpm (non-SLES on UBI 10); --allowerasing for curl vs curl-minimal on UBI
180+
# rpm (non-SLES on RHEL/UBI); --allowerasing for curl vs curl-minimal on UBI
180181
dnf install -y --allowerasing \
181182
wget \
182183
curl \
@@ -197,8 +198,13 @@ jobs:
197198

198199
- name: Setup Python and install runtime
199200
run: |
201+
PY_EXTRA=()
202+
if [ "${{ inputs.os_profile }}" = "rhel8" ]; then
203+
PY_EXTRA=(--python-version 3.12)
204+
fi
200205
bash build_tools/packaging/linux/setup_python_cmd.sh \
201206
--os-profile "${{ inputs.os_profile }}" \
207+
"${PY_EXTRA[@]}" \
202208
--install-runtime \
203209
--output-format github
204210

build_tools/packaging/linux/get_url_repo_params.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,19 @@ def cmd_extract_gfx_arch(args: argparse.Namespace) -> int:
222222

223223
# --- get-container-image ---
224224

225-
# Maps OS profile prefixes to container images (checked in order).
225+
# Maps OS profile prefixes to container images (checked in order; first match wins).
226+
# Single-profile entries (e.g. "rhel8") require an exact match so "rhel10" does not
227+
# match the "rhel8" prefix via startswith.
226228
_OS_PROFILE_TO_IMAGE: list[tuple[tuple[str, ...], str]] = [
227229
(("sles",), "registry.suse.com/bci/bci-base:16.0"),
228230
(("ubuntu", "debian"), "ghcr.io/rocm/no_rocm_image_ubuntu24_04:latest"),
229-
((), "registry.access.redhat.com/ubi10/ubi:10.1"), # default (e.g. rhel*)
231+
(("rhel8",), "registry.access.redhat.com/ubi8/ubi:8.10"),
232+
((), "registry.access.redhat.com/ubi10/ubi:10.1"), # default (e.g. rhel10)
230233
]
231234

235+
# Single-prefix entries that must match the full profile (not startswith).
236+
_EXACT_PROFILE_PREFIXES = frozenset({"rhel8"})
237+
232238

233239
def get_container_image(os_profile: str) -> str:
234240
"""Return the container image for a given OS profile.
@@ -237,10 +243,18 @@ def get_container_image(os_profile: str) -> str:
237243
ubuntu2404 -> ghcr.io/rocm/no_rocm_image_ubuntu24_04:latest
238244
debian12 -> ghcr.io/rocm/no_rocm_image_ubuntu24_04:latest
239245
sles16 -> registry.suse.com/bci/bci-base:16.0
246+
rhel8 -> registry.access.redhat.com/ubi8/ubi:8.10
240247
rhel10 -> registry.access.redhat.com/ubi10/ubi:10.1
241248
"""
249+
profile = os_profile.lower()
242250
for prefixes, image in _OS_PROFILE_TO_IMAGE:
243-
if not prefixes or any(os_profile.startswith(p) for p in prefixes):
251+
if not prefixes:
252+
return image
253+
if len(prefixes) == 1 and prefixes[0] in _EXACT_PROFILE_PREFIXES:
254+
if profile == prefixes[0]:
255+
return image
256+
continue
257+
if any(profile.startswith(p) for p in prefixes):
244258
return image
245259
return _OS_PROFILE_TO_IMAGE[-1][1] # unreachable but satisfies type checker
246260

build_tools/packaging/linux/native_linux_package_install_test.py

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
--release-type prerelease \\
7373
--gpg-key-url https://rocm.prereleases.amd.com/packages/gpg/rocm.gpg
7474
75-
# Nightly RPM (RHEL 8) - run inside rhel8/almalinux container or VM
75+
# Nightly RPM (RHEL 8) - run inside a rhel8/UBI 8 container or VM
7676
python3 native_linux_package_install_test.py \\
7777
--os-profile rhel8 \\
7878
--repo-url https://rocm.nightlies.amd.com/rpm/20260204-21658678136/x86_64/ \\
@@ -184,6 +184,7 @@ def _env(key: str, default: str) -> str:
184184
ZYPP_CLEAN_TIMEOUT_SEC = 60
185185
ZYPP_REFRESH_TIMEOUT_SEC = 120
186186
DNF_CLEAN_TIMEOUT_SEC = 60
187+
DNF_MAKECACHE_TIMEOUT_SEC = 120
187188
INSTALL_TIMEOUT_SEC = 1800 # 30 minutes
188189
ROCMINFO_TIMEOUT_SEC = 30
189190
RDHC_TIMEOUT_SEC = 30
@@ -292,6 +293,11 @@ def _run_streaming(cmd: list[str], timeout_sec: int) -> int:
292293
raise
293294

294295

296+
def _is_rhel8_profile(os_profile: str) -> bool:
297+
"""True only for the ``rhel8`` OS profile (not other EL8/RHEL-like names)."""
298+
return os_profile.lower() == "rhel8"
299+
300+
295301
class NativeLinuxPackageInstallTest:
296302
"""Runner for the native Linux package install test (repo setup, install, verification)."""
297303

@@ -353,6 +359,10 @@ def _is_sles(self) -> bool:
353359
"""
354360
return self.os_profile.lower().startswith("sles")
355361

362+
def _is_rhel8(self) -> bool:
363+
"""Check if the OS profile is ``rhel8``."""
364+
return _is_rhel8_profile(self.os_profile)
365+
356366
def __init__(
357367
self,
358368
repo_url: str,
@@ -707,8 +717,25 @@ def _setup_dnf_repository(self) -> bool:
707717
except subprocess.TimeoutExpired:
708718
print("[WARN] dnf clean timed out (may not be critical)")
709719

710-
print("\n[PASS] DNF repository setup complete")
711-
return True
720+
# Refresh metadata (required on EL8 before first ``dnf install`` from a new .repo)
721+
print(f"\nRefreshing repository metadata (dnf makecache --repo={repo_name})...")
722+
try:
723+
makecache_cmd = ["dnf", "makecache", f"--repo={repo_name}"]
724+
return_code = _run_streaming(makecache_cmd, DNF_MAKECACHE_TIMEOUT_SEC)
725+
if return_code == 0:
726+
print("\n[PASS] DNF repository metadata refreshed")
727+
return True
728+
print(
729+
f"\n[FAIL] dnf makecache failed for repo '{repo_name}' "
730+
f"(exit code: {return_code})"
731+
)
732+
return False
733+
except subprocess.TimeoutExpired:
734+
print("\n[FAIL] dnf makecache timed out")
735+
return False
736+
except OSError as e:
737+
print(f"\n[FAIL] Error refreshing DNF repository metadata: {e}")
738+
return False
712739

713740
def setup_rpm_repository(self) -> bool:
714741
"""Setup RPM repository on the system.
@@ -805,7 +832,11 @@ def install_rpm_packages(self) -> bool:
805832
] + self.package_names
806833
print("[INFO] Using zypper for SLES package installation")
807834
else:
808-
cmd = ["dnf", "install", "-y"] + self.package_names
835+
dnf_args = ["dnf", "install", "-y"]
836+
if self._is_rhel8():
837+
# rhel8 only: EL8 repos occasionally need --nobest for ROCm deps.
838+
dnf_args.append("--nobest")
839+
cmd = dnf_args + self.package_names
809840
print(f"\nRunning: {' '.join(cmd)}")
810841
print("=" * 80)
811842
print("Installation progress (streaming output):\n")
@@ -1057,6 +1088,11 @@ def test_rdhc(self) -> bool:
10571088
--repo-url https://rocm.nightlies.amd.com/rpm/20260204-21658678136/rhel8/x86_64/ \\
10581089
--gfx-arch gfx94x --release-type nightly --install-prefix /opt/rocm/core
10591090
1091+
# --test-type full on RHEL 8 (rdhc needs pciutils/kmod on the host — install before running)
1092+
python native_linux_package_install_test.py --test-type full --os-profile rhel8 \\
1093+
--repo-url https://rocm.nightlies.amd.com/rpm/20260204-21658678136/rhel8/x86_64/ \\
1094+
--gfx-arch gfx94x --release-type nightly --install-prefix /opt/rocm/core
1095+
10601096
# Prerelease RPM (RHEL 8)
10611097
python native_linux_package_install_test.py --os-profile rhel8 \\
10621098
--repo-url https://rocm.prereleases.amd.com/packages/rhel8/x86_64/ \\

build_tools/packaging/linux/tests/get_url_repo_params_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,12 @@ def test_sles_returns_bci_image(self):
499499
"registry.suse.com/bci/bci-base:16.0",
500500
)
501501

502+
def test_rhel8_returns_ubi8_image(self):
503+
self.assertEqual(
504+
get_url_repo_params.get_container_image("rhel8"),
505+
"registry.access.redhat.com/ubi8/ubi:8.10",
506+
)
507+
502508
def test_rhel_returns_ubi_image(self):
503509
self.assertEqual(
504510
get_url_repo_params.get_container_image("rhel10"),

build_tools/packaging/linux/tests/native_linux_package_install_ut_test.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,12 +1241,12 @@ def test_returns_true_when_refresh_succeeds(
12411241
class SetupDnfRepositoryTest(unittest.TestCase):
12421242
"""Tests for NativeLinuxPackageInstallTest._setup_dnf_repository()."""
12431243

1244-
@patch("native_linux_package_install_test.subprocess.run")
1244+
@patch("native_linux_package_install_test._run_streaming", return_value=0)
12451245
@patch("native_linux_package_install_test.Path.write_text")
1246-
def test_returns_true_after_writing_repo_file(self, mock_write_text, mock_run):
1247-
# Test that _setup_dnf_repository writes repo file and returns True (dnf clean may be mocked).
1248-
# Uses Path.write_text, not open().
1249-
mock_run.side_effect = None
1246+
@patch("native_linux_package_install_test.subprocess.run")
1247+
def test_returns_true_after_writing_repo_file_and_makecache(
1248+
self, mock_run, mock_write_text, mock_streaming
1249+
):
12501250
mock_run.return_value = MagicMock(returncode=0)
12511251
t = native_linux_package_install_test.NativeLinuxPackageInstallTest(
12521252
repo_url="https://repo.example.com",
@@ -1256,6 +1256,8 @@ def test_returns_true_after_writing_repo_file(self, mock_write_text, mock_run):
12561256
self.assertTrue(t._setup_dnf_repository())
12571257
written = mock_write_text.call_args[0][0]
12581258
self.assertIn("baseurl=https://repo.example.com", written)
1259+
makecache_cmd = mock_streaming.call_args[0][0]
1260+
self.assertIn("makecache", makecache_cmd)
12591261

12601262

12611263
class SetupRpmRepositoryTest(unittest.TestCase):
@@ -1367,6 +1369,19 @@ def test_returns_true_when_dnf_install_succeeds(self, mock_streaming):
13671369
self.assertTrue(t.install_rpm_packages())
13681370
call_args = mock_streaming.call_args[0][0]
13691371
self.assertEqual(call_args[0], "dnf")
1372+
self.assertIn("--nobest", call_args)
1373+
1374+
@patch("native_linux_package_install_test._run_streaming")
1375+
def test_rhel10_dnf_install_without_nobest(self, mock_streaming):
1376+
mock_streaming.return_value = 0
1377+
t = native_linux_package_install_test.NativeLinuxPackageInstallTest(
1378+
repo_url="https://example.com",
1379+
os_profile="rhel10",
1380+
gfx_arch="gfx94x",
1381+
)
1382+
self.assertTrue(t.install_rpm_packages())
1383+
call_args = mock_streaming.call_args[0][0]
1384+
self.assertNotIn("--nobest", call_args)
13701385

13711386
@patch("native_linux_package_install_test._run_streaming")
13721387
def test_returns_true_when_zypper_install_succeeds(self, mock_streaming):

0 commit comments

Comments
 (0)