Skip to content

Commit e1c8cf1

Browse files
authored
Merge pull request #421 from githubnext/codex/repair-after-ci-activation
Dispatch Evergreen repair for visible CI failures
2 parents e81ad24 + 3f83820 commit e1c8cf1

3 files changed

Lines changed: 94 additions & 15 deletions

File tree

.github/workflows/evergreen.lock.yml

Lines changed: 44 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/evergreen.md

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,30 @@ jobs:
187187
return 1
188188
}
189189
190+
any_configured_check_failing() {
191+
local payload="$1"
192+
local required="$2"
193+
local count
194+
local state
195+
196+
count="$(jq 'length' <<<"$required")"
197+
if [ "$count" -eq 0 ]; then
198+
has_failing_check "$payload"
199+
return
200+
fi
201+
202+
while IFS= read -r name; do
203+
state="$(check_state_for "$payload" "$name")"
204+
case "$state" in
205+
FAILURE|failure|FAILED|failed|ERROR|error|TIMED_OUT|timed_out|CANCELLED|cancelled)
206+
return 0
207+
;;
208+
esac
209+
done < <(jq -r '.[]' <<<"$required")
210+
211+
return 1
212+
}
213+
190214
evaluate_readiness() {
191215
local payload="$1"
192216
local required
@@ -210,6 +234,11 @@ jobs:
210234
return 0
211235
fi
212236
237+
if any_configured_check_failing "$payload" "$required"; then
238+
echo "needs_repair"
239+
return 0
240+
fi
241+
213242
if any_configured_check_missing "$payload" "$required"; then
214243
echo "needs_ci"
215244
return 0
@@ -304,7 +333,7 @@ jobs:
304333
305334
if [ -z "$run_id" ]; then
306335
echo "No CI run found for PR #$pr ($head_sha); leaving for scheduled/PR CI to start."
307-
return 0
336+
return 1
308337
fi
309338
310339
case "$status" in
@@ -317,14 +346,22 @@ jobs:
317346
case "$conclusion" in
318347
success)
319348
echo "CI run $run_id for PR #$pr ($head_sha) already succeeded; not rerunning green checks."
320-
return 0
349+
return 1
321350
;;
322351
esac
323352
324353
echo "Reactivating CI run $run_id for PR #$pr ($head_sha) (status=$status conclusion=$conclusion)."
325-
ci_gh gh run rerun "$run_id" --repo "$REPO" --failed || \
326-
ci_gh gh run rerun "$run_id" --repo "$REPO" || \
327-
echo "Could not reactivate CI run $run_id; scheduled monitor will retry."
354+
if ci_gh gh run rerun "$run_id" --repo "$REPO" --failed; then
355+
return 0
356+
fi
357+
358+
echo "Failed-jobs rerun was unavailable for CI run $run_id; trying full rerun."
359+
if ci_gh gh run rerun "$run_id" --repo "$REPO"; then
360+
return 0
361+
fi
362+
363+
echo "Could not reactivate CI run $run_id; scheduled monitor will retry."
364+
return 1
328365
}
329366
330367
update_branch_if_needed() {
@@ -402,7 +439,7 @@ jobs:
402439
return 1
403440
;;
404441
needs_ci)
405-
trigger_ci_if_needed "$pr" "$head_sha"
442+
trigger_ci_if_needed "$pr" "$head_sha" || true
406443
return 1
407444
;;
408445
needs_branch_update)

.github/workflows/shared/evergreen/repo-policy.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ readiness controller and the agentic orchestrator must both respect this file.
4242
(new head SHA, pending, failing, missing check, conflict, out of scope).
4343
- Current-head SHA policy: readiness is evaluated only against the current PR
4444
head SHA. A new push invalidates prior readiness.
45-
- Pending check policy: `waiting` — do not repair pending or in-progress checks.
45+
- Failing check policy: `needs_repair` — if a configured gate is visibly
46+
failing for the current head SHA, dispatch the repair agent even when other
47+
configured checks are still missing or skipped.
48+
- Pending check policy: `waiting` — do not repair pending or in-progress checks
49+
unless another configured gate has already failed.
4650
- Missing/stale check policy: `needs_ci` — reactivate the latest `CI` run for the
47-
head SHA once (see CI/CD Activation). Never rerun green checks.
51+
head SHA once, then stop so a later reconciliation can classify the resulting
52+
checks (see CI/CD Activation). Never rerun green checks.
4853
- Branch freshness ready criterion: not required to be up to date with `main`;
4954
freshness is only enforced when the branch is conflicted (`DIRTY`/`UNKNOWN`).
5055
- Additional deterministic ready criteria: PR open, has `evergreen`, not

0 commit comments

Comments
 (0)