imbajin commented on code in PR #3271:
URL: https://github.com/apache/hugegraph/pull/3271#discussion_r4184427942


##########
.github/scripts/check-rerun.py:
##########
@@ -0,0 +1,92 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Check the failed run again immediately before an automatic retry."""
+
+import argparse
+import json
+import os
+import subprocess
+from urllib.parse import quote, urlencode
+
+
+def api(path):
+    result = subprocess.run(
+        ["gh", "api", "--method", "GET", path], check=True,
+        capture_output=True, text=True,
+    )
+    return json.loads(result.stdout)
+
+
+def decide(repository, run_id, expected_attempt, max_reruns, fetch=api):
+    run = fetch(f"repos/{repository}/actions/runs/{run_id}")
+    if (run.get("status") != "completed" or run.get("conclusion") != "failure"
+            or run.get("run_attempt") != expected_attempt):
+        return "skip", "source run changed or is no longer a completed failure"
+    if expected_attempt > max_reruns:
+        return "skip", "retry limit reached"
+    sha = run.get("head_sha")
+    if not sha:
+        return "skip", "missing head SHA"
+    if run.get("event") == "pull_request":
+        def local(candidate):
+            base_repository = candidate.get("base", {}).get("repo", {})
+            return (base_repository.get("full_name") == repository
+                    or base_repository.get("url") == 
f"https://api.github.com/repos/{repository}";)
+
+        candidates = [pr for pr in run.get("pull_requests", []) if local(pr)]
+        if not candidates:
+            candidates = [pr for pr in fetch(
+                f"repos/{repository}/commits/{quote(sha, safe='')}/pulls") if 
local(pr)]

Review Comment:
   ⚠️ Blocking: no. Summary: Fork PR runs can be skipped before the checker 
verifies the live PR. Evidence: this PR's head run returns `pull_requests: []`, 
and the base-repository 
`commits/91fd925d4cdcfb6503a5bca3244909dfcf18d57c/pulls` lookup returns `[]`; 
`decide()` then reaches the `skip` path at line 62 although PR #3271 is open at 
that same head. Please resolve the PR from the run's head repository and branch 
when both association sources are empty, then retain the base/state/head checks 
and add a regression test.



##########
.github/workflows/server-ci.yml:
##########
@@ -8,6 +8,11 @@ on:
       - 'test-*'
   pull_request:
 
+# Keep the newest PR run; preserve independent push, release and manual runs.
+concurrency:
+  group: ${{ github.workflow }}-${{ github.event_name }}-${{ 
github.event.pull_request.number || github.run_id }}
+  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

Review Comment:
   ⚠️ Blocking: no. Summary: A rerun of an older PR attempt can cancel or 
replace CI for the current head. Evidence: every `pull_request` attempt shares 
the workflow/event/PR concurrency group on line 13 and this line cancels 
in-progress runs; GitHub reruns keep the original SHA/ref, so a stale manual or 
automatic rerun can cancel current-head checks. Please isolate rerun attempts 
from the PR-wide cancellation group or ensure a rerun still targets the current 
head before it can share that group.



-- 
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