fix(ci): resolve gh_run_watch test hang and hardcoded path

- abortableSleep used Bun.sleep which vitest fake timers do not intercept;
  switch to setTimeout via Promise.withResolvers so vi.useFakeTimers() +
  vi.advanceTimersByTime() work correctly in the polling loop tests
- getCurrentHeadSha() and GhRunWatchTool session cwd used a hardcoded
  /work/pi path; replace with import.meta.dir so the tests resolve the
  real repo HEAD on any machine
- add timeout-minutes: 30 to the CI test job as a safety net against
  future hangs blocking release runs
This commit is contained in:
can1357
2026-04-01 20:18:23 +02:00
parent 5fbfbafa58
commit 2e0186a952
3 changed files with 11 additions and 4 deletions
+1
View File
@@ -110,6 +110,7 @@ jobs:
test:
runs-on: ubuntu-22.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
+2 -2
View File
@@ -64,7 +64,7 @@ function createToolContext(settings: Settings): AgentToolContext {
function getCurrentHeadSha(): string {
const result = Bun.spawnSync(["git", "rev-parse", "HEAD"], {
cwd: "/work/pi",
cwd: import.meta.dir,
stdout: "pipe",
stderr: "pipe",
});
@@ -587,7 +587,7 @@ describe("GitHub CLI tools", () => {
const updates: string[] = [];
let latestUpdateDetails: GhToolDetails | undefined;
const tool = new GhRunWatchTool(createSession("/work/pi"));
const tool = new GhRunWatchTool(createSession(import.meta.dir));
vi.useFakeTimers();
const resultPromise = tool.execute("run-watch", {}, undefined, update => {
const block = update.content[0];
+8 -2
View File
@@ -12,9 +12,15 @@ export class AbortError extends Error {
/**
* Sleep for a given number of milliseconds, respecting abort signal.
*
* Uses setTimeout (not Bun.sleep) so that vitest fake timers can intercept it in tests.
*/
export async function abortableSleep(ms: number, signal?: AbortSignal): Promise<void> {
return untilAborted(signal, () => Bun.sleep(ms));
export function abortableSleep(ms: number, signal?: AbortSignal): Promise<void> {
return untilAborted(signal, () => {
const { promise, resolve } = Promise.withResolvers<void>();
setTimeout(resolve, ms);
return promise;
});
}
/**