jerryshao commented on code in PR #14990:
URL: https://github.com/apache/gravitino/pull/14990#discussion_r4594753163


##########
.github/scripts/fork-ci-status.cjs:
##########
@@ -60,29 +60,66 @@ const MISSING_WORKFLOW = 'Your fork has no Fork CI 
workflow, so pushes to this b
   'Merge or rebase the branch onto the latest base branch, which adds 
.github/workflows/fork-ci.yml, ' +
   'make sure Actions are enabled in your fork, and push again.';
 const requiredAction = note => ({ status: 'completed', conclusion: 
'action_required',
-  title: 'Fork CI needs attention', note });
+  title: NEEDS_ATTENTION, note });
+
+function incompleteAttempt(run, jobs) {
+  if (jobs.some(job => job.run_attempt > run.run_attempt)) {
+    return requiredAction('The jobs API reports a newer attempt than the run 
listing. ' +
+      'Waiting for consistent results; the publisher will automatically check 
again.');
+  }
+  // A completed rerun must expose at least one job from that attempt. 
Otherwise all
+  // retained successes (and auxiliary cancellations) could belong to the 
previous run.
+  if (run.status === 'completed' && run.run_attempt > 1 &&
+      !jobs.some(job => job.run_attempt === run.run_attempt)) {

Review Comment:
   [P1] If attempt 2 has rerun eligibility but its downstream results are not 
visible yet, that single current job lets the attempt 1 gate and suites turn 
attempt 2 green. I reproduced this with an old cancelled watcher; adding the 
current cancelled backend job changed success to cancellation. Please require 
evidence that the matching gate covers the rerun before overriding the 
aggregate in this case. Extend the entirely-stale-snapshot regression with a 
visible attempt 2 eligibility job and delayed downstream results.



##########
.github/scripts/fork-ci-status.cjs:
##########
@@ -60,29 +60,66 @@ const MISSING_WORKFLOW = 'Your fork has no Fork CI 
workflow, so pushes to this b
   'Merge or rebase the branch onto the latest base branch, which adds 
.github/workflows/fork-ci.yml, ' +
   'make sure Actions are enabled in your fork, and push again.';
 const requiredAction = note => ({ status: 'completed', conclusion: 
'action_required',
-  title: 'Fork CI needs attention', note });
+  title: NEEDS_ATTENTION, note });
+
+function incompleteAttempt(run, jobs) {
+  if (jobs.some(job => job.run_attempt > run.run_attempt)) {
+    return requiredAction('The jobs API reports a newer attempt than the run 
listing. ' +
+      'Waiting for consistent results; the publisher will automatically check 
again.');
+  }
+  // A completed rerun must expose at least one job from that attempt. 
Otherwise all
+  // retained successes (and auxiliary cancellations) could belong to the 
previous run.
+  if (run.status === 'completed' && run.run_attempt > 1 &&
+      !jobs.some(job => job.run_attempt === run.run_attempt)) {
+    return requiredAction('The jobs API has not reported the completed current 
attempt yet. ' +
+      'Waiting for consistent results; the publisher will automatically check 
again.');
+  }
+}
 
 function evaluateExecution(pr, run, jobs, baseSha) {
+  const incomplete = incompleteAttempt(run, jobs);
+  if (incomplete) return incomplete;
   const required = jobs.find(job => job.name === requiredName(pr, baseSha));
   if (run.status !== 'completed') {
     // A workflow can remain queued while some of its matrix jobs already have 
runners.
     const running = run.status === 'in_progress' || jobs.some(job => 
job.status === 'in_progress');
     return { status: running ? 'in_progress' : 'queued',
       title: running ? 'Fork CI is running' : 'Fork CI is queued, waiting for 
a runner' };
   }
-  const failed = jobs.filter(job => job.name !== FAIL_FAST && ['failure', 
'timed_out'].includes(job.conclusion))
+  // A nonmatching summary is obsolete only when it is provably from an older 
attempt.
+  // A newer (possibly unexpanded) summary must not reuse an earlier exact 
success.
+  const otherSummary = job => job.name.startsWith('Required CI / ') && job !== 
required;
+  const obsoleteSummary = job => otherSummary(job) && required &&
+    Number.isInteger(job.run_attempt) && job.run_attempt > 0 &&
+    Number.isInteger(required.run_attempt) && required.run_attempt > 
job.run_attempt;
+  if (jobs.some(job => otherSummary(job) && !obsoleteSummary(job))) {
+    return requiredAction('A Required CI record from the same, newer or 
unknown attempt does not match ' +
+      'this head and base. Rerun Required CI for the current context before 
publishing success.');
+  }
+  const isAuxiliary = job => job.name === FAIL_FAST || obsoleteSummary(job);
+  const currentJobs = jobs.filter(job => !isAuxiliary(job));
+  const failed = currentJobs.filter(job => ['failure', 
'timed_out'].includes(job.conclusion))
     .map(job => job.name);
-  // A run that failed only because of the watcher is judged by its suites 
below.
-  const watcherOnly = run.conclusion === 'failure' && !failed.length &&
-    jobs.some(job => job.name === FAIL_FAST && ['failure', 
'timed_out'].includes(job.conclusion));
-  if (run.conclusion !== 'success' && !watcherOnly) {
-    // Fork CI cancels its own run on the first failed job, so report that 
job, not the cancellation.
-    if (failed.length) return { status: 'completed', conclusion: 'failure',
-      title: `Failed: ${failed[0]}${failed.length > 1 ? ` (+${failed.length - 
1} more)` : ''}`.slice(0, 200) };
+  // Partial reruns can retain a cancelled watcher or an obsolete Required CI 
job, keeping
+  // the whole run cancelled after its suites recover. Ignore only those 
auxiliary results,
+  // then verify the exact Required CI and all required suites below. Any 
other unfinished
+  // or unsuccessful job still blocks.
+  const auxiliaryOnly = ['failure', 'timed_out', 
'cancelled'].includes(run.conclusion) &&
+    jobs.some(job => isAuxiliary(job) && ['failure', 'timed_out', 
'cancelled'].includes(job.conclusion)) &&
+    currentJobs.every(job => ['success', 'skipped'].includes(job.conclusion));
+  // Run and job metadata are separate API snapshots. Even a successful 
aggregate must
+  // not hide a failed prerequisite or suite observed in the jobs response.
+  if (failed.length) return { status: 'completed', conclusion: 'failure',
+    title: `Failed: ${failed[0]}${failed.length > 1 ? ` (+${failed.length - 1} 
more)` : ''}`.slice(0, 200) };

Review Comment:
   [P2] For a fork that edits CI definitions, a successful aggregate still 
overrides the prerequisite failure detected here: `mirror()` changes it to 
`TRUSTED_REQUIRED` and says Fork CI passed. Please use the evaluated execution 
result to decide when to request trusted verification, and include `changed: 
true` in the conflicting-prerequisite regression so the failed job remains 
visible.



##########
.github/scripts/fork-ci-status.cjs:
##########
@@ -60,29 +60,66 @@ const MISSING_WORKFLOW = 'Your fork has no Fork CI 
workflow, so pushes to this b
   'Merge or rebase the branch onto the latest base branch, which adds 
.github/workflows/fork-ci.yml, ' +
   'make sure Actions are enabled in your fork, and push again.';
 const requiredAction = note => ({ status: 'completed', conclusion: 
'action_required',
-  title: 'Fork CI needs attention', note });
+  title: NEEDS_ATTENTION, note });
+
+function incompleteAttempt(run, jobs) {
+  if (jobs.some(job => job.run_attempt > run.run_attempt)) {
+    return requiredAction('The jobs API reports a newer attempt than the run 
listing. ' +
+      'Waiting for consistent results; the publisher will automatically check 
again.');
+  }
+  // A completed rerun must expose at least one job from that attempt. 
Otherwise all
+  // retained successes (and auxiliary cancellations) could belong to the 
previous run.
+  if (run.status === 'completed' && run.run_attempt > 1 &&
+      !jobs.some(job => job.run_attempt === run.run_attempt)) {
+    return requiredAction('The jobs API has not reported the completed current 
attempt yet. ' +
+      'Waiting for consistent results; the publisher will automatically check 
again.');
+  }
+}
 
 function evaluateExecution(pr, run, jobs, baseSha) {
+  const incomplete = incompleteAttempt(run, jobs);
+  if (incomplete) return incomplete;
   const required = jobs.find(job => job.name === requiredName(pr, baseSha));
   if (run.status !== 'completed') {
     // A workflow can remain queued while some of its matrix jobs already have 
runners.
     const running = run.status === 'in_progress' || jobs.some(job => 
job.status === 'in_progress');
     return { status: running ? 'in_progress' : 'queued',
       title: running ? 'Fork CI is running' : 'Fork CI is queued, waiting for 
a runner' };
   }
-  const failed = jobs.filter(job => job.name !== FAIL_FAST && ['failure', 
'timed_out'].includes(job.conclusion))
+  // A nonmatching summary is obsolete only when it is provably from an older 
attempt.
+  // A newer (possibly unexpanded) summary must not reuse an earlier exact 
success.
+  const otherSummary = job => job.name.startsWith('Required CI / ') && job !== 
required;
+  const obsoleteSummary = job => otherSummary(job) && required &&
+    Number.isInteger(job.run_attempt) && job.run_attempt > 0 &&
+    Number.isInteger(required.run_attempt) && required.run_attempt > 
job.run_attempt;
+  if (jobs.some(job => otherSummary(job) && !obsoleteSummary(job))) {
+    return requiredAction('A Required CI record from the same, newer or 
unknown attempt does not match ' +
+      'this head and base. Rerun Required CI for the current context before 
publishing success.');
+  }
+  const isAuxiliary = job => job.name === FAIL_FAST || obsoleteSummary(job);
+  const currentJobs = jobs.filter(job => !isAuxiliary(job));
+  const failed = currentJobs.filter(job => ['failure', 
'timed_out'].includes(job.conclusion))
     .map(job => job.name);
-  // A run that failed only because of the watcher is judged by its suites 
below.
-  const watcherOnly = run.conclusion === 'failure' && !failed.length &&
-    jobs.some(job => job.name === FAIL_FAST && ['failure', 
'timed_out'].includes(job.conclusion));
-  if (run.conclusion !== 'success' && !watcherOnly) {
-    // Fork CI cancels its own run on the first failed job, so report that 
job, not the cancellation.
-    if (failed.length) return { status: 'completed', conclusion: 'failure',
-      title: `Failed: ${failed[0]}${failed.length > 1 ? ` (+${failed.length - 
1} more)` : ''}`.slice(0, 200) };
+  // Partial reruns can retain a cancelled watcher or an obsolete Required CI 
job, keeping
+  // the whole run cancelled after its suites recover. Ignore only those 
auxiliary results,
+  // then verify the exact Required CI and all required suites below. Any 
other unfinished
+  // or unsuccessful job still blocks.
+  const auxiliaryOnly = ['failure', 'timed_out', 
'cancelled'].includes(run.conclusion) &&
+    jobs.some(job => isAuxiliary(job) && ['failure', 'timed_out', 
'cancelled'].includes(job.conclusion)) &&
+    currentJobs.every(job => ['success', 'skipped'].includes(job.conclusion));
+  // Run and job metadata are separate API snapshots. Even a successful 
aggregate must
+  // not hide a failed prerequisite or suite observed in the jobs response.
+  if (failed.length) return { status: 'completed', conclusion: 'failure',

Review Comment:
   [P2] When the run reports success but the only visible failure for a suite 
is from a previous attempt, please keep the status non-green and retryable. 
Publishing an ordinary failure here makes the settled probe skip the corrected 
jobs response. A scheduled-publisher test can expose the old failure first, 
then the retried suite's success without changing the run ID or attempt.



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

Reply via email to