Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

pregate remote gate: run ci:ubicloud:diff, not the full gate (P4)

garrytan0839281bb2db
diff --git a/scripts/pregate-remote-gate.sh b/scripts/pregate-remote-gate.sh
index 9ff8a4a11e..e64650f333 100755
--- a/scripts/pregate-remote-gate.sh
+++ b/scripts/pregate-remote-gate.sh
@@ -9,8 +9,11 @@
#
# PREGATE_REMOTE: tree=<tree> tests=<n> failed=<n>
#
-# It runs the full Ubicloud gate (`bun run ci:ubicloud`, every lane), a
-# superset of whatever pregate selected, so PREGATE_FILES_FILE is not read.
+# It runs the development form of the Ubicloud gate, `bun run ci:ubicloud:diff`:
+# a doc-only tree runs the doc checks and gitleaks, any other tree every lane,
+# a superset of whatever pregate selected, so PREGATE_FILES_FILE is not read.
+# The full gate (`bun run ci:ubicloud`) runs once per PR, at handoff, outside
+# pregate (scripts/ubicloud/README.md#how-many-full-gates).
# <tree> is the working-tree content fingerprint this script computes itself
# (tracked plus untracked-unignored files, the set ci:ubicloud packs), taken
# before and after the gate; the line is printed only when both agree and,
@@ -24,7 +27,7 @@
# environment. Extra arguments go to ci:ubicloud (for example --vms 8).
# Spend is not reported (no spent=), so gstack counts it at the cap.
#
-# Seam: GBRAIN_PREGATE_GATE_CMD replaces `bun run ci:ubicloud`
+# Seam: GBRAIN_PREGATE_GATE_CMD replaces `bun run ci:ubicloud:diff`
# (test/scripts/pregate-remote-gate.test.ts).
set -uo pipefail
@@ -54,7 +57,7 @@ fi
log=$(mktemp "${TMPDIR:-/tmp}/pregate-remote-gate-log-XXXXXX") || fail "cannot create a log file"
trap 'rm -f "$log"' EXIT
-gate_cmd=${GBRAIN_PREGATE_GATE_CMD:-bun run ci:ubicloud}
+gate_cmd=${GBRAIN_PREGATE_GATE_CMD:-bun run ci:ubicloud:diff}
# shellcheck disable=SC2086
env -u OPENAI_API_KEY -u ANTHROPIC_API_KEY -u VOYAGE_API_KEY -u GEMINI_API_KEY -u JEV_TYPESAFE_API_KEY -u DATABASE_URL \
bash -c "$gate_cmd \"\$@\"" pregate-remote-gate "$@" 2>&1 | tee "$log"
diff --git a/test/scripts/pregate-remote-gate.test.ts b/test/scripts/pregate-remote-gate.test.ts
index c31950c66c..dbd13f55d1 100644
--- a/test/scripts/pregate-remote-gate.test.ts
+++ b/test/scripts/pregate-remote-gate.test.ts
@@ -8,12 +8,14 @@
* (untracked files included, ignored files excluded), the totals stop summing
* every summary lane, a gate with no summary or a moved tree still prints a
* receipt, the gate's exit code is lost, or a missing UBI_OWNER or a
- * PREGATE_TREE mismatch reaches the gate.
- * Seam: GBRAIN_PREGATE_GATE_CMD replaces `bun run ci:ubicloud`.
+ * PREGATE_TREE mismatch reaches the gate, or the default gate is anything
+ * but the development form `bun run ci:ubicloud:diff` (the full gate runs
+ * once per PR, at handoff).
+ * Seam: GBRAIN_PREGATE_GATE_CMD replaces `bun run ci:ubicloud:diff`.
*/
import { afterEach, beforeEach, describe, expect, it } from 'bun:test';
import { spawnSync } from 'node:child_process';
-import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
@@ -85,6 +87,20 @@ describe('pregate-remote-gate.sh', () => {
expect(r.status).toBe(0);
});
+ it('runs the development gate, bun run ci:ubicloud:diff, by default and passes the extra arguments on', () => {
+ const bin = join(repo, '.git', 'fake-bin');
+ mkdirSync(bin);
+ writeFileSync(join(bin, 'bun'), `#!/usr/bin/env bash\necho "fake-bun: $*"\nprintf '%s\\n' '=== ci-ubicloud summary ===' ' gitleaks 1 passed, 0 failed, 2s compute'\n`);
+ chmodSync(join(bin, 'bun'), 0o755);
+ const r = spawnSync('bash', [SCRIPT, '--lanes', 'unit'], {
+ cwd: repo, encoding: 'utf8',
+ env: { ...process.env, GIT_CONFIG_NOSYSTEM: '1', UBI_OWNER: 'gbra0test', PATH: `${bin}:${process.env.PATH}`, GBRAIN_PREGATE_GATE_CMD: undefined, PREGATE_TREE: undefined } as Record<string, string>,
+ });
+ expect(r.stdout).toContain('fake-bun: run ci:ubicloud:diff --lanes unit');
+ expect(r.stdout.trim().split('\n').at(-1)).toBe(`PREGATE_REMOTE: tree=${contentTree()} tests=1 failed=0`);
+ expect(r.status).toBe(0);
+ });
+
it('prints no receipt when the gate printed no summary', () => {
const r = run('echo provisioning failed; exit 3');
expect(r.out).not.toContain('PREGATE_REMOTE:');