1616 if : github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
1717 runs-on : ubuntu-latest
1818 timeout-minutes : 30
19+ outputs :
20+ snapshot_repository_ref : ${{ steps.snapshot-input.outputs.snapshot_repository_ref }}
1921 steps :
2022 - name : Checkout
2123 uses : actions/checkout@v6
2426 uses : actions/checkout@v6
2527 with :
2628 repository : QuantStrategyLab/QuantPlatformKit
27- ref : 9bb8f31e898ea238a6446472f9f5e58133128d0c
29+ ref : bda6afdab0a2dd693c35d14493176829f4da1231
2830 path : external/QuantPlatformKit
2931
3032 - name : Set up Python
4042 python -m pip install --no-deps -e external/QuantPlatformKit
4143
4244 - name : Download latest trusted lifecycle inputs
45+ id : snapshot-input
4346 env :
4447 GH_TOKEN : ${{ secrets.SNAPSHOT_REPOSITORY_TOKEN }}
4548 INPUT_ROOT : ${{ runner.temp }}/crypto-lifecycle-inputs
@@ -62,17 +65,24 @@ jobs:
6265 pages = json.loads((Path(os.environ["RUNNER_TEMP"]) / "snapshot-artifacts.json").read_text())
6366 run_pages = json.loads((Path(os.environ["RUNNER_TEMP"]) / "trusted-snapshot-runs.json").read_text())
6467 artifacts = [item for page in pages for item in page.get("artifacts", [])]
65- trusted_run_ids = {run["id"] for page in run_pages for run in page.get("workflow_runs", [])}
66- candidates = [
67- item for item in artifacts
68- if not item.get("expired")
69- and str(item.get("name", "")).startswith("crypto-lifecycle-inputs-")
70- and item.get("workflow_run", {}).get("head_branch") == "main"
71- and item.get("workflow_run", {}).get("id") in trusted_run_ids
72- ]
73- if not candidates:
68+ trusted_runs = [run for page in run_pages for run in page.get("workflow_runs", [])]
69+ selected = None
70+ for run in sorted(
71+ trusted_runs,
72+ key=lambda item: (item.get("run_number", 0), item.get("run_attempt", 0)),
73+ reverse=True,
74+ ):
75+ matches = [
76+ item for item in artifacts
77+ if not item.get("expired")
78+ and str(item.get("name", "")).startswith("crypto-lifecycle-inputs-")
79+ and item.get("workflow_run", {}).get("id") == run["id"]
80+ ]
81+ if matches:
82+ selected = max(matches, key=lambda item: item["created_at"])
83+ break
84+ if selected is None:
7485 raise SystemExit("no trusted crypto lifecycle input artifact is available")
75- selected = max(candidates, key=lambda item: item["created_at"])
7686 print(selected["id"], selected["workflow_run"]["id"])
7787 PY
7888 read -r artifact_id workflow_run_id < "${RUNNER_TEMP}/snapshot-artifact-selection.txt"
@@ -94,6 +104,19 @@ jobs:
94104 if mismatches:
95105 raise SystemExit(f"lifecycle input provenance check failed: {mismatches}")
96106 PY
107+ snapshot_repository_ref="$(python - <<'PY'
108+ import json
109+ import os
110+ from pathlib import Path
111+ run = json.loads((Path(os.environ["RUNNER_TEMP"]) / "snapshot-workflow-run.json").read_text())
112+ print(run["head_sha"])
113+ PY
114+ )"
115+ if [[ ! "${snapshot_repository_ref}" =~ ^[0-9a-f]{40}$ ]]; then
116+ echo "::error::Invalid snapshot producer head SHA"
117+ exit 1
118+ fi
119+ echo "snapshot_repository_ref=${snapshot_repository_ref}" >> "${GITHUB_OUTPUT}"
97120 gh api "/repos/QuantStrategyLab/CryptoLivePoolPipelines/actions/artifacts/${artifact_id}/zip" \
98121 > "${RUNNER_TEMP}/snapshot-artifact.zip"
99122 python - <<'PY'
@@ -176,15 +199,16 @@ jobs:
176199 contents : read
177200 issues : write
178201 id-token : write
179- uses : QuantStrategyLab/QuantPlatformKit/.github/workflows/reusable-drift-check.yml@9bb8f31e898ea238a6446472f9f5e58133128d0c
202+ uses : QuantStrategyLab/QuantPlatformKit/.github/workflows/reusable-drift-check.yml@bda6afdab0a2dd693c35d14493176829f4da1231
180203 with :
181204 strategy_domain : crypto
182205 caller_event_name : ${{ github.event_name }}
183206 caller_pr_head_repository : ${{ github.event.pull_request.head.repo.full_name || '' }}
184207 snapshot_repository : QuantStrategyLab/CryptoLivePoolPipelines
185208 snapshot_checkout_path : external/CryptoLivePoolPipelines
209+ snapshot_repository_ref : ${{ needs.preflight_backtests.outputs.snapshot_repository_ref }}
186210 ai_gateway_service_url : ${{ vars.AI_GATEWAY_SERVICE_URL }}
187- quant_platform_kit_ref : 9bb8f31e898ea238a6446472f9f5e58133128d0c
211+ quant_platform_kit_ref : bda6afdab0a2dd693c35d14493176829f4da1231
188212 lifecycle_preflight_artifact : lifecycle-preflight-${{ github.run_id }}-${{ github.run_attempt }}
189213 secrets :
190214 codex_audit_service_url : ${{ secrets.CODEX_AUDIT_SERVICE_URL }}
0 commit comments