|
1 | 1 | name: Router Submission Evaluation |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request_target: |
5 | | - types: [opened, synchronize, reopened] |
6 | | - paths: |
7 | | - - "router_inference/predictions/**" |
| 4 | + issue_comment: |
| 5 | + types: [created] |
8 | 6 |
|
9 | 7 | jobs: |
10 | 8 | evaluate-router: |
| 9 | + if: >- |
| 10 | + github.event.issue.pull_request && |
| 11 | + startsWith(github.event.comment.body, '/evaluate') && |
| 12 | + ( |
| 13 | + github.event.comment.author_association == 'OWNER' || |
| 14 | + github.event.comment.author_association == 'MEMBER' || |
| 15 | + github.event.comment.author_association == 'COLLABORATOR' |
| 16 | + ) |
11 | 17 | runs-on: self-hosted |
12 | 18 | permissions: |
13 | 19 | contents: read |
14 | 20 | pull-requests: write |
15 | 21 | steps: |
| 22 | + - name: Acknowledge /evaluate command |
| 23 | + uses: actions/github-script@v7 |
| 24 | + with: |
| 25 | + script: | |
| 26 | + await github.rest.reactions.createForIssueComment({ |
| 27 | + owner: context.repo.owner, |
| 28 | + repo: context.repo.repo, |
| 29 | + comment_id: context.payload.comment.id, |
| 30 | + content: 'eyes' |
| 31 | + }); |
| 32 | +
|
| 33 | + - name: Fetch PR details |
| 34 | + id: pr |
| 35 | + uses: actions/github-script@v7 |
| 36 | + with: |
| 37 | + script: | |
| 38 | + const pr = await github.rest.pulls.get({ |
| 39 | + owner: context.repo.owner, |
| 40 | + repo: context.repo.repo, |
| 41 | + pull_number: context.payload.issue.number |
| 42 | + }); |
| 43 | + core.setOutput('head_sha', pr.data.head.sha); |
| 44 | + core.setOutput('base_ref', pr.data.base.ref); |
| 45 | + core.setOutput('base_sha', pr.data.base.sha); |
| 46 | + core.setOutput('number', pr.data.number); |
| 47 | +
|
16 | 48 | - name: Checkout base repository (for evaluation scripts) |
17 | 49 | uses: actions/checkout@v4 |
18 | 50 | with: |
19 | | - ref: ${{ github.event.pull_request.base.ref }} |
| 51 | + ref: ${{ steps.pr.outputs.base_ref }} |
20 | 52 | path: base |
21 | 53 | fetch-depth: 0 |
22 | 54 |
|
23 | 55 | - name: Checkout PR branch (for prediction file only) |
24 | 56 | uses: actions/checkout@v4 |
25 | 57 | with: |
26 | | - ref: ${{ github.event.pull_request.head.sha }} |
| 58 | + ref: ${{ steps.pr.outputs.head_sha }} |
27 | 59 | path: pr |
28 | 60 | fetch-depth: 0 |
29 | 61 |
|
|
35 | 67 | set -euo pipefail |
36 | 68 | # Compare against the upstream base branch |
37 | 69 | # This ensures each router submission is evaluated independently |
38 | | - BASE_REF="${{ github.event.pull_request.base.ref }}" |
39 | | - BASE_SHA="${{ github.event.pull_request.base.sha }}" |
| 70 | + BASE_REF="${{ steps.pr.outputs.base_ref }}" |
| 71 | + BASE_SHA="${{ steps.pr.outputs.base_sha }}" |
40 | 72 |
|
41 | 73 | if [[ -z "$BASE_SHA" ]]; then |
42 | 74 | echo "Error: Could not determine PR base SHA" >&2 |
@@ -158,9 +190,9 @@ jobs: |
158 | 190 | run: | |
159 | 191 | set -euo pipefail; trap 'cat evaluation_output.txt' EXIT |
160 | 192 | # Uses base repo's evaluation script (safe - not from PR) |
161 | | - BASE_SHA="${{ github.event.pull_request.base.sha }}" |
| 193 | + BASE_SHA="${{ steps.pr.outputs.base_sha }}" |
162 | 194 | uv run python automation/process_pr_submission.py \ |
163 | | - --pr "${{ github.event.pull_request.number }}" \ |
| 195 | + --pr "${{ steps.pr.outputs.number }}" \ |
164 | 196 | --router "${{ steps.detect.outputs.router }}" \ |
165 | 197 | --split "${{ steps.detect.outputs.split }}" \ |
166 | 198 | --base-ref "$BASE_SHA" > evaluation_output.txt 2>&1 |
@@ -213,9 +245,21 @@ jobs: |
213 | 245 |
|
214 | 246 | // Post comment to PR |
215 | 247 | await github.rest.issues.createComment({ |
216 | | - issue_number: context.payload.pull_request.number, |
| 248 | + issue_number: context.payload.issue.number, |
217 | 249 | owner: context.repo.owner, |
218 | 250 | repo: context.repo.repo, |
219 | 251 | body: comment |
220 | 252 | }); |
221 | 253 | console.log('Successfully posted evaluation results as PR comment'); |
| 254 | +
|
| 255 | + - name: React with success |
| 256 | + if: ${{ steps.detect.outputs.router != '' && steps.evaluate.outcome == 'success' }} |
| 257 | + uses: actions/github-script@v7 |
| 258 | + with: |
| 259 | + script: | |
| 260 | + await github.rest.reactions.createForIssueComment({ |
| 261 | + owner: context.repo.owner, |
| 262 | + repo: context.repo.repo, |
| 263 | + comment_id: context.payload.comment.id, |
| 264 | + content: 'rocket' |
| 265 | + }); |
0 commit comments