This is an automated email from the ASF dual-hosted git repository.

mrhhsg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 1323628bf99 [fix](build) Allow TeamCity comment triggers on draft PRs 
(#70605)
1323628bf99 is described below

commit 1323628bf9985cd35fdea3e8524d09a8a551a86a
Author: Dongyang Li <[email protected]>
AuthorDate: Mon Nov 16 14:31:27 2026 +0800

    [fix](build) Allow TeamCity comment triggers on draft PRs (#70605)
    
    ### Background
    
    PR comment commands use a shared TeamCity helper to verify the PR before
    submitting builds or writing file-filter skip statuses.
    
    ### What problem does this PR solve?
    
    Issue Number: None
    Related PR: #70459 (introduced the draft restriction), #70515 (retained
    it)
    PR Type: Bugfix
    
    Problem Summary:
    Authorized `run buildall` and individual commands fail on open draft
    PRs, including when a lane should only write a skip status. Allow draft
    PRs through the shared gate while retaining the open-state, exact head
    and target-branch checks.
    
    ### Details
    
    - **Frequency:** Every comment-triggered build or skip for a draft PR.
    - **Root cause:** The common PR identity check also required `draft ==
    false`.
    - **Why existing tests missed it:** Existing dispatch tests replaced the
    PR check with a freshness stub.
    - **Fix:** Remove only the draft predicate. New tests exercise the real
    PR predicate for both enqueue and skip paths.
    - **Other paths and branches:** The shared helper covers all supported
    comment-triggered lanes and branches. Workflow commenter authorization
    and file filters are unchanged.
    
    ### Testing
    
    - `python3
    regression-test/pipeline/common/tests/test_teamcity_utils.py`: 29 tests
    passed locally.
    - The new draft acceptance test fails against the original predicate.
    - Negative coverage verifies closed PRs, changed heads and changed
    target branches cannot enqueue builds or write skip statuses.
    - `bash -n regression-test/pipeline/common/teamcity-utils.sh` and `git
    diff --check` passed.
    - No live CI rerun performed for this change.
    
    ### Release note
    
    None.
    
    ### Check List (For Author)
    
    - Behavior changed: Yes (open draft PRs accept authorized comment
    triggers).
    - Does this need documentation: No.
    - Pre-submission status: Ready.
    
    ### AI Disclosure
    
    - Tool: OpenAI Codex.
    - Generated: Code change, tests and PR description.
    - Human review: Pending.
---
 regression-test/pipeline/common/teamcity-utils.sh  |  2 +-
 .../pipeline/common/tests/test_teamcity_utils.py   | 32 ++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/regression-test/pipeline/common/teamcity-utils.sh 
b/regression-test/pipeline/common/teamcity-utils.sh
index de0c962be94..195efda8904 100644
--- a/regression-test/pipeline/common/teamcity-utils.sh
+++ b/regression-test/pipeline/common/teamcity-utils.sh
@@ -56,7 +56,7 @@ teamcity_current_pr() {
         -H "Authorization: Bearer ${GITHUB_TOKEN:?}" \
         "https://api.github.com/repos/apache/doris/pulls/${PULL_REQUEST_NUM}"; |
         jq -e --arg head "$COMMIT_ID_FROM_TRIGGER" --arg branch 
"$PULL_REQUEST_TARGET_BRANCH" \
-            '.state=="open" and .draft==false and .head.sha==$head and 
.base.ref==$branch' >/dev/null
+            '.state=="open" and .head.sha==$head and .base.ref==$branch' 
>/dev/null
 }
 
 teamcity_current_root() {
diff --git a/regression-test/pipeline/common/tests/test_teamcity_utils.py 
b/regression-test/pipeline/common/tests/test_teamcity_utils.py
index d7247f36232..a98ea2d0ac6 100644
--- a/regression-test/pipeline/common/tests/test_teamcity_utils.py
+++ b/regression-test/pipeline/common/tests/test_teamcity_utils.py
@@ -114,6 +114,38 @@ curl(){ python3 "$FIXTURE_ROOT/status_mock.py" "$@"; }
         self.assertEqual(self.skipped_contexts(), ['TeamCity/feut'])
         self.assertFalse(self.state().get('posts'))
 
+    def run_with_pr(self, pr, changed):
+        prefix = '''teamcity_request(){ python3 "$FIXTURE_ROOT/mock.py" "$@"; }
+curl(){
+    if [[ "$*" == *'/pulls/123'* ]]; then
+        printf '%s\\n' "$MOCK_PR";
+    else
+        python3 "$FIXTURE_ROOT/status_mock.py" "$@";
+    fi
+}
+'''
+        return self.run_shell(prefix + 'trigger_or_skip_build ' + changed + ' 
123 master ' + HEAD + ' feut 1',
+                              mock=False, check=False, env={'MOCK_PR': 
json.dumps(pr)})
+
+    def test_draft_pr_can_trigger_and_skip(self):
+        pr = {'state': 'open', 'draft': True, 'head': {'sha': HEAD}, 'base': 
{'ref': 'master'}}
+        result = self.run_with_pr(pr, 'true')
+        self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
+        self.assertEqual(len(self.state()['posts']), 1)
+        result = self.run_with_pr(pr, 'false')
+        self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
+        self.assertEqual(self.skipped_contexts(), ['TeamCity/feut'])
+
+    def test_closed_or_changed_draft_pr_cannot_trigger_or_skip(self):
+        for change in [{'state': 'closed'}, {'head': {'sha': 'b' * 40}}, 
{'base': {'ref': 'branch-4.2'}}]:
+            for changed in ['true', 'false']:
+                with self.subTest(change=change, changed=changed):
+                    pr = {'state': 'open', 'draft': True, 'head': {'sha': 
HEAD}, 'base': {'ref': 'master'}, **change}
+                    result = self.run_with_pr(pr, changed)
+                    self.assertNotEqual(result.returncode, 0)
+                    self.assertFalse(self.state().get('posts'))
+                    self.assertFalse(self.skipped_contexts())
+
     def test_compile_skip_covers_downstream_checks(self):
         self.run_shell('trigger_or_skip_build false 123 master ' + HEAD + ' 
compile 1')
         self.assertEqual(self.skipped_contexts(), ['TeamCity/compile', 
'TeamCity/p0', 'TeamCity/cloud_p0',


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

Reply via email to