Skip to content
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
86 changes: 86 additions & 0 deletions .github/workflows/amdsmi-python-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# ---------------------------------------------------------------------------
# AMD SMI Python-version loader tests.
#
# The amdsmi loader and wrapper must behave identically across every CPython
# version AMD SMI supports (3.6.8 through the latest release). This job runs the
# version-independent loader contract tests under a matrix of interpreters so a
# change that only breaks on a specific version is caught. No GPU required.
# ---------------------------------------------------------------------------

name: AMDSMI Python Version Tests

on:
pull_request:
branches: [develop]
paths:
- 'projects/amdsmi/py-interface/**'
- 'projects/amdsmi/tools/generator.py'
- 'projects/amdsmi/tools/disable_system_fallback.py'
- 'projects/amdsmi/tests/python/**'
- 'projects/amdsmi/tests/run_amdsmi_python_versions_test.py'
- '.github/workflows/amdsmi-python-versions.yml'
push:
branches: [develop]
paths:
- 'projects/amdsmi/py-interface/**'
- 'projects/amdsmi/tools/generator.py'
- 'projects/amdsmi/tools/disable_system_fallback.py'
- 'projects/amdsmi/tests/python/**'
- 'projects/amdsmi/tests/run_amdsmi_python_versions_test.py'
- '.github/workflows/amdsmi-python-versions.yml'
workflow_dispatch:

permissions:
contents: read

jobs:
python-version-tests:
name: Python ${{matrix.python-version}}
runs-on: ubuntu-22.04
# 3.6/3.7 run inside official python images because actions/setup-python no
# longer provides those EOL interpreters on a supported hosted runner (they
# were only on ubuntu-20.04, itself being retired). The images are archived,
# not deleted, so this stays green after the runner EOL. Newer minors run
# natively via setup-python. Empty matrix.container = no container.
container: ${{matrix.container}}
strategy:
fail-fast: false
matrix:
include:
- { python-version: '3.6', container: 'python:3.6-slim-bullseye' }
- { python-version: '3.7', container: 'python:3.7-slim-bullseye' }
- { python-version: '3.8', container: '' }
- { python-version: '3.9', container: '' }
- { python-version: '3.10', container: '' }
- { python-version: '3.11', container: '' }
- { python-version: '3.12', container: '' }
- { python-version: '3.13', container: '' }
- { python-version: '3.14', container: '' }

steps:
# The slim python images ship without git; actions/checkout needs it.
- name: Install git (container legs only)
if: matrix.container != ''
run: |
apt-get update
apt-get install -y --no-install-recommends git ca-certificates

- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
# rocm-systems is a large monorepo; only the amdsmi tests are needed.
sparse-checkout: |
projects/amdsmi
.github/workflows

- name: Set up Python ${{matrix.python-version}}
# Container legs already ship the exact interpreter; only host runners
# need setup-python.
if: matrix.container == ''
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{matrix.python-version}}

- name: Run loader tests under this interpreter
run: |
python3 projects/amdsmi/tests/run_amdsmi_python_versions_test.py \
--interpreters "$(command -v python3)"
136 changes: 136 additions & 0 deletions .github/workflows/amdsmi-upgrade-downgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# ---------------------------------------------------------------------------
# AMD SMI package upgrade / downgrade test.
#
# The packaging rework changed how the module is delivered (direct
# site-packages install instead of a postinst pip install), which changes the
# postinst/prerm/postun semantics. This job builds the package twice with
# different versions in the SAME distro container, then installs old -> upgrades
# to new -> downgrades back, asserting the module, CLI, and the ld.so.conf.d
# linker registration stay consistent at each step (a self-upgrade round trip;
# a true cross-release test additionally needs a prior published artifact).
#
# The package must be built and tested in the same distro image: the RPM/DEB
# bakes in the distro's site-packages path, so a package built on one distro
# will not import on another. No GPU required.
# ---------------------------------------------------------------------------

name: AMDSMI Upgrade Downgrade

