Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

ci: make the ci-gate script portable (no GNU grep -P) (#5833)

Francesco Bonaccie4154be4a23d
diff --git a/.github/scripts/tests/test_ci_gate_workflow.py b/.github/scripts/tests/test_ci_gate_workflow.py
index bb186899b2..3d883fd8cd 100644
--- a/.github/scripts/tests/test_ci_gate_workflow.py
+++ b/.github/scripts/tests/test_ci_gate_workflow.py
@@ -75,12 +75,12 @@ sleep() {
def run_gate(rows, jobs='test\tsuccess', older_jobs=None, rows_dir=None,
- max_sleeps=4, max_seconds=10**9):
+ max_sleeps=4, max_seconds=10**9, queue_ref=''):
# Mirrors the runner: GitHub runs a bare `run:` step with `bash -e`. The mocked
# sleep advances SECONDS, so the poll schedule is observable without waiting.
return subprocess.run(
['bash', '-e', '-c', MOCK + SCRIPT[SCRIPT.index('sha=$PR_SHA'):]],
- env={**os.environ, 'PR_SHA': 'abc', 'QUEUE_REF': '',
+ env={**os.environ, 'PR_SHA': 'abc', 'QUEUE_REF': queue_ref,
'GITHUB_REPOSITORY': 'test/repo', 'GITHUB_RUN_ID': '99',
'ROWS': rows, 'JOBS': jobs,
'OLDER_JOBS': jobs if older_jobs is None else older_jobs,
@@ -183,3 +183,16 @@ def test_gate_poll_schedule_backs_off_and_stays_within_the_api_budget():
assert intervals.count(30) == 20
# One run listing is one or two API calls; keep a long suite under 100 an hour.
assert len(sleeps) <= 100
+
+
+def test_gate_reads_the_pull_request_number_from_a_merge_queue_ref():
+ ref = 'refs/heads/gh-readonly-queue/main/pr-5811-0123abcd'
+ completed = run_gate(DONE, queue_ref=ref)
+ assert completed.returncode == 0, completed.stderr
+ assert 'build: pass' in completed.stdout
+
+
+def test_gate_fails_on_a_merge_queue_ref_without_a_pull_request_number():
+ completed = run_gate(DONE, queue_ref='refs/heads/gh-readonly-queue/main/odd')
+ assert completed.returncode == 1
+ assert 'build: pass' not in completed.stdout
diff --git a/.github/workflows/ci-gate.yml b/.github/workflows/ci-gate.yml
index dc28894416..3a259a02d8 100644
--- a/.github/workflows/ci-gate.yml
+++ b/.github/workflows/ci-gate.yml
@@ -26,7 +26,8 @@ jobs:
api() { local out; for _ in 1 2 3 4 5 6; do out=$(gh api "$@") && { printf '%s\n' "$out"; return; }; sleep 120; done; return 1; }
sha=$PR_SHA
if [[ -n "$QUEUE_REF" ]]; then
- pr=$(grep -oP '/pr-\K[0-9]+' <<<"$QUEUE_REF") || exit 1
+ [[ "$QUEUE_REF" =~ /pr-([0-9]+) ]] || exit 1
+ pr=${BASH_REMATCH[1]}
sha=$(api "repos/$GITHUB_REPOSITORY/pulls/$pr" --jq .head.sha) || exit 1
fi
runs() {
@@ -51,7 +52,7 @@ jobs:
previous=
while :; do
current=$(runs) || exit 1
- if [[ -n "$current" && "$current" == "$previous" ]] && ! grep -qvP '\tcompleted$' <<<"$current"; then
+ if [[ -n "$current" && "$current" == "$previous" ]] && awk -F'\t' '$NF != "completed" { exit 1 }' <<<"$current"; then
break
fi
previous=$current