From f7cfa60ee1a95733e5c0a603fda50dbf90fee7d6 Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Thu, 2 Apr 2026 05:34:48 +0800 Subject: [PATCH] fix: bootstrap experiment validation runs --- .github/workflows/experiment_validation.yml | 7 ++++ .../monthly_optimization_planner.yml | 38 +++++++++++++++++++ ...t_experiment_validation_workflow_config.py | 1 + ...ly_optimization_planner_workflow_config.py | 2 + 4 files changed, 48 insertions(+) diff --git a/.github/workflows/experiment_validation.yml b/.github/workflows/experiment_validation.yml index 9eed929..8da3486 100644 --- a/.github/workflows/experiment_validation.yml +++ b/.github/workflows/experiment_validation.yml @@ -16,6 +16,8 @@ jobs: permissions: contents: read issues: write + env: + DOWNLOAD_TOP_LIQUID: ${{ vars.DOWNLOAD_TOP_LIQUID || '90' }} steps: - name: Checkout @@ -92,6 +94,11 @@ jobs: cat data/output/experiment_validation/skip_reason.txt >> "$GITHUB_STEP_SUMMARY" fi + - name: Download raw history for experiment validation + if: steps.experiment_payload.outputs.should_run == 'true' + run: | + python3 scripts/download_history.py --top-liquid "${DOWNLOAD_TOP_LIQUID}" --force-exchange-info + - name: Run monthly shadow build if: steps.experiment_payload.outputs.should_run == 'true' && steps.experiment_payload.outputs.run_shadow_build == 'true' run: | diff --git a/.github/workflows/monthly_optimization_planner.yml b/.github/workflows/monthly_optimization_planner.yml index e03a0f7..7c7e6c1 100644 --- a/.github/workflows/monthly_optimization_planner.yml +++ b/.github/workflows/monthly_optimization_planner.yml @@ -189,6 +189,44 @@ jobs: gh workflow run experiment_validation.yml \ -f issue_number="${{ steps.upstream_experiment_target.outputs.issue_number }}" + - name: Resolve downstream experiment validation target + id: downstream_experiment_target + run: | + python3 - <<'PY' + import json + import os + from pathlib import Path + + fanout = json.loads( + Path("data/output/monthly_optimization/fanout/binance_platform.json").read_text(encoding="utf-8") + ) + plan = json.loads( + Path("data/output/monthly_optimization/optimization_plan.json").read_text(encoding="utf-8") + ) + actions = plan.get("repo_action_summary", {}).get("BinancePlatform", {}).get("actions", []) + should_dispatch = bool(fanout.get("issue_number")) and fanout.get("status") in {"created", "updated"} and any( + action.get("experiment_only") for action in actions + ) + with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output: + print(f"should_dispatch={'true' if should_dispatch else 'false'}", file=output) + print(f"issue_number={fanout.get('issue_number') or ''}", file=output) + PY + + - name: Dispatch BinancePlatform experiment validation + if: steps.downstream_experiment_target.outputs.should_dispatch == 'true' + env: + GH_TOKEN: ${{ secrets.CROSS_REPO_GITHUB_TOKEN }} + run: | + set +e + gh workflow run experiment_validation.yml \ + -R "${{ inputs.downstream_repo }}" \ + -f issue_number="${{ steps.downstream_experiment_target.outputs.issue_number }}" + status=$? + set -e + if [ "$status" -ne 0 ]; then + echo "Downstream experiment validation dispatch skipped: CROSS_REPO_GITHUB_TOKEN likely needs Actions write on ${{ inputs.downstream_repo }}." >> "$GITHUB_STEP_SUMMARY" + fi + - name: Upload planner artifact uses: actions/upload-artifact@v7 with: diff --git a/tests/test_experiment_validation_workflow_config.py b/tests/test_experiment_validation_workflow_config.py index 4e4a814..5f555a7 100644 --- a/tests/test_experiment_validation_workflow_config.py +++ b/tests/test_experiment_validation_workflow_config.py @@ -16,6 +16,7 @@ def test_workflow_runs_shadow_build_and_posts_comment(self) -> None: self.assertIn("workflow_dispatch:", workflow) self.assertIn("issue_number:", workflow) self.assertIn("prepare_experiment_validation.py", workflow) + self.assertIn("download_history.py", workflow) self.assertIn("run_monthly_shadow_build.py", workflow) self.assertIn("run_walkforward_validation.py", workflow) self.assertIn("render_experiment_validation_summary.py", workflow) diff --git a/tests/test_monthly_optimization_planner_workflow_config.py b/tests/test_monthly_optimization_planner_workflow_config.py index 87b44de..5233455 100644 --- a/tests/test_monthly_optimization_planner_workflow_config.py +++ b/tests/test_monthly_optimization_planner_workflow_config.py @@ -31,6 +31,8 @@ def test_planner_workflow_downloads_artifacts_posts_issue_and_fans_out_tasks(sel self.assertIn("Fan out BinancePlatform task issue", workflow) self.assertIn("Resolve upstream experiment validation target", workflow) self.assertIn("Dispatch CryptoLeaderRotation experiment validation", workflow) + self.assertIn("Resolve downstream experiment validation target", workflow) + self.assertIn("Dispatch BinancePlatform experiment validation", workflow) self.assertIn("gh workflow run experiment_validation.yml", workflow) self.assertIn("--allow-permission-skip", workflow) self.assertIn("Append fanout summary", workflow)