|
1 | 1 | name: Router Submission Evaluation |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request_target: |
5 | | - types: [labeled, synchronize, reopened] |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + pr_number: |
| 7 | + description: Pull request number to evaluate |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + base_ref: |
| 11 | + description: Base branch ref for evaluation scripts checkout |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + base_sha: |
| 15 | + description: Base commit SHA for PR diff/evaluation |
| 16 | + required: true |
| 17 | + type: string |
6 | 18 |
|
7 | 19 | jobs: |
8 | 20 | evaluate-router: |
9 | | - if: >- |
10 | | - contains(github.event.pull_request.labels.*.name, 'evaluate-requested') && |
11 | | - ( |
12 | | - github.event.action != 'labeled' || |
13 | | - github.event.label.name == 'evaluate-requested' |
14 | | - ) |
15 | 21 | runs-on: self-hosted |
16 | 22 | permissions: |
17 | 23 | contents: read |
18 | 24 | issues: write |
19 | 25 | checks: write |
20 | 26 | pull-requests: write |
| 27 | + env: |
| 28 | + PR_NUMBER: ${{ inputs.pr_number }} |
| 29 | + BASE_REF: ${{ inputs.base_ref }} |
| 30 | + BASE_SHA: ${{ inputs.base_sha }} |
| 31 | + PR_CHECKOUT_REF: ${{ format('refs/pull/{0}/head', inputs.pr_number) }} |
21 | 32 | steps: |
22 | 33 | - name: Checkout base repository (for evaluation scripts) |
23 | 34 | uses: actions/checkout@v4 |
24 | 35 | with: |
25 | | - ref: ${{ github.event.pull_request.base.ref }} |
| 36 | + ref: ${{ env.BASE_REF }} |
26 | 37 | path: base |
27 | 38 | fetch-depth: 0 |
28 | 39 |
|
29 | 40 | - name: Checkout PR branch (for prediction file only) |
30 | 41 | uses: actions/checkout@v4 |
31 | 42 | with: |
32 | | - ref: ${{ github.event.pull_request.head.sha }} |
| 43 | + ref: ${{ env.PR_CHECKOUT_REF }} |
33 | 44 | path: pr |
34 | 45 | fetch-depth: 0 |
35 | 46 |
|
|
39 | 50 | working-directory: pr |
40 | 51 | run: | |
41 | 52 | set -euo pipefail |
42 | | - BASE_REF="${{ github.event.pull_request.base.ref }}" |
43 | | - BASE_SHA="${{ github.event.pull_request.base.sha }}" |
| 53 | + BASE_REF="${{ env.BASE_REF }}" |
| 54 | + BASE_SHA="${{ env.BASE_SHA }}" |
44 | 55 |
|
45 | 56 | if [[ -z "$BASE_SHA" ]]; then |
46 | 57 | echo "Error: Could not determine PR base SHA" >&2 |
@@ -154,9 +165,9 @@ jobs: |
154 | 165 | ROUTERARENA_DATASET_DIR: ${{ github.workspace }}/dataset |
155 | 166 | run: | |
156 | 167 | set -euo pipefail; trap 'cat evaluation_output.txt' EXIT |
157 | | - BASE_SHA="${{ github.event.pull_request.base.sha }}" |
| 168 | + BASE_SHA="${{ env.BASE_SHA }}" |
158 | 169 | uv run python automation/process_pr_submission.py \ |
159 | | - --pr "${{ github.event.pull_request.number }}" \ |
| 170 | + --pr "${{ env.PR_NUMBER }}" \ |
160 | 171 | --router "${{ steps.detect.outputs.router }}" \ |
161 | 172 | --split "${{ steps.detect.outputs.split }}" \ |
162 | 173 | --base-ref "$BASE_SHA" > evaluation_output.txt 2>&1 |
@@ -206,28 +217,9 @@ jobs: |
206 | 217 | comment += '*Evaluation completed by RouterArena automated workflow*'; |
207 | 218 |
|
208 | 219 | await github.rest.issues.createComment({ |
209 | | - issue_number: context.payload.pull_request.number, |
| 220 | + issue_number: Number('${{ env.PR_NUMBER }}'), |
210 | 221 | owner: context.repo.owner, |
211 | 222 | repo: context.repo.repo, |
212 | 223 | body: comment |
213 | 224 | }); |
214 | 225 | console.log('Successfully posted evaluation results as PR comment'); |
215 | | -
|
216 | | - - name: Remove evaluation label |
217 | | - if: ${{ always() }} |
218 | | - uses: actions/github-script@v7 |
219 | | - with: |
220 | | - script: | |
221 | | - try { |
222 | | - await github.rest.issues.removeLabel({ |
223 | | - owner: context.repo.owner, |
224 | | - repo: context.repo.repo, |
225 | | - issue_number: context.payload.pull_request.number, |
226 | | - name: 'evaluate-requested' |
227 | | - }); |
228 | | - } catch (error) { |
229 | | - // Ignore if label is already removed/missing. |
230 | | - if (error.status !== 404) { |
231 | | - throw error; |
232 | | - } |
233 | | - } |
0 commit comments