Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
ci(native-locks): a data-safety suite still running at 300 s is named, sampled and killed, so a stall leaves a log instead of a timeout cancel
garrytana75bf5a8f536
diff --git a/.github/workflows/native-locks.yml b/.github/workflows/native-locks.ymlindex cf8ce844a9..e2c57ff2bf 100644--- a/.github/workflows/native-locks.yml+++ b/.github/workflows/native-locks.yml@@ -105,14 +105,32 @@ jobs:env:GBRAIN_CI_DISABLE_TEST_ENV_FILE: '1'GBRAIN_TEST_REQUIRE_CASE_INSENSITIVE: ${{ runner.os != 'Linux' && '1' || '0' }}+ # Each file normally takes 1-50 s (darwin-x64 is the slowest). A file still running at+ # 300 s is stuck: its process table and, on macOS, a native stack sample go to the log+ # before it is killed, because a job the timeout cancels keeps no log at all.run: |status=0- bun --no-env-file test --timeout=180000 test/persistence-publication-native.serial.test.ts || status=1- bun --no-env-file test --timeout=180000 test/persistence-git-publication.test.ts || status=1- bun --no-env-file test --timeout=180000 test/persistence-sync-origin-native.test.ts || status=1- bun --no-env-file test --timeout=180000 test/backup-portability-native.serial.test.ts || status=1- bun --no-env-file test --timeout=180000 test/export-publication-native.test.ts || status=1- bun --no-env-file test --timeout=180000 test/native-export-publication.test.ts || status=1+ bound_s="${GBRAIN_NATIVE_SUITE_BOUND_S:-300}"+ bounded() {+ bun --no-env-file test --timeout=180000 "$1" &+ pid=$!+ for _ in $(seq 1 "$bound_s"); do+ if ! kill -0 "$pid" 2>/dev/null; then wait "$pid"; return $?; fi+ sleep 1+ done+ echo "::error::$1 was still running after $bound_s s (it normally takes under 60 s); process table and stack sample follow, then it is killed"+ ps -A -o pid,ppid,stat,etime,command 2>/dev/null | grep -E 'bun|git' | grep -v grep || ps -ef+ if command -v sample >/dev/null 2>&1; then sample "$pid" 3 2>&1 | head -200; fi+ kill -TERM "$pid" 2>/dev/null; sleep 5; kill -KILL "$pid" 2>/dev/null+ wait "$pid" 2>/dev/null+ return 1+ }+ bounded test/persistence-publication-native.serial.test.ts || status=1+ bounded test/persistence-git-publication.test.ts || status=1+ bounded test/persistence-sync-origin-native.test.ts || status=1+ bounded test/backup-portability-native.serial.test.ts || status=1+ bounded test/export-publication-native.test.ts || status=1+ bounded test/native-export-publication.test.ts || status=1exit "$status"- name: Build the published CLI platforms and verify persistent writesif: matrix.target == 'linux-x64-glibc' || matrix.target == 'darwin-arm64'diff --git a/test/scripts/data-safety-native-workflow.test.ts b/test/scripts/data-safety-native-workflow.test.tsindex 774778a165..dd8a74161f 100644--- a/test/scripts/data-safety-native-workflow.test.ts+++ b/test/scripts/data-safety-native-workflow.test.ts@@ -137,11 +137,24 @@ describe('data-safety native CI coverage', () => {GBRAIN_CI_DISABLE_TEST_ENV_FILE: '1',GBRAIN_TEST_REQUIRE_CASE_INSENSITIVE: "${{ runner.os != 'Linux' && '1' || '0' }}",});- expect(step!.run!.trim().split('\n')).toEqual([- 'status=0',- ...suites.map(suite => `bun --no-env-file test --timeout=180000 ${suite} || status=1`),- 'exit "$status"',- ]);+ const lines = step!.run!.trim().split('\n');+ expect(lines[0]).toBe('status=0');+ expect(lines).toContain(' bun --no-env-file test --timeout=180000 "$1" &');+ expect(lines.filter(line => line.startsWith('bounded '))).toEqual(suites.map(suite => `bounded ${suite} || status=1`));+ expect(lines.at(-1)).toBe('exit "$status"');+ });++ test('a stuck native safety suite is named, sampled and killed inside the job timeout, and the step fails', () => {+ const step = workflow.jobs.native.steps.find(entry => entry.name === 'Verify native data-safety contracts')!;+ const stuck = suites[2]!;+ const result = Bun.spawnSync(['bash', '-e', '-o', 'pipefail', '-c', `+ bun() { if [[ "$4" == "$GBRAIN_TEST_STUCK_SUITE" ]]; then exec sleep 600; fi; printf '%s\\n' "$4"; }+ ${step.run}+ `], { env: { PATH: process.env.PATH ?? '', GBRAIN_TEST_STUCK_SUITE: stuck, GBRAIN_NATIVE_SUITE_BOUND_S: '2' }, timeout: 60_000 });+ expect(result.exitCode).toBe(1);+ const stdout = result.stdout.toString();+ expect(stdout).toContain(`::error::${stuck} was still running after 2 s`);+ expect(stdout.trim().split('\n').filter(line => line.startsWith('test/'))).toEqual(suites.filter(suite => suite !== stuck));});for (const failed of ['', ...suites]) test(`every native safety suite runs and failures remain fatal (${failed || 'all pass'})`, () => {