| 1 |
name: AMDSMI CI |
| 2 |
|
| 3 |
on: |
| 4 |
pull_request: |
| 5 |
branches: [amd-staging, amd-mainline, release/rocm-rel-*] |
| 6 |
push: |
| 7 |
branches: [amd-staging, amd-mainline, release/rocm-rel-*] |
| 8 |
workflow_dispatch: |
| 9 |
|
| 10 |
permissions: |
| 11 |
contents: read |
| 12 |
env: |
| 13 |
DEBIAN_FRONTEND: noninteractive |
| 14 |
DEBCONF_NONINTERACTIVE_SEEN: true |
| 15 |
BUILD_TYPE: Release |
| 16 |
ROCM_DIR: /opt/rocm |
| 17 |
|
| 18 |
jobs: |
| 19 |
debian-buildinstall: |
| 20 |
name: Build |
| 21 |
runs-on: |
| 22 |
- self-hosted |
| 23 |
- ${{ vars.RUNNER_TYPE }} |
| 24 |
continue-on-error: true |
| 25 |
strategy: |
| 26 |
max-parallel: 10 |
| 27 |
matrix: |
| 28 |
os: [Ubuntu20, Ubuntu22, Debian10] |
| 29 |
container: |
| 30 |
image: ${{ vars[format('{0}_DOCKER_IMAGE', matrix.os)] }} |
| 31 |
options: --rm --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --shm-size=64G --cap-add=SYS_MODULE -v /lib/modules:/lib/modules |
| 32 |
|
| 33 |
steps: |
| 34 |
- uses: actions/checkout@v4 |
| 35 |
|
| 36 |
- name: Update repositories for Debian10 |
| 37 |
if: matrix.os == 'Debian10' |
| 38 |
run: | |
| 39 |
set -e |
| 40 |
echo 'Updating repositories for Debian10 (archived)' |
| 41 |
cat > /etc/apt/sources.list << EOF |
| 42 |
deb http://archive.debian.org/debian buster main |
| 43 |
deb http://archive.debian.org/debian-security buster/updates main |
| 44 |
EOF |
| 45 |
echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99-disable-check-valid-until |
| 46 |
apt update |
| 47 |
|
| 48 |
- name: Build AMDSMI |
| 49 |
run: | |
| 50 |
set -e |
| 51 |
echo 'Building on ${{ matrix.os }}' |
| 52 |
BUILD_FOLDER=$GITHUB_WORKSPACE/build |
| 53 |
RETRIES=3 |
| 54 |
|
| 55 |
for i in $(seq 1 $RETRIES); do |
| 56 |
echo "Build attempt $i for ${{ matrix.os }}..." |
| 57 |
rm -rf $BUILD_FOLDER |
| 58 |
mkdir -p $BUILD_FOLDER |
| 59 |
cd $BUILD_FOLDER |
| 60 |
|
| 61 |
# Capture build output to parse warnings |
| 62 |
if cmake $GITHUB_WORKSPACE -DBUILD_TESTS=ON -DENABLE_ESMI_LIB=ON 2>&1 | tee cmake.log && \ |
| 63 |
make -j $(nproc) 2>&1 | tee make.log && \ |
| 64 |
make package 2>&1 | tee package.log; then |
| 65 |
|
| 66 |
# Parse and report warnings as GitHub annotations |
| 67 |
echo "::group::Build Warnings" |
| 68 |
grep -i "warning" cmake.log make.log package.log | while read -r line; do |
| 69 |
echo "::warning::$line" |
| 70 |
done |
| 71 |
echo "::endgroup::" |
| 72 |
|
| 73 |
echo "Build successful on attempt $i" |
| 74 |
break |
| 75 |
else |
| 76 |
echo "Build failed on attempt $i" |
| 77 |
if [ $i -eq $RETRIES ]; then |
| 78 |
echo "All $RETRIES build attempts failed. Exiting." |
| 79 |
exit 1 |
| 80 |
fi |
| 81 |
sleep $((2 * i)) |
| 82 |
fi |
| 83 |
done |
| 84 |
echo "Build completed on ${{ matrix.os }}" |
| 85 |
|
| 86 |
- name: Install AMDSMI |
| 87 |
run: | |
| 88 |
cd $GITHUB_WORKSPACE/build |
| 89 |
if [ "${{ matrix.os }}" != "Debian10" ]; then |
| 90 |
apt update |
| 91 |
fi |
| 92 |
|
| 93 |
RETRIES=3 |
| 94 |
for i in $(seq 1 $RETRIES); do |
| 95 |
echo "Installation attempt $i for ${{ matrix.os }}..." |
| 96 |
if apt install -y ./amd-smi-lib*99999-local_amd64.deb; then |
| 97 |
echo "Installation successful on attempt $i" |
| 98 |
ln -s /opt/rocm/bin/amd-smi /usr/local/bin |
| 99 |
|
| 100 |
# Verify Installation |
| 101 |
echo 'Verifying installation:' |
| 102 |
amd-smi version |
| 103 |
python3 -m pip list | grep amd |
| 104 |
python3 -m pip list | grep pip |
| 105 |
python3 -m pip list | grep setuptools |
| 106 |
echo 'Completed installation on ${{ matrix.os }}' |
| 107 |
break |
| 108 |
else |
| 109 |
echo "Installation failed on attempt $i" |
| 110 |
if [ $i -eq $RETRIES ]; then |
| 111 |
echo "All $RETRIES installation attempts failed. Exiting." |
| 112 |
exit 1 |
| 113 |
fi |
| 114 |
sleep $((2 * i)) |
| 115 |
fi |
| 116 |
done |
| 117 |
echo "Build completed on ${{ matrix.os }}" |
| 118 |
|
| 119 |
- name: Uninstall |
| 120 |
if: always() |
| 121 |
run: | |
| 122 |
set -e |
| 123 |
echo 'Uninstalling on ${{ matrix.os }}' |
| 124 |
apt remove -y amd-smi-lib || true |
| 125 |
rm -f /usr/local/bin/amd-smi |
| 126 |
if [ -d /opt/rocm/share/amd_smi ]; then |
| 127 |
echo '/opt/rocm/share/amd_smi exists. Removing.' |
| 128 |
rm -rf /opt/rocm/share/amd_smi |
| 129 |
fi |
| 130 |
echo 'Uninstall done on ${{ matrix.os }}' |
| 131 |
|
| 132 |
debian-test: |
| 133 |
name: Tests |
| 134 |
needs: debian-buildinstall |
| 135 |
runs-on: |
| 136 |
- self-hosted |
| 137 |
- ${{ vars.RUNNER_TYPE }} |
| 138 |
continue-on-error: true |
| 139 |
strategy: |
| 140 |
max-parallel: 10 |
| 141 |
matrix: |
| 142 |
os: [Ubuntu20, Ubuntu22, Debian10] |
| 143 |
container: |
| 144 |
image: ${{ vars[format('{0}_DOCKER_IMAGE', matrix.os)] }} |
| 145 |
options: --rm --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --shm-size=64G --cap-add=SYS_MODULE -v /lib/modules:/lib/modules |
| 146 |
|
| 147 |
steps: |
| 148 |
- uses: actions/checkout@v4 |
| 149 |
|
| 150 |
- name: Update repositories for Debian10 |
| 151 |
if: matrix.os == 'Debian10' |
| 152 |
run: | |
| 153 |
set -e |
| 154 |
echo 'Updating repositories for Debian10 (archived)' |
| 155 |
cat > /etc/apt/sources.list << EOF |
| 156 |
deb http://archive.debian.org/debian buster main |
| 157 |
deb http://archive.debian.org/debian-security buster/updates main |
| 158 |
EOF |
| 159 |
echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99-disable-check-valid-until |
| 160 |
apt update |
| 161 |
|
| 162 |
- name: Build and Install for Test |
| 163 |
run: | |
| 164 |
set -e |
| 165 |
echo 'Building for test on ${{ matrix.os }}' |
| 166 |
BUILD_FOLDER=$GITHUB_WORKSPACE/build |
| 167 |
RETRIES=3 |
| 168 |
|
| 169 |
for i in $(seq 1 $RETRIES); do |
| 170 |
echo "Build attempt $i for ${{ matrix.os }} test..." |
| 171 |
rm -rf $BUILD_FOLDER |
| 172 |
mkdir -p $BUILD_FOLDER |
| 173 |
cd $BUILD_FOLDER |
| 174 |
|
| 175 |
if cmake $GITHUB_WORKSPACE -DBUILD_TESTS=ON -DENABLE_ESMI_LIB=ON && \ |
| 176 |
make -j $(nproc) && \ |
| 177 |
make package; then |
| 178 |
echo "Build successful on attempt $i" |
| 179 |
break |
| 180 |
else |
| 181 |
echo "Build failed on attempt $i" |
| 182 |
if [ $i -eq $RETRIES ]; then |
| 183 |
echo "All $RETRIES build attempts failed. Exiting." |
| 184 |
exit 1 |
| 185 |
fi |
| 186 |
sleep $((2 * i)) |
| 187 |
fi |
| 188 |
done |
| 189 |
|
| 190 |
echo 'Installing for test on ${{ matrix.os }}' |
| 191 |
for i in $(seq 1 $RETRIES); do |
| 192 |
echo "Installation attempt $i for test on ${{ matrix.os }}..." |
| 193 |
if apt install -y $BUILD_FOLDER/amd-smi-lib*99999-local_amd64.deb; then |
| 194 |
echo "Installation successful on attempt $i" |
| 195 |
ln -s /opt/rocm/bin/amd-smi /usr/local/bin |
| 196 |
echo 'Install done for test on ${{ matrix.os }}' |
| 197 |
break |
| 198 |
else |
| 199 |
echo "Installation failed on attempt $i" |
| 200 |
if [ $i -eq $RETRIES ]; then |
| 201 |
echo "All $RETRIES installation attempts failed. Exiting." |
| 202 |
exit 1 |
| 203 |
fi |
| 204 |
sleep $((2 * i)) |
| 205 |
fi |
| 206 |
done |
| 207 |
|
| 208 |
- name: AMDSMI Command Tests |
| 209 |
shell: bash |
| 210 |
run: | |
| 211 |
set -e |
| 212 |
echo "Running AMDSMI commands on ${{ matrix.os }}" |
| 213 |
mkdir -p /tmp/test-results-${{ matrix.os }} |
| 214 |
commands=( |
| 215 |
"amd-smi version" |
| 216 |
"amd-smi list" |
| 217 |
"amd-smi static" |
| 218 |
"amd-smi firmware" |
| 219 |
"amd-smi ucode" |
| 220 |
"amd-smi bad-pages" |
| 221 |
"amd-smi metric" |
| 222 |
"amd-smi process" |
| 223 |
"amd-smi topology" |
| 224 |
"amd-smi monitor" |
| 225 |
"amd-smi dmon" |
| 226 |
"amd-smi xgmi" |
| 227 |
"amd-smi partition" |
| 228 |
) |
| 229 |
for cmd in "${commands[@]}"; do |
| 230 |
debug_cmd="$cmd --loglevel debug" |
| 231 |
echo "Running: $debug_cmd" |
| 232 |
if ! eval "$debug_cmd" > /tmp/test-results-${{ matrix.os }}/$(echo $cmd | tr ' ' '_').log 2>&1; then |
| 233 |
echo "Command '$debug_cmd' failed." |
| 234 |
cat /tmp/test-results-${{ matrix.os }}/$(echo $cmd | tr ' ' '_').log |
| 235 |
exit 1 |
| 236 |
else |
| 237 |
echo "$debug_cmd passed." |
| 238 |
fi |
| 239 |
done |
| 240 |
echo "AMDSMI commands done on ${{ matrix.os }}" |
| 241 |
|
| 242 |
- name: Upload AMDSMI Command Test Results |
| 243 |
if: always() |
| 244 |
uses: actions/upload-artifact@v4 |
| 245 |
with: |
| 246 |
name: amdsmi-command-tests-${{ matrix.os }} |
| 247 |
path: /tmp/test-results-${{ matrix.os }} |
| 248 |
|
| 249 |
- name: Run AMDSMI, Python, and Example Tests |
| 250 |
shell: bash |
| 251 |
run: | |
| 252 |
set -e |
| 253 |
echo 'Running other tests on ${{ matrix.os }}' |
| 254 |
|
| 255 |
# AMDSMI Tests |
| 256 |
echo 'Running AMDSMI tests' |
| 257 |
cd /opt/rocm/share/amd_smi/tests |
| 258 |
source amdsmitst.exclude |
| 259 |
|
| 260 |
AMDSMI_RETRIES=3 |
| 261 |
for attempt in $(seq 1 $AMDSMI_RETRIES); do |
| 262 |
echo "AMDSMI test attempt $attempt for ${{ matrix.os }}..." |
| 263 |
if ./amdsmitst --gtest_filter="-$(echo ${BLACKLIST_ALL_ASICS})" > /tmp/test-results-${{ matrix.os }}/amdsmi_tests.log 2>&1; then |
| 264 |
echo "AMDSMI tests passed on attempt $attempt" |
| 265 |
echo "=============== TEST OUTPUT ===============" |
| 266 |
cat /tmp/test-results-${{ matrix.os }}/amdsmi_tests.log | grep -E "\[==========\]|\[ PASSED \]|\[ SKIPPED \]|\[ FAILED \]" |
| 267 |
echo "==============================================" |
| 268 |
echo "AMDSMI tests done" |
| 269 |
break |
| 270 |
else |
| 271 |
TEST_EXIT_CODE=$? |
| 272 |
echo "AMDSMI tests failed on attempt $attempt with exit code $TEST_EXIT_CODE" |
| 273 |
if [ $attempt -eq $AMDSMI_RETRIES ]; then |
| 274 |
echo "All $AMDSMI_RETRIES AMDSMI test attempts failed. Final failure." |
| 275 |
echo "=============== TEST OUTPUT ===============" |
| 276 |
cat /tmp/test-results-${{ matrix.os }}/amdsmi_tests.log | grep -E "\[==========\]|\[ PASSED \]|\[ SKIPPED \]|\[ FAILED \]" |
| 277 |
echo "==============================================" |
| 278 |
echo "AMDSMI tests failed" |
| 279 |
exit $TEST_EXIT_CODE |
| 280 |
else |
| 281 |
echo "Retrying AMDSMI tests in $((2 * attempt)) seconds..." |
| 282 |
sleep $((2 * attempt)) |
| 283 |
fi |
| 284 |
fi |
| 285 |
done |
| 286 |
|
| 287 |
# Python Tests |
| 288 |
echo 'Running Python tests' |
| 289 |
cd /opt/rocm/share/amd_smi/tests/python_unittest |
| 290 |
echo "Running integration tests..." |
| 291 |
if ! ./integration_test.py -v > /tmp/test-results-${{ matrix.os }}/integration_test_output.txt 2>&1; then |
| 292 |
echo "Integration tests failed!" |
| 293 |
echo "=============== INTEGRATION TEST OUTPUT ===============" |
| 294 |
tail -100 /tmp/test-results-${{ matrix.os }}/integration_test_output.txt |
| 295 |
echo "=======================================================" |
| 296 |
exit 1 |
| 297 |
else |
| 298 |
echo "Integration tests passed" |
| 299 |
fi |
| 300 |
|
| 301 |
echo "Running unit tests..." |
| 302 |
if ! ./unit_tests.py -v > /tmp/test-results-${{ matrix.os }}/unit_test_output.txt 2>&1; then |
| 303 |
echo "Unit tests failed!" |
| 304 |
echo "=============== UNIT TEST OUTPUT ===============" |
| 305 |
tail -100 /tmp/test-results-${{ matrix.os }}/unit_test_output.txt |
| 306 |
echo "================================================" |
| 307 |
exit 1 |
| 308 |
else |
| 309 |
echo "Unit tests passed" |
| 310 |
fi |
| 311 |
|
| 312 |
echo "Python tests done" |
| 313 |
|
| 314 |
# Example Tests |
| 315 |
echo 'Running Example tests' |
| 316 |
cd $GITHUB_WORKSPACE/example |
| 317 |
rm -rf build |
| 318 |
cmake -B build -DENABLE_ESMI_LIB=OFF |
| 319 |
make -C build -j $(nproc) |
| 320 |
cd build |
| 321 |
./amd_smi_drm_ex > /tmp/test-results-${{ matrix.os }}/amd_smi_drm_ex.log 2>&1 || echo 'amd_smi_drm_ex failed' |
| 322 |
./amd_smi_nodrm_ex > /tmp/test-results-${{ matrix.os }}/amd_smi_nodrm_ex.log 2>&1 || echo 'amd_smi_nodrm_ex failed' |
| 323 |
echo "Example tests done" |
| 324 |
|
| 325 |
- name: AMDSMI Test Results |
| 326 |
if: always() |
| 327 |
run: | |
| 328 |
echo "Displaying AMDSMI test results for ${{ matrix.os }}" |
| 329 |
cat /tmp/test-results-${{ matrix.os }}/amdsmi_tests.log || echo "No AMDSMI test results found for ${{ matrix.os }}" |
| 330 |
|
| 331 |
- name: Integration Test Results |
| 332 |
if: always() |
| 333 |
run: | |
| 334 |
echo "Displaying Integration test results for ${{ matrix.os }}" |
| 335 |
cat /tmp/test-results-${{ matrix.os }}/integration_test_output.txt || echo "No integration test results found for ${{ matrix.os }}" |
| 336 |
|
| 337 |
- name: Unit Test Results |
| 338 |
if: always() |
| 339 |
run: | |
| 340 |
echo "Displaying Unit Test Results for ${{ matrix.os }}" |
| 341 |
cat /tmp/test-results-${{ matrix.os }}/unit_test_output.txt || echo "No unit test results found for ${{ matrix.os }}" |
| 342 |
|
| 343 |
- name: Example DRM Test Results |
| 344 |
if: always() |
| 345 |
run: | |
| 346 |
echo "Displaying Example DRM test results for ${{ matrix.os }}" |
| 347 |
cat /tmp/test-results-${{ matrix.os }}/amd_smi_drm_ex.log || echo "No DRM example test results found for ${{ matrix.os }}" |
| 348 |
|
| 349 |
- name: Example NoDRM Test Results |
| 350 |
if: always() |
| 351 |
run: | |
| 352 |
echo "Displaying Example NoDRM test results for ${{ matrix.os }}" |
| 353 |
cat /tmp/test-results-${{ matrix.os }}/amd_smi_nodrm_ex.log || echo "No NoDRM example test results found for ${{ matrix.os }}" |
| 354 |
|
| 355 |
rpm-buildinstall: |
| 356 |
name: Build |
| 357 |
runs-on: |
| 358 |
- self-hosted |
| 359 |
- ${{ vars.RUNNER_TYPE }} |
| 360 |
continue-on-error: true |
| 361 |
strategy: |
| 362 |
max-parallel: 10 |
| 363 |
matrix: |
| 364 |
os: |
| 365 |
- SLES |
| 366 |
- RHEL8 |
| 367 |
- RHEL9 |
| 368 |
- RHEL10 |
| 369 |
- AzureLinux3 |
| 370 |
- AlmaLinux8 |
| 371 |
container: |
| 372 |
image: ${{ vars[format('{0}_DOCKER_IMAGE', matrix.os)] }} |
| 373 |
options: --rm --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --shm-size=64G --cap-add=SYS_MODULE -v /lib/modules:/lib/modules |
| 374 |
|
| 375 |
steps: |
| 376 |
- uses: actions/checkout@v4 |
| 377 |
|
| 378 |
- name: Set PkgMgr |
| 379 |
run: | |
| 380 |
set -e |
| 381 |
case "${{ matrix.os }}" in |
| 382 |
SLES) |
| 383 |
echo "PACKAGE_MANAGER=zypper" >> $GITHUB_ENV |
| 384 |
;; |
| 385 |
RHEL8|RHEL9|RHEL10|AlmaLinux8|AzureLinux3) |
| 386 |
echo "PACKAGE_MANAGER=dnf" >> $GITHUB_ENV |
| 387 |
;; |
| 388 |
esac |
| 389 |
|
| 390 |
- name: Add more_itertools |
| 391 |
if: matrix.os == 'AzureLinux3' |
| 392 |
run: | |
| 393 |
set -e |
| 394 |
echo 'Installing more_itertools on ${{ matrix.os }}' |
| 395 |
python3 -m pip install more_itertools |
| 396 |
|
| 397 |
- name: Build AMDSMI(RHEL10 & AlmaLinux8) |
| 398 |
if: matrix.os == 'RHEL10' || matrix.os == 'AlmaLinux8' |
| 399 |
run: | |
| 400 |
set -e |
| 401 |
echo 'Building on ${{ matrix.os }} with retries and QA_RPATHS' |
| 402 |
BUILD_FOLDER=$GITHUB_WORKSPACE/build |
| 403 |
RETRIES=5 |
| 404 |
|
| 405 |
# Set QA_RPATHS to ignore empty (0x0010) and invalid (0x0002) RPATHs |
| 406 |
export QA_RPATHS=$((0x0010 | 0x0002)) |
| 407 |
|
| 408 |
for i in $(seq 1 $RETRIES); do |
| 409 |
echo "Build attempt $i for ${{ matrix.os }} ..." |
| 410 |
rm -rf $BUILD_FOLDER |
| 411 |
mkdir -p $BUILD_FOLDER |
| 412 |
cd $BUILD_FOLDER |
| 413 |
|
| 414 |
if cmake $GITHUB_WORKSPACE -DBUILD_TESTS=ON -DENABLE_ESMI_LIB=ON && \ |
| 415 |
make -j $(nproc) && \ |
| 416 |
make package; then |
| 417 |
echo "Build successful on attempt $i" |
| 418 |
break |
| 419 |
else |
| 420 |
echo "Build failed on attempt $i" |
| 421 |
if [ $i -eq $RETRIES ]; then |
| 422 |
echo "All $RETRIES build attempts failed. Exiting." |
| 423 |
exit 1 |
| 424 |
fi |
| 425 |
sleep $((2 * i)) |
| 426 |
fi |
| 427 |
done |
| 428 |
echo "Build completed on ${{ matrix.os }}" |
| 429 |
|
| 430 |
- name: Build AMDSMI |
| 431 |
if: matrix.os != 'RHEL10' && matrix.os != 'AlmaLinux8' |
| 432 |
run: | |
| 433 |
set -e |
| 434 |
echo 'Building on ${{ matrix.os }}' |
| 435 |
BUILD_FOLDER=$GITHUB_WORKSPACE/build |
| 436 |
RETRIES=3 |
| 437 |
|
| 438 |
for i in $(seq 1 $RETRIES); do |
| 439 |
echo "Build attempt $i for ${{ matrix.os }}..." |
| 440 |
rm -rf $BUILD_FOLDER |
| 441 |
mkdir -p $BUILD_FOLDER |
| 442 |
cd $BUILD_FOLDER |
| 443 |
|
| 444 |
# Capture build output to parse warnings |
| 445 |
if cmake $GITHUB_WORKSPACE -DBUILD_TESTS=ON -DENABLE_ESMI_LIB=ON 2>&1 | tee cmake.log && \ |
| 446 |
make -j $(nproc) 2>&1 | tee make.log && \ |
| 447 |
make package 2>&1 | tee package.log; then |
| 448 |
|
| 449 |
# Parse and report warnings as GitHub annotations |
| 450 |
echo "::group::Build Warnings" |
| 451 |
grep -i "warning" cmake.log make.log package.log | while read -r line; do |
| 452 |
echo "::warning::$line" |
| 453 |
done |
| 454 |
echo "::endgroup::" |
| 455 |
|
| 456 |
echo "Build successful on attempt $i" |
| 457 |
break |
| 458 |
else |
| 459 |
echo "Build failed on attempt $i" |
| 460 |
if [ $i -eq $RETRIES ]; then |
| 461 |
echo "All $RETRIES build attempts failed. Exiting." |
| 462 |
exit 1 |
| 463 |
fi |
| 464 |
sleep $((2 * i)) |
| 465 |
fi |
| 466 |
done |
| 467 |
echo "Build completed on ${{ matrix.os }}" |
| 468 |
|
| 469 |
- name: Install AMDSMI(RHEL10 & AlmaLinux8) |
| 470 |
if: matrix.os == 'RHEL10' || matrix.os == 'AlmaLinux8' |
| 471 |
run: | |
| 472 |
cd $GITHUB_WORKSPACE/build |
| 473 |
dnf install python3-setuptools python3-wheel -y |
| 474 |
|
| 475 |
RETRIES=3 |
| 476 |
for i in $(seq 1 $RETRIES); do |
| 477 |
echo "RHEL10: Installation attempt $i..." |
| 478 |
if timeout 10m dnf install -y --skip-broken --disablerepo=* ./amd-smi-lib-*99999-local*.rpm; then |
| 479 |
echo "Installation successful on attempt $i" |
| 480 |
ln -s /opt/rocm/bin/amd-smi /usr/local/bin |
| 481 |
|
| 482 |
echo 'Verifying installation:' |
| 483 |
amd-smi version |
| 484 |
python3 -m pip list | grep amd |
| 485 |
python3 -m pip list | grep pip |
| 486 |
python3 -m pip list | grep setuptools |
| 487 |
echo 'Completed installation on RHEL10' |
| 488 |
break |
| 489 |
else |
| 490 |
echo "Installation failed on attempt $i" |
| 491 |
if [ $i -eq $RETRIES ]; then |
| 492 |
echo "All $RETRIES installation attempts failed. Exiting." |
| 493 |
exit 1 |
| 494 |
fi |
| 495 |
sleep $((2 * i)) |
| 496 |
fi |
| 497 |
done |
| 498 |
|
| 499 |
- name: Install AMDSMI |
| 500 |
if: matrix.os != 'RHEL10' && matrix.os != 'AlmaLinux8' |
| 501 |
run: | |
| 502 |
cd $GITHUB_WORKSPACE/build |
| 503 |
case ${{ env.PACKAGE_MANAGER }} in |
| 504 |
zypper) |
| 505 |
timeout 10m zypper --no-refresh --no-gpg-checks install -y ./amd-smi-lib-*99999-local*.rpm |
| 506 |
;; |
| 507 |
dnf) |
| 508 |
dnf install python3-setuptools python3-wheel -y |
| 509 |
RETRIES=3 |
| 510 |
for i in $(seq 1 $RETRIES); do |
| 511 |
echo "Attempt $i: Installing AMDSMI package..." |
| 512 |
if timeout 10m dnf install -y --skip-broken --disablerepo=* ./amd-smi-lib-*99999-local*.rpm; then |
| 513 |
echo "AMDSMI package installed successfully." |
| 514 |
break |
| 515 |
else |
| 516 |
echo "Installation failed on attempt $i. Retrying..." |
| 517 |
if [ $i -eq $RETRIES ]; then |
| 518 |
echo "All $RETRIES attempts failed. Exiting." |
| 519 |
exit 1 |
| 520 |
fi |
| 521 |
sleep 10 |
| 522 |
fi |
| 523 |
done |
| 524 |
;; |
| 525 |
esac |
| 526 |
ln -s /opt/rocm/bin/amd-smi /usr/local/bin |
| 527 |
|
| 528 |
# Verify Installation |
| 529 |
echo 'Verifying installation:' |
| 530 |
amd-smi version |
| 531 |
python3 -m pip list | grep amd |
| 532 |
python3 -m pip list | grep pip |
| 533 |
python3 -m pip list | grep setuptools |
| 534 |
echo 'Completed installation on ${{ matrix.os }}' |
| 535 |
|
| 536 |
- name: Uninstall |
| 537 |
if: always() |
| 538 |
run: | |
| 539 |
set -e |
| 540 |
echo 'Uninstalling on ${{ matrix.os }}' |
| 541 |
case ${{ matrix.os }} in |
| 542 |
SLES) |
| 543 |
zypper remove -y amd-smi-lib || true |
| 544 |
;; |
| 545 |
RHEL8|RHEL9|RHEL10|AlmaLinux8|AzureLinux3) |
| 546 |
dnf remove -y amd-smi-lib || true |
| 547 |
;; |
| 548 |
esac |
| 549 |
rm -f /usr/local/bin/amd-smi |
| 550 |
if [ -d /opt/rocm/share/amd_smi ]; then |
| 551 |
echo '/opt/rocm/share/amd_smi exists. Removing.' |
| 552 |
rm -rf /opt/rocm/share/amd_smi |
| 553 |
fi |
| 554 |
echo 'Uninstall done on ${{ matrix.os }}' |
| 555 |
|
| 556 |
rpm-test: |
| 557 |
name: Tests |
| 558 |
needs: [rpm-buildinstall, debian-test] # debian-test is needed to complete before rpm-test starts (see comment about driver reloads) |
| 559 |
runs-on: |
| 560 |
- self-hosted |
| 561 |
- ${{ vars.RUNNER_TYPE }} |
| 562 |
continue-on-error: true |
| 563 |
strategy: |
| 564 |
max-parallel: 10 |
| 565 |
matrix: |
| 566 |
os: |
| 567 |
- SLES |
| 568 |
- RHEL8 |
| 569 |
- RHEL9 |
| 570 |
- RHEL10 |
| 571 |
- AzureLinux3 |
| 572 |
- AlmaLinux8 |
| 573 |
container: |
| 574 |
image: ${{ vars[format('{0}_DOCKER_IMAGE', matrix.os)] }} |
| 575 |
options: --rm --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --shm-size=64G --cap-add=SYS_MODULE -v /lib/modules:/lib/modules |
| 576 |
|
| 577 |
steps: |
| 578 |
- uses: actions/checkout@v4 |
| 579 |
|
| 580 |
- name: Set PkgMgr |
| 581 |
run: | |
| 582 |
set -e |
| 583 |
case "${{ matrix.os }}" in |
| 584 |
SLES) |
| 585 |
echo "PACKAGE_MANAGER=zypper" >> $GITHUB_ENV |
| 586 |
;; |
| 587 |
RHEL8|RHEL9|RHEL10|AlmaLinux8|AzureLinux3) |
| 588 |
echo "PACKAGE_MANAGER=dnf" >> $GITHUB_ENV |
| 589 |
;; |
| 590 |
esac |
| 591 |
|
| 592 |
- name: Add more_itertools |
| 593 |
if: matrix.os == 'AzureLinux3' |
| 594 |
run: | |
| 595 |
set -e |
| 596 |
echo 'Installing more_itertools on ${{ matrix.os }}' |
| 597 |
python3 -m pip install more_itertools |
| 598 |
|
| 599 |
- name: Build and Install for Tests (RHEL10 & AlmaLinux8) |
| 600 |
if: matrix.os == 'RHEL10' || matrix.os == 'AlmaLinux8' |
| 601 |
run: | |
| 602 |
set -e |
| 603 |
echo 'Building for test on RHEL10/AlmaLinux8 with retries and QA_RPATHS' |
| 604 |
BUILD_FOLDER=$GITHUB_WORKSPACE/build |
| 605 |
RETRIES=5 |
| 606 |
|
| 607 |
# Set QA_RPATHS to ignore empty (0x0010 | 0x0002) RPATHs |
| 608 |
export QA_RPATHS=$((0x0010 | 0x0002)) |
| 609 |
|
| 610 |
for i in $(seq 1 $RETRIES); do |
| 611 |
echo "Build attempt $i for RHEL10/AlmaLinux8 test..." |
| 612 |
rm -rf $BUILD_FOLDER |
| 613 |
mkdir -p $BUILD_FOLDER |
| 614 |
cd $BUILD_FOLDER |
| 615 |
|
| 616 |
if cmake $GITHUB_WORKSPACE -DBUILD_TESTS=ON -DENABLE_ESMI_LIB=ON && \ |
| 617 |
make -j $(nproc) && \ |
| 618 |
make package; then |
| 619 |
echo "Build successful on attempt $i" |
| 620 |
break |
| 621 |
else |
| 622 |
echo "Build failed on attempt $i" |
| 623 |
if [ $i -eq $RETRIES ]; then |
| 624 |
echo "All $RETRIES build attempts failed. Exiting." |
| 625 |
exit 1 |
| 626 |
fi |
| 627 |
sleep $((2 * i)) |
| 628 |
fi |
| 629 |
done |
| 630 |
|
| 631 |
echo 'Installing for test on RHEL10/AlmaLinux8' |
| 632 |
dnf install python3-setuptools python3-wheel -y |
| 633 |
|
| 634 |
for i in $(seq 1 $RETRIES); do |
| 635 |
echo "RHEL10/AlmaLinux8: Installation attempt $i for test..." |
| 636 |
if timeout 10m dnf install -y --skip-broken --disablerepo=* $BUILD_FOLDER/amd-smi-lib-*99999-local*.rpm; then |
| 637 |
echo "Installation successful on attempt $i" |
| 638 |
ln -s /opt/rocm/bin/amd-smi /usr/local/bin |
| 639 |
echo 'Install done for test on RHEL10/AlmaLinux8' |
| 640 |
break |
| 641 |
else |
| 642 |
echo "Installation failed on attempt $i" |
| 643 |
if [ $i -eq $RETRIES ]; then |
| 644 |
echo "All $RETRIES installation attempts failed. Exiting." |
| 645 |
exit 1 |
| 646 |
fi |
| 647 |
sleep $((2 * i)) |
| 648 |
fi |
| 649 |
done |
| 650 |
|
| 651 |
- name: Build and Install for Tests |
| 652 |
if: matrix.os != 'RHEL10' && matrix.os != 'AlmaLinux8' |
| 653 |
run: | |
| 654 |
set -e |
| 655 |
echo 'Building for test on ${{ matrix.os }}' |
| 656 |
BUILD_FOLDER=$GITHUB_WORKSPACE/build |
| 657 |
rm -rf $BUILD_FOLDER |
| 658 |
mkdir -p $BUILD_FOLDER |
| 659 |
cd $BUILD_FOLDER |
| 660 |
cmake $GITHUB_WORKSPACE -DBUILD_TESTS=ON -DENABLE_ESMI_LIB=ON |
| 661 |
make -j $(nproc) |
| 662 |
make package |
| 663 |
|
| 664 |
echo 'Installing for test on ${{ matrix.os }}' |
| 665 |
case ${{ env.PACKAGE_MANAGER }} in |
| 666 |
zypper) |
| 667 |
timeout 10m zypper --no-refresh --no-gpg-checks install -y $BUILD_FOLDER/amd-smi-lib-*99999-local*.rpm |
| 668 |
;; |
| 669 |
dnf) |
| 670 |
dnf install python3-setuptools python3-wheel -y |
| 671 |
RETRIES=3 |
| 672 |
for i in $(seq 1 $RETRIES); do |
| 673 |
echo "Attempt $i: Installing..." |
| 674 |
if timeout 10m dnf install -y --skip-broken --disablerepo=* $BUILD_FOLDER/amd-smi-lib-*99999-local*.rpm; then |
| 675 |
echo "Install successful." |
| 676 |
break |
| 677 |
else |
| 678 |
echo "Attempt $i failed. Retrying..." |
| 679 |
if [ $i -eq $RETRIES ]; then |
| 680 |
echo "All attempts failed." |
| 681 |
exit 1 |
| 682 |
fi |
| 683 |
sleep 10 |
| 684 |
fi |
| 685 |
done |
| 686 |
;; |
| 687 |
esac |
| 688 |
ln -s /opt/rocm/bin/amd-smi /usr/local/bin |
| 689 |
echo 'Install done for test on ${{ matrix.os }}' |
| 690 |
|
| 691 |
- name: AMDSMI Command Tests |
| 692 |
shell: bash |
| 693 |
run: | |
| 694 |
set -e |
| 695 |
echo "Running AMDSMI commands on ${{ matrix.os }}" |
| 696 |
mkdir -p /tmp/test-results-${{ matrix.os }} |
| 697 |
commands=( |
| 698 |
"amd-smi version" |
| 699 |
"amd-smi list" |
| 700 |
"amd-smi static" |
| 701 |
"amd-smi firmware" |
| 702 |
"amd-smi ucode" |
| 703 |
"amd-smi bad-pages" |
| 704 |
"amd-smi metric" |
| 705 |
"amd-smi process" |
| 706 |
"amd-smi topology" |
| 707 |
"amd-smi monitor" |
| 708 |
"amd-smi dmon" |
| 709 |
"amd-smi xgmi" |
| 710 |
"amd-smi partition" |
| 711 |
) |
| 712 |
for cmd in "${commands[@]}"; do |
| 713 |
debug_cmd="$cmd --loglevel debug" |
| 714 |
echo "Running: $debug_cmd" |
| 715 |
if ! eval "$debug_cmd" > /tmp/test-results-${{ matrix.os }}/$(echo $cmd | tr ' ' '_').log 2>&1; then |
| 716 |
echo "Command '$debug_cmd' failed." |
| 717 |
cat /tmp/test-results-${{ matrix.os }}/$(echo $cmd | tr ' ' '_').log |
| 718 |
exit 1 |
| 719 |
else |
| 720 |
echo "$debug_cmd passed." |
| 721 |
fi |
| 722 |
done |
| 723 |
echo "AMDSMI commands done on ${{ matrix.os }}" |
| 724 |
|
| 725 |
- name: Upload AMDSMI Command Test Results |
| 726 |
if: always() |
| 727 |
uses: actions/upload-artifact@v4 |
| 728 |
with: |
| 729 |
name: amdsmi-command-tests-${{ matrix.os }} |
| 730 |
path: /tmp/test-results-${{ matrix.os }} |
| 731 |
|
| 732 |
- name: Run AMDSMI, Python, and Example Tests |
| 733 |
shell: bash |
| 734 |
run: | |
| 735 |
set -e |
| 736 |
echo 'Running other tests on ${{ matrix.os }}' |
| 737 |
|
| 738 |
# AMDSMI Tests |
| 739 |
echo 'Running AMDSMI tests' |
| 740 |
cd /opt/rocm/share/amd_smi/tests |
| 741 |
source amdsmitst.exclude |
| 742 |
|
| 743 |
AMDSMI_RETRIES=3 |
| 744 |
for attempt in $(seq 1 $AMDSMI_RETRIES); do |
| 745 |
echo "AMDSMI test attempt $attempt for ${{ matrix.os }}..." |
| 746 |
if ./amdsmitst --gtest_filter="-$(echo ${BLACKLIST_ALL_ASICS})" > /tmp/test-results-${{ matrix.os }}/amdsmi_tests.log 2>&1; then |
| 747 |
echo "AMDSMI tests passed on attempt $attempt" |
| 748 |
echo "=============== TEST OUTPUT ===============" |
| 749 |
cat /tmp/test-results-${{ matrix.os }}/amdsmi_tests.log | grep -E "\[==========\]|\[ PASSED \]|\[ SKIPPED \]|\[ FAILED \]" |
| 750 |
echo "==============================================" |
| 751 |
echo "AMDSMI tests done" |
| 752 |
break |
| 753 |
else |
| 754 |
TEST_EXIT_CODE=$? |
| 755 |
echo "AMDSMI tests failed on attempt $attempt with exit code $TEST_EXIT_CODE" |
| 756 |
if [ $attempt -eq $AMDSMI_RETRIES ]; then |
| 757 |
echo "All $AMDSMI_RETRIES AMDSMI test attempts failed. Final failure." |
| 758 |
echo "=============== TEST OUTPUT ===============" |
| 759 |
cat /tmp/test-results-${{ matrix.os }}/amdsmi_tests.log | grep -E "\[==========\]|\[ PASSED \]|\[ SKIPPED \]|\[ FAILED \]" |
| 760 |
echo "==============================================" |
| 761 |
echo "AMDSMI tests failed" |
| 762 |
exit $TEST_EXIT_CODE |
| 763 |
else |
| 764 |
echo "Retrying AMDSMI tests in $((2 * attempt)) seconds..." |
| 765 |
sleep $((2 * attempt)) |
| 766 |
fi |
| 767 |
fi |
| 768 |
done |
| 769 |
|
| 770 |
# Python Tests |
| 771 |
echo 'Running Python tests' |
| 772 |
cd /opt/rocm/share/amd_smi/tests/python_unittest |
| 773 |
echo "Running integration tests..." |
| 774 |
if ! ./integration_test.py -v > /tmp/test-results-${{ matrix.os }}/integration_test_output.txt 2>&1; then |
| 775 |
echo "Integration tests failed!" |
| 776 |
echo "=============== INTEGRATION TEST OUTPUT ===============" |
| 777 |
tail -100 /tmp/test-results-${{ matrix.os }}/integration_test_output.txt |
| 778 |
echo "=======================================================" |
| 779 |
exit 1 |
| 780 |
else |
| 781 |
echo "Integration tests passed" |
| 782 |
fi |
| 783 |
|
| 784 |
echo "Running unit tests..." |
| 785 |
if ! ./unit_tests.py -v > /tmp/test-results-${{ matrix.os }}/unit_test_output.txt 2>&1; then |
| 786 |
echo "Unit tests failed!" |
| 787 |
echo "=============== UNIT TEST OUTPUT ===============" |
| 788 |
tail -100 /tmp/test-results-${{ matrix.os }}/unit_test_output.txt |
| 789 |
echo "================================================" |
| 790 |
exit 1 |
| 791 |
else |
| 792 |
echo "Unit tests passed" |
| 793 |
fi |
| 794 |
|
| 795 |
echo "Python tests done" |
| 796 |
|
| 797 |
# Example Tests |
| 798 |
echo 'Running Example tests' |
| 799 |
cd $GITHUB_WORKSPACE/example |
| 800 |
rm -rf build |
| 801 |
cmake -B build -DENABLE_ESMI_LIB=OFF |
| 802 |
make -C build -j $(nproc) |
| 803 |
cd build |
| 804 |
./amd_smi_drm_ex > /tmp/test-results-${{ matrix.os }}/amd_smi_drm_ex.log 2>&1 || echo 'amd_smi_drm_ex failed' |
| 805 |
./amd_smi_nodrm_ex > /tmp/test-results-${{ matrix.os }}/amd_smi_nodrm_ex.log 2>&1 || echo 'amd_smi_nodrm_ex failed' |
| 806 |
echo "Example tests done" |
| 807 |
|
| 808 |
- name: AMDSMI Test Results |
| 809 |
if: always() |
| 810 |
run: | |
| 811 |
echo "Displaying AMDSMI test results for ${{ matrix.os }}" |
| 812 |
cat /tmp/test-results-${{ matrix.os }}/amdsmi_tests.log || echo "No AMDSMI test results found for ${{ matrix.os }}" |
| 813 |
|
| 814 |
- name: Integration Test Results |
| 815 |
if: always() |
| 816 |
run: | |
| 817 |
echo "Displaying Integration test results for ${{ matrix.os }}" |
| 818 |
cat /tmp/test-results-${{ matrix.os }}/integration_test_output.txt || echo "No integration test results found for ${{ matrix.os }}" |
| 819 |
|
| 820 |
- name: Unit Test Results |
| 821 |
if: always() |
| 822 |
run: | |
| 823 |
echo "Displaying Unit Test Results for ${{ matrix.os }}" |
| 824 |
cat /tmp/test-results-${{ matrix.os }}/unit_test_output.txt || echo "No unit test results found for ${{ matrix.os }}" |
| 825 |
|
| 826 |
- name: Example DRM Test Results |
| 827 |
if: always() |
| 828 |
run: | |
| 829 |
echo "Displaying Example DRM test results for ${{ matrix.os }}" |
| 830 |
cat /tmp/test-results-${{ matrix.os }}/amd_smi_drm_ex.log || echo "No DRM example test results found for ${{ matrix.os }}" |
| 831 |
|
| 832 |
- name: Example NoDRM Test Results |
| 833 |
if: always() |
| 834 |
run: | |
| 835 |
echo "Displaying Example NoDRM test results for ${{ matrix.os }}" |
| 836 |
cat /tmp/test-results-${{ matrix.os }}/amd_smi_nodrm_ex.log || echo "No NoDRM example test results found for ${{ matrix.os }}" |