Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

ci(ci-fast-hosted): align routing decision with ci-fast.yml

Steven Enamakelfcd4f697fa83
diff --git a/.github/workflows/ci-fast-hosted.yml b/.github/workflows/ci-fast-hosted.yml
index 7470211d96..a45cafff84 100644
--- a/.github/workflows/ci-fast-hosted.yml
+++ b/.github/workflows/ci-fast-hosted.yml
@@ -5,7 +5,8 @@
# group only admits ci-fast.yml / ci-lanes.yml at refs/heads/main, and a fork's
# `pull_request` run resolves to refs/pull/N/merge.
#
-# Org members skip this workflow; ci-fast.yml runs theirs on the EX63.
+# Org members skip this workflow; ci-fast.yml runs theirs on the EX63. The
+# route job follows ci-fast.yml's own decision, so the two never disagree.
name: CI Fast (hosted)
on:
@@ -26,27 +27,65 @@ jobs:
route:
name: Route (outsiders → GitHub-hosted)
runs-on: ubuntu-latest
- timeout-minutes: 5
+ timeout-minutes: 6
outputs:
outsider: ${{ steps.route.outputs.outsider }}
steps:
- - name: Decide whether the author is an outside contributor
+ - name: Follow ci-fast.yml's routing decision
id: route
env:
+ GH_TOKEN: ${{ github.token }}
+ REPO: ${{ github.repository }}
+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}
AUTHOR: ${{ github.event.pull_request.user.login }}
ACTOR: ${{ github.actor }}
ASSOCIATION: ${{ github.event.pull_request.author_association }}
run: |
set -euo pipefail
- # Fork `pull_request` runs get no secrets, so this can only read the
- # event's author association. Mirrors ci-fast.yml's no-token path:
- # a run is a member run only when the author is OWNER/MEMBER and the
- # pusher is the author.
- outsider=true
- if { [ "${ASSOCIATION}" = "OWNER" ] || [ "${ASSOCIATION}" = "MEMBER" ]; } && [ "${ACTOR}" = "${AUTHOR}" ]; then
- outsider=false
+ # ci-fast.yml decides who is an org member: it runs from main with
+ # the CI_MEMBERSHIP_TOKEN secret, so it also sees private members.
+ # Fork `pull_request` runs get no secrets and see those members only
+ # as COLLABORATOR, so deciding here as well would run the PR twice.
+ # Instead, find ci-fast.yml's run for this head commit and read its
+ # outcome: EX63 lanes skipped means outsider, anything else means
+ # the EX63 is handling it.
+ decide_from_ci_fast() {
+ local run_id="" lanes=""
+ for _ in $(seq 1 36); do
+ run_id="$(gh api "repos/${REPO}/actions/workflows/ci-fast.yml/runs?head_sha=${HEAD_SHA}&per_page=5" \
+ --jq '[.workflow_runs[] | select(.event == "pull_request_target")] | sort_by(.created_at) | last | .id // empty' 2>/dev/null || true)"
+ if [ -n "${run_id}" ]; then
+ # The EX63 lanes job gets a conclusion (skipped) or starts only
+ # after the route job has decided.
+ lanes="$(gh api "repos/${REPO}/actions/runs/${run_id}/jobs?per_page=50" \
+ --jq '[.jobs[] | select(.name | test("CI Fast \\(EX63\\)"))][0] | "\(.status)/\(.conclusion)"' 2>/dev/null || true)"
+ route="$(gh api "repos/${REPO}/actions/runs/${run_id}/jobs?per_page=50" \
+ --jq '[.jobs[] | select(.name | startswith("Route"))][0].conclusion // empty' 2>/dev/null || true)"
+ if [ "${route}" = "success" ]; then
+ case "${lanes}" in
+ completed/skipped) echo "true ci-fast run ${run_id}: EX63 lanes skipped"; return 0 ;;
+ ""|null/null) ;; # not materialised yet
+ *) echo "false ci-fast run ${run_id}: EX63 lanes ${lanes}"; return 0 ;;
+ esac
+ fi
+ fi
+ sleep 5
+ done
+ return 1
+ }
+ if verdict="$(decide_from_ci_fast)"; then
+ outsider="${verdict%% *}"
+ reason="${verdict#* }"
+ else
+ # No ci-fast.yml decision within 3 minutes: fall back to the event's
+ # author association (private members may then run here too).
+ outsider=true
+ if { [ "${ASSOCIATION}" = "OWNER" ] || [ "${ASSOCIATION}" = "MEMBER" ]; } && [ "${ACTOR}" = "${AUTHOR}" ]; then
+ outsider=false
+ fi
+ reason="fallback: no ci-fast.yml decision, association=${ASSOCIATION}"
fi
- echo "[ci][route] author=${AUTHOR} actor=${ACTOR} association=${ASSOCIATION} outsider=${outsider}"
+ echo "[ci][route] author=${AUTHOR} actor=${ACTOR} outsider=${outsider} (${reason})"
echo "outsider=${outsider}" >> "$GITHUB_OUTPUT"
lanes: