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

hello-stephen 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 ae7efba35e7 [chore](ci) Report large added files in Code Style on 
master (#71301)
ae7efba35e7 is described below

commit ae7efba35e7fe8be2c1f633ef6abf5c6b802f1f2
Author: shuke <[email protected]>
AuthorDate: Wed Dec 2 20:12:22 2026 +0800

    [chore](ci) Report large added files in Code Style on master (#71301)
    
    ### Background
    
    Doris starts a separate event resolver and a large-file job to warn
    contributors about new files. In a December 2 sample, the warning job's
    queue P95 was nearly 24 minutes. Its file-list, size and reporting steps
    together averaged eight seconds.
    
    ### What problem does this PR solve?
    
    Issue Number: None
    Related PR: #71294 (master Code Style), #70832 (PR event relay)
    PR Type: Build/CI/Chore
    
    Problem Summary: Run the size check before checkout in the existing
    master Code Style job. Adding a file larger than 1 MiB produces a
    warning with the filename and byte count in the Actions summary. A
    shared PR event resolver still dispatches review-status updates and
    sends eligible non-master events to the existing comment job.
    
    ### Details
    
    - **Affected:** GitHub Actions on Ubuntu for pull requests targeting
    master and the trusted PR event dispatcher on the default branch.
    - **Developer and release impact:** Master PR authors see large-file
    warnings in Code Style, including for documentation-only changes.
    Release branches keep their existing checks and require no backports.
    Review comments and dismissals retain their handlers.
    - **License and third-party:** None.
    - **Rollback:** Revert this PR to restore the separate resolver and
    commenter on master.
    - **CI permissions and secrets:** Code Style uses its existing read-only
    token. The trusted dispatcher grants write permissions only to the jobs
    that publish review status or post the non-master warning.
    - **Behavior change:** Only newly added files strictly over 1,048,576
    bytes are flagged. A truncated compare falls back to comparing the exact
    Git commits. An incomplete size lookup is reported without blocking
    style checks or the merge.
    
    ### Testing
    
    Actionlint passed on all four changed workflows. All 61 tests in the
    four resolver, checkout, API and status suites passed, including master
    and fork/release routing. Thirteen style-selection cases passed,
    including four historical PR snapshots. Two local Git comparisons each
    examined 3,002 additions, flagged the last large file and excluded a
    rename. Read-only GitHub API checks verified PR #71294 and a
    1,183,086-byte repository blob. The non-master file-list, size and
    comment steps and the review aggregation job were compared with the
    base.
    
    ### Release note
    
    None.
    
    ### Check List (For Author)
    
    - Behavior changed: Yes (see Details).
    - Does this need documentation: No.
    - Pre-submission status: Partially verified. GitHub-hosted execution is
    pending.
    
    ### AI Disclosure
    
    - Tool: OpenAI Codex.
    - Generated: Implementation, tests and PR description.
    - Human review: Pending.
---
 .github/scripts/pr_workflow_event.py             |  2 +-
 .github/scripts/test_pr_workflow_event.py        | 60 ++++++++++++++--
 .github/scripts/test_review_checkout_workflow.py |  4 +-
 .github/workflows/code-review-sync-result.yml    | 28 +-------
 .github/workflows/code-style.yml                 | 89 +++++++++++++++++++++++-
 .github/workflows/lfs-warning.yml                | 25 +++++--
 .github/workflows/reviewer-assignment-check.yml  |  2 +
 7 files changed, 166 insertions(+), 44 deletions(-)

diff --git a/.github/scripts/pr_workflow_event.py 
b/.github/scripts/pr_workflow_event.py
index 5e043b79fec..662357300d3 100644
--- a/.github/scripts/pr_workflow_event.py
+++ b/.github/scripts/pr_workflow_event.py
@@ -87,7 +87,7 @@ def resolve(event, relay, repository, api=get):
                               ([before] if action == "synchronize" and before 
else [])))
     require(all(isinstance(sha, str) and SHA.fullmatch(sha) for sha in heads), 
"Invalid PR head SHA.")
     return {"pr_number": str(number), "head_shas": json.dumps(heads),
-            "check_large_files": str(pr["state"] == "open" and
+            "check_large_files": str(pr["base"]["ref"] != "master" and 
pr["state"] == "open" and
                                      action in {"opened", "synchronize", 
"reopened"}).lower()}
 
 
diff --git a/.github/scripts/test_pr_workflow_event.py 
b/.github/scripts/test_pr_workflow_event.py
index a0ad5ec342c..868ffec567f 100644
--- a/.github/scripts/test_pr_workflow_event.py
+++ b/.github/scripts/test_pr_workflow_event.py
@@ -17,6 +17,9 @@
 # under the License.
 
 import copy
+import io
+from contextlib import redirect_stdout
+from unittest.mock import patch
 import json
 import os
 from pathlib import Path
@@ -51,7 +54,7 @@ class RelayTest(unittest.TestCase):
         self.relay = {"number": 42, "action": "synchronize", "head_sha": HEAD, 
"before": BEFORE}
         self.pr = {"number": 42, "state": "open", "merged": False,
                    "head": {"sha": HEAD, "repo": {"id": 2}, "ref": 
"contributor-branch"},
-                   "base": {"repo": {"full_name": "apache/doris"}, "sha": 
BASE}}
+                   "base": {"repo": {"full_name": "apache/doris"}, "ref": 
"branch-4.1", "sha": BASE}}
         self.associated = [{"number": 42}]
         self.calls = []
 
