From fb3c904a89b10a75e2a3a4942ef9aa4820405655 Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Thu, 2 Apr 2026 03:13:37 +0800 Subject: [PATCH] fix: use gh to download planner artifacts --- .../monthly_optimization_planner.yml | 40 ++++++++++++------- ...ly_optimization_planner_workflow_config.py | 3 +- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/.github/workflows/monthly_optimization_planner.yml b/.github/workflows/monthly_optimization_planner.yml index 198e005..e990a3f 100644 --- a/.github/workflows/monthly_optimization_planner.yml +++ b/.github/workflows/monthly_optimization_planner.yml @@ -27,30 +27,42 @@ jobs: uses: actions/checkout@v6 - name: Download upstream AI review artifact + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - python3 scripts/download_ai_review_artifact.py \ + mkdir -p data/input/upstream + gh run download "${{ inputs.upstream_run_id }}" \ --repo "${GITHUB_REPOSITORY}" \ - --run-id "${{ inputs.upstream_run_id }}" \ - --output-dir data/input/upstream \ - --token-env GITHUB_TOKEN - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + --dir data/input/upstream - name: Download downstream AI review artifact + env: + GH_TOKEN: ${{ secrets.CROSS_REPO_GITHUB_TOKEN }} run: | - python3 scripts/download_ai_review_artifact.py \ + mkdir -p data/input/downstream + gh run download "${{ inputs.downstream_run_id }}" \ --repo "${{ inputs.downstream_repo }}" \ - --run-id "${{ inputs.downstream_run_id }}" \ - --output-dir data/input/downstream \ - --token-env CROSS_REPO_GITHUB_TOKEN - env: - CROSS_REPO_GITHUB_TOKEN: ${{ secrets.CROSS_REPO_GITHUB_TOKEN }} + --dir data/input/downstream + + - name: Resolve downloaded artifact paths + id: artifact_paths + run: | + UPSTREAM_DIR=$(find data/input/upstream -mindepth 1 -maxdepth 1 -type d | head -1) + DOWNSTREAM_DIR=$(find data/input/downstream -mindepth 1 -maxdepth 1 -type d | head -1) + if [ -z "${UPSTREAM_DIR}" ] || [ -z "${DOWNSTREAM_DIR}" ]; then + echo "Failed to resolve downloaded artifact directories" >&2 + exit 1 + fi + { + echo "upstream_dir=${UPSTREAM_DIR}" + echo "downstream_dir=${DOWNSTREAM_DIR}" + } >> "${GITHUB_OUTPUT}" - name: Build monthly optimization plan run: | python3 scripts/build_monthly_optimization_plan.py \ - --upstream-review-file data/input/upstream/final_review_payload.json \ - --downstream-review-file data/input/downstream/final_review_payload.json \ + --upstream-review-file "${{ steps.artifact_paths.outputs.upstream_dir }}/final_review_payload.json" \ + --downstream-review-file "${{ steps.artifact_paths.outputs.downstream_dir }}/final_review_payload.json" \ --output-dir data/output/monthly_optimization - name: Append optimization summary diff --git a/tests/test_monthly_optimization_planner_workflow_config.py b/tests/test_monthly_optimization_planner_workflow_config.py index 69518c2..cf9920b 100644 --- a/tests/test_monthly_optimization_planner_workflow_config.py +++ b/tests/test_monthly_optimization_planner_workflow_config.py @@ -18,7 +18,8 @@ def test_planner_workflow_downloads_artifacts_and_posts_issue(self) -> None: self.assertIn("downstream_repo:", workflow) self.assertIn("actions: read", workflow) self.assertIn("CROSS_REPO_GITHUB_TOKEN", workflow) - self.assertIn("download_ai_review_artifact.py", workflow) + self.assertIn("gh run download", workflow) + self.assertIn("Resolve downloaded artifact paths", workflow) self.assertIn("build_monthly_optimization_plan.py", workflow) self.assertIn("post_monthly_optimization_issue.py", workflow) self.assertIn("final_review_payload.json", workflow)