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
93 lines
2.9 KiB
Python
93 lines
2.9 KiB
Python
# Copyright Advanced Micro Devices, Inc.
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
"""Unit tests for notify_quartz reporting-workflow path attribution."""
|
|
|
|
import os
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest import mock
|
|
|
|
sys.path.insert(0, os.fspath(Path(__file__).parent.parent))
|
|
|
|
import notify_quartz
|
|
from notify_quartz import _GithubApiResponse, _build_payload, _normalize_reporting_path
|
|
|
|
|
|
class NormalizeReportingPathTest(unittest.TestCase):
|
|
def test_empty_is_passthrough_signal(self):
|
|
self.assertEqual(_normalize_reporting_path(""), "")
|
|
self.assertEqual(_normalize_reporting_path(" "), "")
|
|
|
|
def test_bare_filename(self):
|
|
self.assertEqual(
|
|
_normalize_reporting_path("multi_arch_build_portable_linux.yml"),
|
|
".github/workflows/multi_arch_build_portable_linux.yml",
|
|
)
|
|
|
|
def test_full_workflow_ref_strips_owner_and_ref(self):
|
|
self.assertEqual(
|
|
_normalize_reporting_path(
|
|
"ROCm/TheRock/.github/workflows/build_tarballs.yml@refs/heads/main"
|
|
),
|
|
".github/workflows/build_tarballs.yml",
|
|
)
|
|
|
|
def test_plain_path_passthrough(self):
|
|
self.assertEqual(
|
|
_normalize_reporting_path(".github/workflows/x.yml"),
|
|
".github/workflows/x.yml",
|
|
)
|
|
|
|
|
|
def _run_obj() -> dict:
|
|
return {
|
|
"id": 999,
|
|
"name": "Multi-Arch Release",
|
|
"path": ".github/workflows/multi_arch_release.yml",
|
|
"workflow_id": 1,
|
|
"status": "in_progress",
|
|
}
|
|
|
|
|
|
class BuildPayloadPathOverrideTest(unittest.TestCase):
|
|
def _build(self, reporting_workflow: str) -> dict:
|
|
with (
|
|
mock.patch.dict(os.environ, {"GITHUB_RUN_ID": "999"}),
|
|
mock.patch.object(
|
|
notify_quartz,
|
|
"_github_api_request",
|
|
return_value=_GithubApiResponse(body=_run_obj(), headers={}),
|
|
),
|
|
):
|
|
return _build_payload(
|
|
token="t",
|
|
repo="ROCm/rockrel",
|
|
embedded_inputs={},
|
|
captured_outputs={},
|
|
run_conclusion="",
|
|
run_phase="started",
|
|
reporting_workflow=reporting_workflow,
|
|
)
|
|
|
|
def test_override_sets_child_path_but_keeps_shared_run_id(self):
|
|
payload = self._build("multi_arch_build_portable_linux.yml")
|
|
wr = payload["workflow_run"]
|
|
self.assertEqual(
|
|
wr["path"], ".github/workflows/multi_arch_build_portable_linux.yml"
|
|
)
|
|
# run_id stays the shared entry run -- it links the leaf to its parent.
|
|
self.assertEqual(wr["id"], 999)
|
|
|
|
def test_empty_reporting_keeps_api_path(self):
|
|
payload = self._build("")
|
|
self.assertEqual(
|
|
payload["workflow_run"]["path"],
|
|
".github/workflows/multi_arch_release.yml",
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|