Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ jobs:
python -m pip install --no-deps -e external/QuantPlatformKit -e external/UsEquityStrategies

- name: Run ruff

- name: Check QPK pin consistency
run: python scripts/check_qpk_pin_consistency.py
continue-on-error: true
run: |
set -euo pipefail
ruff check .
Expand Down
42 changes: 42 additions & 0 deletions scripts/check_qpk_pin_consistency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
"""Check that all QPK git references match the canonical QPK_PIN.
Usage: python scripts/check_qpk_pin_consistency.py [--fix]
"""
import re, subprocess, sys
from pathlib import Path

QPK_PIN_URL = "https://raw.githubusercontent.com/QuantStrategyLab/QuantPlatformKit/main/QPK_PIN"
SHA_RE = re.compile(r"@([a-f0-9]{40})")

def fetch_pin() -> str:
import urllib.request
with urllib.request.urlopen(QPK_PIN_URL, timeout=10) as r:
sha = r.read().decode().strip().split()[0]
if len(sha) == 40: return sha
raise RuntimeError(f"Invalid QPK_PIN: {sha}")

def main():
fix = "--fix" in sys.argv
target = fetch_pin()
print(f"QPK_PIN: {target[:12]}...")
errors = 0
for path in sorted(Path.cwd().glob("**/requirements*.txt")) + sorted(Path.cwd().glob("**/pyproject.toml")):
if "external" in str(path): continue
content = path.read_text()
for m in SHA_RE.finditer(content):
sha = m.group(1)
if "QuantPlatformKit" not in content[max(0,m.start()-200):m.end()]: continue
if sha != target:
errors += 1
print(f" ❌ {path}: QPK@{sha[:12]} (expected {target[:12]})")
if fix:
path.write_text(content.replace(sha, target))
print(f" → fixed")
if errors:
print(f"\n{errors} mismatch(es). Run with --fix to auto-fix.")
return 1
print("✅ All QPK pins match.")
return 0

if __name__ == "__main__":
raise SystemExit(main())
Loading