Merge pull request #232 from QuantStrategyLab/auto/qpk-pin-update #641
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.11" | |
| - name: Install dependencies | |
| run: | | |
| set -euo pipefail | |
| python -m pip install --upgrade pip | |
| python -m pip install -e . numpy pandas pytest pytest-cov ruff | |
| - name: Validate dependency constraint refs | |
| run: | | |
| set -euo pipefail | |
| python - <<'PY' | |
| import re | |
| import subprocess | |
| import tempfile | |
| from pathlib import Path | |
| constraint_path = Path("qsl-pins.txt") | |
| if not constraint_path.exists(): | |
| constraint_path = Path("constraints.txt") | |
| print(f"Validating dependency refs from {constraint_path}") | |
| pattern = re.compile( | |
| r"^(?P<package>[A-Za-z0-9_.-]+)\s+@\s+git\+(?P<url>https://github\.com/QuantStrategyLab/[^@]+\.git)@(?P<ref>[A-Za-z0-9_.-]+)\s*$" | |
| ) | |
| failures = [] | |
| for line in constraint_path.read_text(encoding="utf-8").splitlines(): | |
| stripped = line.strip() | |
| if not stripped or stripped.startswith("#"): | |
| continue | |
| match = pattern.match(stripped) | |
| if not match: | |
| continue | |
| package = match.group("package") | |
| url = match.group("url") | |
| ref = match.group("ref") | |
| with tempfile.TemporaryDirectory() as tmp: | |
| subprocess.run(["git", "init", "-q", tmp], check=True) | |
| result = subprocess.run( | |
| ["git", "-C", tmp, "fetch", "--depth=1", "--quiet", url, ref], | |
| text=True, | |
| stdout=subprocess.PIPE, | |
| stderr=subprocess.PIPE, | |
| ) | |
| if result.returncode: | |
| failures.append(f"{package}: cannot fetch {url}@{ref}: {result.stderr.strip()}") | |
| if failures: | |
| raise SystemExit("\n".join(failures)) | |
| print("constraint refs OK") | |
| PY | |
| - name: Run Ruff | |
| run: | | |
| set -euo pipefail | |
| ruff check . | |
| - name: Run unit tests | |
| run: | | |
| set -euo pipefail | |
| PYTHONPATH=src python -m pytest -q --cov --cov-report=term --cov-report=xml tests |