54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
"""Vendored upstream Skills stay byte-for-byte what VENDOR.md says they are."""
|
|
|
|
import hashlib
|
|
from pathlib import Path
|
|
|
|
from app.skills.agent_skills import discover_skills
|
|
|
|
VENDOR_DIR = Path(__file__).parents[1] / "skills" / "vendor" / "google"
|
|
PINNED_COMMIT = "81a31a6e4300425598a69fd96c8e843c947ae308"
|
|
EXPECTED_SKILLS = {
|
|
"google-cloud-solution-architecture",
|
|
"google-cloud-waf-security",
|
|
"google-cloud-waf-reliability",
|
|
"google-cloud-waf-cost-optimization",
|
|
"google-cloud-waf-operational-excellence",
|
|
"google-cloud-waf-performance-optimization",
|
|
"google-cloud-waf-sustainability",
|
|
}
|
|
|
|
|
|
def read_checksums() -> dict[str, str]:
|
|
entries = {}
|
|
for line in (VENDOR_DIR / "SHA256SUMS").read_text(encoding="utf-8").splitlines():
|
|
digest, relative_path = line.split(maxsplit=1)
|
|
entries[relative_path] = digest
|
|
return entries
|
|
|
|
|
|
def test_vendor_record_names_pinned_commit_and_licence():
|
|
vendor_md = (VENDOR_DIR / "VENDOR.md").read_text(encoding="utf-8")
|
|
|
|
assert f"`{PINNED_COMMIT}`" in vendor_md
|
|
assert "Apache License" in (VENDOR_DIR / "LICENSE").read_text(encoding="utf-8")
|
|
|
|
|
|
def test_checksums_cover_every_vendored_file_and_match():
|
|
checksums = read_checksums()
|
|
on_disk = {
|
|
path.relative_to(VENDOR_DIR).as_posix()
|
|
for path in VENDOR_DIR.rglob("*")
|
|
if path.is_file() and path.name not in {"SHA256SUMS", "VENDOR.md"}
|
|
}
|
|
|
|
assert set(checksums) == on_disk
|
|
for relative_path, digest in checksums.items():
|
|
actual = hashlib.sha256((VENDOR_DIR / relative_path).read_bytes()).hexdigest()
|
|
assert actual == digest, f"{relative_path} differs from vendored upstream"
|
|
|
|
|
|
def test_expected_upstream_skills_are_present_and_valid():
|
|
skills = discover_skills([VENDOR_DIR])
|
|
|
|
assert set(skills) == EXPECTED_SKILLS
|