on:
pull_request:
branches: [develop]
paths:
- 'projects/amdsmi/DEBIAN/**'
- 'projects/amdsmi/RPM/**'
- 'projects/amdsmi/py-interface/**'
- 'projects/amdsmi/CMakeLists.txt'
- 'projects/amdsmi/tests/run_amdsmi_upgrade_downgrade_test.py'
- '.github/workflows/amdsmi-upgrade-downgrade.yml'
push:
branches: [develop]
paths:
- 'projects/amdsmi/DEBIAN/**'
- 'projects/amdsmi/RPM/**'
- 'projects/amdsmi/py-interface/**'
- 'projects/amdsmi/CMakeLists.txt'
- 'projects/amdsmi/tests/run_amdsmi_upgrade_downgrade_test.py'
- '.github/workflows/amdsmi-upgrade-downgrade.yml'
workflow_dispatch:

permissions:
contents: read

jobs:
upgrade-downgrade:
name: ${{matrix.name}}
runs-on: ubuntu-22.04
container: ${{matrix.container}}
strategy:
fail-fast: false
matrix:
include:
- name: Debian (Ubuntu 22.04)
container: ubuntu:22.04
generator: DEB
manager: apt
ext: deb
- name: RPM (AlmaLinux 9)
container: almalinux:9
generator: RPM
manager: dnf
ext: rpm

env:
BUILD_DIR: /tmp/amdsmi-build

steps:
- name: Install Debian build prerequisites
if: matrix.generator == 'DEB'
run: |
set -e
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y --no-install-recommends \
git ca-certificates gcc g++ cmake make file pkg-config \
libdrm-dev libnl-3-dev libnl-genl-3-dev libmnl-dev python3 sudo

- name: Install RPM build prerequisites
if: matrix.generator == 'RPM'
run: |
set -e
# libnl3-devel/libmnl-devel live in CRB + EPEL on AlmaLinux 9.
dnf install -y 'dnf-command(config-manager)'
dnf config-manager --set-enabled crb
dnf install -y epel-release
dnf install -y \
git gcc gcc-c++ cmake make rpm-build file \
libdrm-devel libnl3-devel libmnl-devel python3 sudo

- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
# rocm-systems is a large monorepo; only the amdsmi project is needed.
sparse-checkout: |
projects/amdsmi
.github/workflows

- name: Mark workspace safe for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"

- name: Configure and build once
working-directory: projects/amdsmi
run: |
set -e
cmake -S . -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release -DENABLE_ESMI_LIB=ON
cmake --build "$BUILD_DIR" -j"$(nproc)"

- name: Package two versions (old, new)
working-directory: projects/amdsmi
run: |
set -e
# Re-package the same build tree at two versions via
# ROCM_LIBPATCH_VERSION (the 4th version component); no rebuild.
# Select the MAIN package only (exclude the -tests package). Match by
# build order rather than a hardcoded version so a version bump does
# not silently break the selection: after the first cpack only v1
# exists, and after the second the newest by version sort is v2.
mkdir -p /tmp/pkgs
main_pkgs() {
find "$BUILD_DIR" -maxdepth 1 -name "amd-smi-lib[-_]*.${{matrix.ext}}" \
| grep -v -- '-tests' | sort -V
}
ROCM_LIBPATCH_VERSION=1 cmake "$BUILD_DIR" >/dev/null
( cd "$BUILD_DIR" && cpack -G ${{matrix.generator}} )
cp "$(main_pkgs | head -1)" /tmp/pkgs/old.${{matrix.ext}}
ROCM_LIBPATCH_VERSION=2 cmake "$BUILD_DIR" >/dev/null
( cd "$BUILD_DIR" && cpack -G ${{matrix.generator}} )
cp "$(main_pkgs | tail -1)" /tmp/pkgs/new.${{matrix.ext}}
ls -l /tmp/pkgs

- name: Install old, upgrade to new, downgrade to old
working-directory: projects/amdsmi
run: |
set -e
python3 tests/run_amdsmi_upgrade_downgrade_test.py \
--old-package /tmp/pkgs/old.${{matrix.ext}} \
--new-package /tmp/pkgs/new.${{matrix.ext}} \
--package-manager ${{matrix.manager}}
Loading
Loading