@@ -73,6 +76,12 @@ class RelayTest(unittest.TestCase):
         self.assertEqual(result["check_large_files"], "true")
         self.assertEqual(len(self.calls), 2)
 
+    def 
test_master_keeps_review_sync_but_size_warnings_belong_to_code_style(self):
+        self.pr["base"]["ref"] = "master"
+        result = self.resolve()
+        self.assertEqual(result["check_large_files"], "false")
+        self.assertEqual(json.loads(result["head_shas"]), [HEAD, BEFORE])
+
     def test_stale_run_recomputes_live_head_too(self):
         self.pr["head"]["sha"] = CURRENT
         self.assertEqual(json.loads(self.resolve()["head_shas"]), [CURRENT, 
HEAD, BEFORE])
@@ -198,14 +207,53 @@ else:
         resolver = (WORKFLOWS / "resolve-pr-event.yml").read_text()
         self.assertIn("run-id: ${{ github.event.workflow_run.id }}", resolver)
         self.assertIn("ref: ${{ github.event.repository.default_branch }}", 
resolver)
-        for name in ("lfs-warning.yml", "code-review-sync-result.yml"):
-            source = (WORKFLOWS / name).read_text()
-            self.assertNotIn("pull_request_target:", source)
-            self.assertIn("uses: ./.github/workflows/resolve-pr-event.yml", 
source)
-        source = (WORKFLOWS / "code-review-sync-result.yml").read_text()
+        source = (WORKFLOWS / "lfs-warning.yml").read_text()
+        self.assertNotIn("pull_request_target:", source)
+        self.assertIn("uses: ./.github/workflows/resolve-pr-event.yml", source)
+        self.assertIn("if: needs.resolve-event.outputs.check_large_files == 
'true'", source)
+        review = (WORKFLOWS / "code-review-sync-result.yml").read_text()
+        self.assertNotIn("workflows: [Pull Request Events", review)
         self.assertIn("fromJSON(needs.resolve-event.outputs.head_shas)", 
source)
 
 
+class CodeStyleLargeFileTest(unittest.TestCase):
+    def run_check(self, files, objects):
+        script = step_script("code-style.yml", "Warn about large added files")
+        with tempfile.TemporaryDirectory() as directory:
+            root = Path(directory)
+            (root / "event").write_text(json.dumps({"pull_request": {}}))
+            (root / "code-style-files.json").write_text(json.dumps({"files": 
files}))
+            summary = root / "summary"
+            summary.touch()
+            env = {"GITHUB_EVENT_PATH": str(root / "event"), 
"GITHUB_REPOSITORY": "apache/doris",
+                   "RUNNER_TEMP": directory, "GITHUB_STEP_SUMMARY": 
str(summary)}
+            response = json.dumps({"data": {"repository": objects}}).encode()
+            with patch.dict(os.environ, env), patch("subprocess.check_output", 
return_value=response) as gh:
+                with redirect_stdout(io.StringIO()) as log:
+                    exec(compile(script, "Code Style large-file step", 
"exec"), {})
+                return summary.read_text(), log.getvalue(), gh.call_args_list
+
+    def test_docs_only_additions_warn_strictly_above_one_mib(self):
+        files = [{"status": status, "filename": path, "sha": char * 40}
+                 for status, path, char in [("added", "docs/limit", "a"),
+                                            ("added", "docs/<large>\nfile", 
"b"),
+                                            ("modified", "existing", "c"), 
("renamed", "moved", "d")]]
+        summary, log, calls = self.run_check(files, {
+            "f0": {"__typename": "Blob", "byteSize": 1048576},
+            "f1": {"__typename": "Blob", "byteSize": 1048577}})
+        self.assertEqual(len(calls), 1)
+        query = " ".join(calls[0].args[0])
+        self.assertNotIn("c" * 40, query)
+        self.assertNotIn("d" * 40, query)
+        self.assertNotIn("docs/limit", summary)
+        self.assertIn(r"docs/&lt;large&gt;\nfile", summary)
+        self.assertIn("1,048,577 bytes", summary)
+        self.assertIn("::warning::", log)
+
+    def test_no_additions_need_no_size_request(self):
+        self.assertEqual(self.run_check([], {}), ("", "", []))
+
+
 class LargeFileCommentTest(unittest.TestCase):
     def test_warning_remains_nonblocking_and_uses_resolved_pr_number(self):
         with tempfile.TemporaryDirectory() as directory:
diff --git a/.github/scripts/test_review_checkout_workflow.py 
b/.github/scripts/test_review_checkout_workflow.py
index df8e7c9236f..d95f91f913e 100644
--- a/.github/scripts/test_review_checkout_workflow.py
+++ b/.github/scripts/test_review_checkout_workflow.py
@@ -130,7 +130,7 @@ class ReviewCheckoutWorkflowTest(unittest.TestCase):
         self.assertEqual(".github/scripts/review_github_api.py", 
self.inputs["sparse-checkout"])
 
     def 
test_closed_pr_still_reaches_aggregate_and_releases_shared_head_context(self):
-        sync = (WORKFLOWS / "code-review-sync-result.yml").read_text()
+        sync = (WORKFLOWS / "lfs-warning.yml").read_text()
         relay = (WORKFLOWS / "pull-request-events.yml").read_text()
         triggers = relay.split("  pull_request:\n", 
1)[1].split("\npermissions:", 1)[0]
         self.assertIn("closed", triggers)
@@ -138,7 +138,7 @@ class ReviewCheckoutWorkflowTest(unittest.TestCase):
         self.assertIn("uses: 
./.github/workflows/code-review-aggregate-status.yml", caller)
         self.assertIn("needs: resolve-event", caller)
         self.assertIn("fromJSON(needs.resolve-event.outputs.head_shas)", 
caller)
-        self.assertIn("workflows: [Pull Request Events, Code Review 
Dismissal]", sync)
+        self.assertIn("workflows: [Pull Request Events]", sync)
         github = self.pr_event()
         self.assert_trusted_default_checkout(github)
         head = github["event"]["pull_request"]["head"]["sha"]
diff --git a/.github/workflows/code-review-sync-result.yml 
b/.github/workflows/code-review-sync-result.yml
index de99362b703..ad7ca0d1e51 100644
--- a/.github/workflows/code-review-sync-result.yml
+++ b/.github/workflows/code-review-sync-result.yml
@@ -2,7 +2,7 @@ name: Code Review
 
 on:
   workflow_run:
-    workflows: [Pull Request Events, Code Review Dismissal]
+    workflows: [Code Review Dismissal]
     types: [completed]
   issue_comment:
     types: [created]
@@ -343,29 +343,3 @@ jobs:
       contents: read
       pull-requests: read
       statuses: write
-
-  resolve-event:
-    if: >-
-      github.event_name == 'workflow_run' &&
-      github.event.workflow_run.conclusion == 'success' &&
-      github.event.workflow_run.event == 'pull_request'
-    uses: ./.github/workflows/resolve-pr-event.yml
-    permissions:
-      actions: read
-      contents: read
-      pull-requests: read
-
-  sync-status:
-    name: Sync review status
-    needs: resolve-event
-    strategy:
-      fail-fast: false
-      matrix:
-        head_sha: ${{ fromJSON(needs.resolve-event.outputs.head_shas) }}
-    uses: ./.github/workflows/code-review-aggregate-status.yml
-    with:
-      head_sha: ${{ matrix.head_sha }}
-    permissions:
-      contents: read
-      pull-requests: read
-      statuses: write
diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml
index f1d282589f1..8bcf3b45de1 100644
--- a/.github/workflows/code-style.yml
+++ b/.github/workflows/code-style.yml
@@ -55,19 +55,102 @@ jobs:
         shell: bash
         run: |
           # The first compare page lists at most 300 files. At the limit, run 
both checks.
-          if ! selection=$(gh api 
"repos/$GITHUB_REPOSITORY/compare/$BASE_SHA...$HEAD_SHA?per_page=1" |
-            jq -er '
+          files="$RUNNER_TEMP/code-style-files.json"
+          if ! gh api 
"repos/$GITHUB_REPOSITORY/compare/$BASE_SHA...$HEAD_SHA?per_page=1" \
+              --jq '{merge_base: .merge_base_commit.sha, files: (.files | 
map({filename, previous_filename, status, sha}))}' > "$files" ||
+            ! selection=$(jq -er '
               .files | select(type == "array" and length < 300)
               | [.[] | .filename, (.previous_filename // empty)]
               | any(.[]; . == ".github/workflows/code-style.yml") as $workflow
               | ($workflow or any(.[]; test("^(fe/|gensrc/(proto|thrift)/)"))) 
as $java
               | ($workflow or any(.[]; test("^(be|cloud)/(src|test)/"))) as 
$cpp
-              | "java=\($java)\ncpp=\($cpp)"'); then
+              | "java=\($java)\ncpp=\($cpp)"' "$files"); then
             echo "::warning::Changed paths unavailable or incomplete; running 
both style checks"
             selection=$'java=true\ncpp=true'
           fi
           printf '%s\n' "$selection" >> "$GITHUB_OUTPUT"
 
+      - name: Warn about large added files
+        id: sizes
+        continue-on-error: true
+        timeout-minutes: 2
+        env:
+          GH_TOKEN: ${{ github.token }}
+        shell: python3 {0}
+        run: |
+          import html
+          import json
+          import os
+          from pathlib import Path
+          import subprocess
+
+          def api(*args):
+              return json.loads(subprocess.check_output(["gh", "api", *args]))
+
+          pr = 
json.loads(Path(os.environ["GITHUB_EVENT_PATH"]).read_text())["pull_request"]
+          repo = os.environ["GITHUB_REPOSITORY"]
+          temp = Path(os.environ["RUNNER_TEMP"])
+          try:
+              comparison = json.loads((temp / 
"code-style-files.json").read_text())
+          except (OSError, ValueError):
+              comparison = {}
+          files = comparison.get("files")
+          if files is not None and len(files) < 300:
+              added = [(f["filename"], f["sha"]) for f in files if f["status"] 
== "added"]
+          else:
+              # GitHub caps compare at 300 and PR files at 3,000. Diff exact 
commits without a checkout.
+              objects_dir = temp / "code-style-objects.git"
+              subprocess.run(["git", "init", "--bare", "-q", objects_dir], 
check=True)
+
+              def git(*args):
+                  return subprocess.check_output(["git", "-C", objects_dir, 
*args])
+
+              git("remote", "add", "origin", 
f"{os.environ['GITHUB_SERVER_URL']}/{repo}.git")
+              head = pr["head"]["sha"]
+              base = comparison.get("merge_base")
+              if base:
+                  git("fetch", "--no-tags", "--depth=1", "--filter=blob:none", 
"origin", base, head)
+              else:
+                  git("fetch", "--no-tags", "--filter=tree:0", "origin", 
pr["base"]["sha"], head)
+                  base = git("merge-base", pr["base"]["sha"], 
head).decode().strip()
+              entries = git("diff", "--raw", "--no-abbrev", "-z", 
"--find-renames", "--diff-filter=A",
+                            base, head, "--").split(b"\0")
+              added = [(os.fsdecode(path), header.split()[3].decode())
+                       for header, path in zip(entries[::2], entries[1::2]) if 
header.split()[1] != b"160000"]
+
+          owner, name = repo.split("/")
+          summary = Path(os.environ["GITHUB_STEP_SUMMARY"])
+          missing_size = False
+          oversized = 0
+          for start in range(0, len(added), 100):
+              batch = added[start:start + 100]
+              fields = " 
".join(f"f{i}:object(oid:{json.dumps(oid)}){{__typename ... on Blob 
{{byteSize}}}}"
+                                for i, (_, oid) in enumerate(batch))
+              query = 
"query($owner:String!,$name:String!){repository(owner:$owner,name:$name){" + 
fields + "}}"
+              objects = api("graphql", "-f", f"query={query}", "-f", 
f"owner={owner}", "-f", f"name={name}")["data"]["repository"]
+              for i, (filename, _) in enumerate(batch):
+                  obj = objects[f"f{i}"]
+                  if obj is None:
+                      missing_size = True
+                      continue
+                  if obj["__typename"] != "Blob" or obj["byteSize"] <= 1024 * 
1024:
+                      continue
+                  size = obj["byteSize"]
+                  path = html.escape(json.dumps(filename, 
ensure_ascii=False)[1:-1])
+                  oversized += 1
+                  with summary.open("a", encoding="utf-8", 
errors="backslashreplace") as out:
+                      print(f"<p>Large added file: <code>{path}</code> 
({size:,} bytes, limit 1 MiB).</p>", file=out)
+          if oversized:
+              print(f"::warning::{oversized} added file(s) exceed 1 MiB. See 
the Code Style summary.")
+          if missing_size:
+              raise RuntimeError("GitHub did not return sizes for all added 
objects")
+
+      - name: Report incomplete large-file check
+        if: steps.sizes.outcome == 'failure'
+        run: |
+          echo "::warning::The large-file check was incomplete. See the Code 
Style summary."
+          echo "The large-file check could not verify all added files." >> 
"$GITHUB_STEP_SUMMARY"
+
       - name: Checkout source
         id: source
         if: steps.paths.outputs.java == 'true' || steps.paths.outputs.cpp == 
'true'
diff --git a/.github/workflows/lfs-warning.yml 
b/.github/workflows/lfs-warning.yml
index 38a268b80b2..1991663bd40 100644
--- a/.github/workflows/lfs-warning.yml
+++ b/.github/workflows/lfs-warning.yml
@@ -16,17 +16,14 @@
 # under the License.
 #
 ---
-name: 'Check Large File'
+name: PR Event Checks
 
 on:
   workflow_run:
     workflows: [Pull Request Events]
     types: [completed]
 
-permissions:
-  contents: read
-  pull-requests: write
-  issues: write
+permissions: {}
 
 jobs:
   resolve-event:
@@ -37,10 +34,28 @@ jobs:
       contents: read
       pull-requests: read
 
+  sync-status:
+    name: Sync review status
+    needs: resolve-event
+    strategy:
+      fail-fast: false
+      matrix:
+        head_sha: ${{ fromJSON(needs.resolve-event.outputs.head_shas) }}
+    uses: ./.github/workflows/code-review-aggregate-status.yml
+    with:
+      head_sha: ${{ matrix.head_sha }}
+    permissions:
+      contents: read
+      pull-requests: read
+      statuses: write
+
   large-file-checker:
     needs: resolve-event
     if: needs.resolve-event.outputs.check_large_files == 'true'
     name: "Check large file"
+    permissions:
+      contents: read
+      pull-requests: write
     runs-on: ubuntu-24.04
     steps:
       # Replaces the previous checkout + ppremk/lfs-warning action with plain
diff --git a/.github/workflows/reviewer-assignment-check.yml 
b/.github/workflows/reviewer-assignment-check.yml
index 6a3bba5cf88..be85ca0f1a8 100644
--- a/.github/workflows/reviewer-assignment-check.yml
+++ b/.github/workflows/reviewer-assignment-check.yml
@@ -22,6 +22,7 @@ on:
       - '.github/workflows/pull-request-events.yml'
       - '.github/workflows/resolve-pr-event.yml'
       - '.github/workflows/lfs-warning.yml'
+      - '.github/workflows/code-style.yml'
       - '.github/workflows/code-review-sync-result.yml'
       - '.github/workflows/reviewer-assignment*.yml'
       - 'tools/reviewer-routing/**'
@@ -46,6 +47,7 @@ on:
       - '.github/workflows/pull-request-events.yml'
       - '.github/workflows/resolve-pr-event.yml'
       - '.github/workflows/lfs-warning.yml'
+      - '.github/workflows/code-style.yml'
       - '.github/workflows/code-review-sync-result.yml'
       - '.github/workflows/reviewer-assignment*.yml'
       - 'tools/reviewer-routing/**'


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

Reply via email to