Files
TheRock/rocm-libraries/.github/scripts/check_wheel_freshness.py
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

89 lines
2.7 KiB
Python

# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
# SPDX-License-Identifier: MIT
"""Fail CI when the installed ROCm nightly wheels are too old.
Multi-arch nightly wheels are versioned like ``7.15.0a20260709`` where the
trailing eight digits after the alpha marker encode the build date
(``YYYYMMDD``). A stalled or broken nightly index would silently keep serving an
old build, so we parse that date from the installed package metadata and fail
when it is older than the allowed age. This turns "the nightly stopped
publishing" from a mystery into a loud CI failure.
"""
import argparse
import re
import sys
from datetime import datetime, timezone
from importlib.metadata import PackageNotFoundError, version
# Matches an 8-digit YYYYMMDD run; the nightly date is the last such group in a
# version like "7.15.0a20260709".
_DATE_RE = re.compile(r"(\d{8})")
def parse_build_date(pkg_version):
"""Return the build ``date`` encoded in a nightly wheel version, or None."""
for match in reversed(_DATE_RE.findall(pkg_version)):
try:
return datetime.strptime(match, "%Y%m%d").date()
except ValueError:
continue
return None
def main():
p = argparse.ArgumentParser(description=__doc__)
p.add_argument(
"--package",
default="rocm-sdk-core",
help="Installed distribution to inspect (default: rocm-sdk-core)",
)
p.add_argument(
"--max-age-days",
type=int,
default=14,
help="Fail if the wheel build date is older than this many days",
)
args = p.parse_args()
try:
pkg_version = version(args.package)
except PackageNotFoundError:
print(
f"ERROR: package '{args.package}' is not installed; cannot check "
"wheel freshness.",
file=sys.stderr,
)
return 1
build_date = parse_build_date(pkg_version)
if build_date is None:
print(
f"ERROR: could not parse a build date from '{args.package}' version "
f"'{pkg_version}'.",
file=sys.stderr,
)
return 1
today = datetime.now(timezone.utc).date()
age_days = (today - build_date).days
print(
f"{args.package}=={pkg_version} built {build_date.isoformat()} "
f"({age_days} day(s) old, threshold {args.max_age_days})"
)
if age_days > args.max_age_days:
print(
f"ERROR: ROCm nightly wheels are {age_days} days old, which exceeds "
f"the {args.max_age_days}-day threshold. The nightly index may be "
"stale or broken.",
file=sys.stderr,
)
return 1
return 0
if __name__ == "__main__":
sys.exit(main())