github-actions[bot] commented on code in PR #66272:
URL: https://github.com/apache/doris/pull/66272#discussion_r3681726653


##########
.github/workflows/code-review-runner.yml:
##########
@@ -41,11 +56,85 @@ jobs:
   code-review:
     runs-on: ubuntu-latest
     timeout-minutes: 120
+    if: >-
+      inputs.pr_number != '' ||
+      (
+        github.event_name == 'issue_comment' &&
+        github.event.issue.pull_request &&
+        startsWith(github.event.comment.body, '/review') &&
+        (
+          github.event.comment.author_association == 'MEMBER' ||
+          github.event.comment.author_association == 'OWNER' ||
+          github.event.comment.author_association == 'COLLABORATOR'
+        )
+      )
     steps:
+      - name: Resolve review inputs
+        id: review_inputs
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          EVENT_NAME: ${{ github.event_name }}
+          ISSUE_NUMBER: ${{ github.event.issue.number }}
+          COMMENT_BODY: ${{ github.event.comment.body }}
+          INPUT_PR_NUMBER: ${{ inputs.pr_number }}
+          INPUT_HEAD_SHA: ${{ inputs.head_sha }}
+          INPUT_BASE_SHA: ${{ inputs.base_sha }}
+          INPUT_REVIEW_FOCUS: ${{ inputs.review_focus }}
+          INPUT_MANAGE_STATUS: ${{ inputs.manage_status }}
+          REPO: ${{ github.repository }}
+        run: |
+          if [ -n "$INPUT_PR_NUMBER" ]; then
+            PR_NUMBER="$INPUT_PR_NUMBER"
+            HEAD_SHA="$INPUT_HEAD_SHA"
+            BASE_SHA="$INPUT_BASE_SHA"
+            REVIEW_FOCUS="$INPUT_REVIEW_FOCUS"
+            MANAGE_STATUS="$INPUT_MANAGE_STATUS"
+          elif [ "$EVENT_NAME" = "issue_comment" ]; then
+            PR_NUMBER="$ISSUE_NUMBER"
+            PR_JSON="$(gh api "repos/${REPO}/pulls/${PR_NUMBER}")"
+            HEAD_SHA="$(jq -er '.head.sha' <<<"$PR_JSON")"
+            BASE_SHA="$(jq -er '.base.sha' <<<"$PR_JSON")"
+            REVIEW_FOCUS="$(printf '%s' "${COMMENT_BODY#'/review'}" |
+              python3 -c 'import sys; 
sys.stdout.write(sys.stdin.read().lstrip())')"
+            MANAGE_STATUS=true
+          else
+            echo "Review inputs are unavailable for event '$EVENT_NAME'." >&2
+            exit 1
+          fi
+
+          test -n "$PR_NUMBER"
+          test -n "$HEAD_SHA"
+          test -n "$BASE_SHA"
+
+          echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
+          echo "head_sha=$HEAD_SHA" >> "$GITHUB_OUTPUT"
+          echo "base_sha=$BASE_SHA" >> "$GITHUB_OUTPUT"
+          echo "manage_status=$MANAGE_STATUS" >> "$GITHUB_OUTPUT"
+          focus_delimiter="review_focus_${RANDOM}_${RANDOM}"
+          {
+            echo "review_focus<<${focus_delimiter}"
+            printf '%s\n' "$REVIEW_FOCUS"
+            echo "${focus_delimiter}"
+          } >> "$GITHUB_OUTPUT"
+
+      - name: Mark Code Review status as pending
+        if: ${{ steps.review_inputs.outputs.manage_status == 'true' }}
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          HEAD_SHA: ${{ steps.review_inputs.outputs.head_sha }}
+          REPO: ${{ github.repository }}
+        run: |
+          gh api "repos/${REPO}/statuses/${HEAD_SHA}" \

Review Comment:
   Input-based runs reach this status write before the later authoritative PR 
tuple check. Because `workflow_dispatch` defaults `manage_status` to true, a 
mixed input such as PR A plus PR B's valid head SHA immediately overwrites PR 
B's `code-review` context with `pending`; checkout can succeed and only the 
later `live_pr` comparison rejects the mismatch, after which the terminal step 
writes `pending` there again. Please verify or derive the declared PR's live 
head/base before either status POST so a failed dispatch cannot block an 
unrelated PR without reviewing it.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to