Files
TheRock/rocm-systems/.github/workflows/hipfile-python-bindings.yml
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

219 lines
8.8 KiB
YAML

name: hipfile-python-bindings
run-name: Build and install hipFile Python bindings
env:
AIS_GHA_CMD_FILES_DOCKER_DIR: /root/github
AIS_INPUT_CI_IMAGE: ${{ inputs.ci_image }}
AIS_INPUT_CXX_COMPILER: ${{ inputs.cxx_compiler }}
AIS_INPUT_CXX_STANDARD: ${{ inputs.cxx_standard }}
AIS_INPUT_HIPFILE_PKG_DEV_FILENAME: ${{ inputs.ais_hipfile_pkg_dev_filename }}
AIS_INPUT_HIPFILE_PKG_FILENAME: ${{ inputs.ais_hipfile_pkg_filename }}
AIS_INPUT_PLATFORM: ${{ inputs.platform }}
AIS_INPUT_ROCM_VERSION: ${{ inputs.rocm_version }}
AIS_PKG_MGR: >-
${{
startsWith(inputs.platform, 'rocky') && 'dnf' ||
inputs.platform == 'suse' && 'zypper' ||
inputs.platform == 'ubuntu' && 'apt'
}}
on:
workflow_call:
inputs:
ais_hipfile_pkg_dev_filename:
required: true
type: string
ais_hipfile_pkg_filename:
required: true
type: string
ci_image:
required: true
type: string
cxx_compiler:
description: "C++ compiler the consumed packages were built with"
required: true
type: string
cxx_standard:
description: "C++ standard the consumed packages were built with"
required: true
type: number
platform:
required: true
type: string
rocm_version:
description: "Target ROCm MAJOR.MINOR.PATCH Version"
required: true
type: string
outputs:
hipfile_python_sdist_filename:
description: "Filename of the hipFile Python sdist artifact"
value: ${{ jobs.build_python_bindings.outputs.hipfile_python_sdist_filename }}
permissions:
contents: read
packages: read
jobs:
build_python_bindings:
runs-on: [ubuntu-24.04]
outputs:
hipfile_python_sdist_filename: ${{ steps.sdist-metadata.outputs.HIPFILE_PYTHON_SDIST_FILENAME }}
steps:
- name: Set early AIS CI environment variables
run: |
echo "AIS_PR_NUMBER=$(echo "${GITHUB_REF}" | sed 's|[^0-9]||g')" >> "${GITHUB_ENV}"
echo "AIS_GHA_CMD_FILES_DIR=${GITHUB_ENV%/*}" >> "${GITHUB_ENV}"
echo "AIS_SAFE_COMPILER_NAME=$(echo "${AIS_INPUT_CXX_COMPILER}" | sed 's|[\+]|plus|g')" >> "${GITHUB_ENV}"
- name: Set AIS CI container name
run: |
echo "AIS_CONTAINER_NAME=${AIS_PR_NUMBER:=${GITHUB_RUN_ID}}_${GITHUB_JOB}_${AIS_INPUT_PLATFORM}_${AIS_INPUT_ROCM_VERSION}_${AIS_SAFE_COMPILER_NAME}_${AIS_INPUT_CXX_STANDARD}" >> "${GITHUB_ENV}"
- name: Fetching code repository...
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
path: rocm-systems
sparse-checkout: |
projects/hipfile
.github/workflows
- name: Download hipFile runtime package
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ inputs.ais_hipfile_pkg_filename }}
- name: Download hipFile development package
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ inputs.ais_hipfile_pkg_dev_filename }}
- name: Authenticating to GitHub Container Registry
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Starting Docker Container
run: |
docker run \
-dt \
--rm \
--pull always \
-v ${GITHUB_WORKSPACE}:/mnt/ais:ro \
-v "${AIS_GHA_CMD_FILES_DIR}:${AIS_GHA_CMD_FILES_DOCKER_DIR}" \
--name "${AIS_CONTAINER_NAME}" \
"${AIS_INPUT_CI_IMAGE}"
- name: Make copy of the code repository
run: |
docker exec \
-t \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
cp -R /mnt/ais /ais
'
- name: Copy the hipFile packages into the container
run: |
docker cp \
"${GITHUB_WORKSPACE}/${AIS_INPUT_HIPFILE_PKG_FILENAME}" \
"${AIS_CONTAINER_NAME}:/root"
docker cp \
"${GITHUB_WORKSPACE}/${AIS_INPUT_HIPFILE_PKG_DEV_FILENAME}" \
"${AIS_CONTAINER_NAME}:/root"
- name: Install the hipFile packages
run: |
docker exec \
-t \
-w /root \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
${{
format(
env.AIS_PKG_MGR == 'apt' && 'apt install -y "./{0}" "./{1}"' ||
env.AIS_PKG_MGR == 'dnf' && 'dnf install -y --cacheonly "./{0}" "./{1}"' ||
env.AIS_PKG_MGR == 'zypper' && 'zypper --no-refresh install -y --allow-unsigned-rpm "./{0}" "./{1}"' ||
'echo "Unknown platform."; exit 1',
inputs.ais_hipfile_pkg_filename,
inputs.ais_hipfile_pkg_dev_filename
)
}}
ldconfig
'
- name: Create Python virtual environment and install build dependencies
run: |
docker exec \
-t \
-w /ais/rocm-systems/projects/hipfile \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
python3.12 -m venv .venv
.venv/bin/pip install --upgrade pip
.venv/bin/pip install build pytest
'
- name: Build hipFile Python sdist & capture metadata
id: sdist-metadata
run: |
docker exec \
-e "AIS_GITHUB_OUTPUT=${{ env.AIS_GHA_CMD_FILES_DOCKER_DIR }}/${GITHUB_OUTPUT##*/}" \
-e "_AIS_INPUT_PLATFORM=${AIS_INPUT_PLATFORM}" \
-e "_AIS_INPUT_ROCM_VERSION=${AIS_INPUT_ROCM_VERSION}" \
-e "_AIS_SAFE_COMPILER_NAME=${AIS_SAFE_COMPILER_NAME}" \
-e "_AIS_INPUT_CXX_STANDARD=${AIS_INPUT_CXX_STANDARD}" \
-t \
-w /ais/rocm-systems/projects/hipfile \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
.venv/bin/python -m build --sdist ./python
shopt -s nullglob
OLD_FILENAME="$(basename ./python/dist/hipfile-*.tar.gz)"
# python_bindings runs for every (platform, rocm, cxx) leg and the
# sdist version does not encode any of them, so disambiguate the
# artifact (named after the file) across all of them. Sanitized
# compiler avoids a "+" being read as a PEP 440 local version.
NEW_FILENAME="${OLD_FILENAME%.tar.gz}-${_AIS_INPUT_PLATFORM}-${_AIS_INPUT_ROCM_VERSION}-${_AIS_SAFE_COMPILER_NAME}-cxx${_AIS_INPUT_CXX_STANDARD}.tar.gz"
mv ./python/dist/${OLD_FILENAME} ./python/dist/${NEW_FILENAME}
echo "HIPFILE_PYTHON_SDIST_FILENAME=${NEW_FILENAME}" >> "${AIS_GITHUB_OUTPUT}"
'
- name: Install hipFile Python sdist into virtual environment
run: |
docker exec \
-t \
-w /ais/rocm-systems/projects/hipfile \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
.venv/bin/pip install ./python/dist/${{ steps.sdist-metadata.outputs.HIPFILE_PYTHON_SDIST_FILENAME }}
'
- name: Verify hipFile Python package installation
run: |
docker exec \
-t \
-w /ais/rocm-systems/projects/hipfile \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
.venv/bin/python -c "import hipfile; print(f\"hipfile {hipfile.__version__} installed successfully\")"
'
- name: Run hipFile Python unit tests
run: |
docker exec \
-t \
-w /ais/rocm-systems/projects/hipfile \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
.venv/bin/python -m pytest python/tests
'
- name: Copy sdist out of the container
run: |
docker cp \
"${AIS_CONTAINER_NAME}:/ais/rocm-systems/projects/hipfile/python/dist/${{ steps.sdist-metadata.outputs.HIPFILE_PYTHON_SDIST_FILENAME }}" \
${GITHUB_WORKSPACE}
- name: Upload hipFile Python sdist as an artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ steps.sdist-metadata.outputs.HIPFILE_PYTHON_SDIST_FILENAME }}
path: ${{ format('{0}/{1}', github.workspace, steps.sdist-metadata.outputs.HIPFILE_PYTHON_SDIST_FILENAME) }}
if-no-files-found: error
retention-days: 1
compression-level: 0
- name: Cleanup & Stop the Docker container
if: ${{ always() }}
run: |
if docker inspect "${AIS_CONTAINER_NAME}" >/dev/null 2>&1; then
docker stop "${AIS_CONTAINER_NAME}"
else
echo "Container ${AIS_CONTAINER_NAME} does not exist; skipping stop"
fi