mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-14 18:39:54 +08:00
- dev 构建改为优先使用已发布 driver release 对应源码提交作为检测基线 - 避免驱动相关提交的 CI 失败后,后续仅修 workflow 时被误判为无需重建驱动 - 当已发布驱动基线无法解析时,保守回退为全量驱动构建 - 补充驱动变更检测补偿场景回归测试 - 新增 driver release source 解析测试,覆盖 release body 与 target_commitish 场景
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import importlib.util
|
|
import pathlib
|
|
import unittest
|
|
|
|
|
|
MODULE_PATH = pathlib.Path(__file__).with_name("resolve-driver-release-source.py")
|
|
SPEC = importlib.util.spec_from_file_location("resolve_driver_release_source", MODULE_PATH)
|
|
MODULE = importlib.util.module_from_spec(SPEC)
|
|
assert SPEC.loader is not None
|
|
SPEC.loader.exec_module(MODULE)
|
|
|
|
|
|
class ResolveDriverReleaseSourceTests(unittest.TestCase):
|
|
def test_extracts_commit_from_release_body_link(self):
|
|
commit = "a" * 40
|
|
release = {
|
|
"body": (
|
|
f"GoNavi dev driver-agent assets.\n\n"
|
|
f"**提交**: [`{commit}`](https://github.com/Syngnat/GoNavi/commit/{commit})"
|
|
)
|
|
}
|
|
self.assertEqual(MODULE.extract_source_commit(release), commit)
|
|
|
|
def test_extracts_commit_from_plain_body_sha(self):
|
|
commit = "b" * 40
|
|
release = {"body": f"source commit: {commit}"}
|
|
self.assertEqual(MODULE.extract_source_commit(release), commit)
|
|
|
|
def test_falls_back_to_full_sha_target_commitish(self):
|
|
commit = "c" * 40
|
|
release = {"target_commitish": commit}
|
|
self.assertEqual(MODULE.extract_source_commit(release), commit)
|
|
|
|
def test_ignores_branch_name_target_commitish(self):
|
|
release = {"body": "", "target_commitish": "main"}
|
|
self.assertIsNone(MODULE.extract_source_commit(release))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|