|
| 1 | +#!/bin/bash |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved. |
| 4 | +# |
| 5 | +# Collect environment versions from inside the container and write |
| 6 | +# a GitHub Actions job summary table. Version collection logic lives |
| 7 | +# in collect_versions.py; this script handles container exec + summary. |
| 8 | + |
| 9 | +set -e |
| 10 | + |
| 11 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 12 | + |
| 13 | +GPU_ARG="" |
| 14 | +if [ -n "$GPU_DEVICES" ]; then |
| 15 | + GPU_ARG="--gpus $GPU_DEVICES" |
| 16 | +fi |
| 17 | + |
| 18 | +# Run collect_versions.py inside the container, extract JSON line |
| 19 | +# shellcheck disable=SC2086 |
| 20 | +RAW=$("$SCRIPT_DIR/container_exec.sh" $GPU_ARG "python3 /iris_workspace/.github/scripts/collect_versions.py") |
| 21 | +VERSION_JSON=$(echo "$RAW" | grep '^{' | tail -1) |
| 22 | + |
| 23 | +if [ -z "$VERSION_JSON" ]; then |
| 24 | + echo "[WARN] Failed to collect version info" |
| 25 | + exit 0 |
| 26 | +fi |
| 27 | + |
| 28 | +# Format and print with Python on the host (available on all runners) |
| 29 | +python3 -c " |
| 30 | +import json, sys, os |
| 31 | +
|
| 32 | +d = json.loads(sys.argv[1]) |
| 33 | +
|
| 34 | +def g(k): |
| 35 | + return str(d.get(k, 'unknown')) |
| 36 | +
|
| 37 | +gpu = f\"{g('gpu_name')} ({g('gpu_arch')}) x {g('gpu_count')}\" |
| 38 | +
|
| 39 | +print('============================================') |
| 40 | +print(' Iris CI - Environment Report') |
| 41 | +print('============================================') |
| 42 | +for label, key in [('Driver', 'driver'), ('ROCm', 'rocm'), ('Python', 'python'), |
| 43 | + ('PyTorch', 'torch'), ('HIP', 'hip'), ('Triton', 'triton')]: |
| 44 | + print(f' {label:9s} {g(key)}') |
| 45 | +print(f' {\"GPU\":9s} {gpu}') |
| 46 | +print(f' {\"Kernel\":9s} {g(\"kernel\")}') |
| 47 | +print('============================================') |
| 48 | +
|
| 49 | +summary_path = os.environ.get('GITHUB_STEP_SUMMARY') |
| 50 | +if summary_path: |
| 51 | + with open(summary_path, 'a') as f: |
| 52 | + f.write('### Environment\n\n') |
| 53 | + f.write('| Component | Version |\n') |
| 54 | + f.write('|-----------|--------|\n') |
| 55 | + for label, key in [('Driver', 'driver'), ('ROCm', 'rocm'), ('Python', 'python'), |
| 56 | + ('PyTorch', 'torch'), ('HIP', 'hip'), ('Triton', 'triton')]: |
| 57 | + f.write(f'| {label} | {g(key)} |\n') |
| 58 | + f.write(f'| GPU | {gpu} |\n') |
| 59 | + f.write(f'| Kernel | {g(\"kernel\")} |\n\n') |
| 60 | +" "$VERSION_JSON" |
0 commit comments