From cfbfae9fa019a6c051bbdffdfa9b579ab3935dd9 Mon Sep 17 00:00:00 2001 From: Rhuan Barreto Date: Mon, 25 May 2026 22:34:06 +0200 Subject: [PATCH 1/4] fix(ci): resolve macOS and Windows test failures in release builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The v0.38.0 and v0.39.0 release builds failed on macOS (7 tests) and Windows (1 test) while PR CI (ubuntu-only) passed green. Root causes: 1. macOS `/var` → `/private/var` symlink: `mkdtempSync` returns `/var/folders/…` but `process.cwd()` after `chdir()` resolves the symlink, causing path mismatches in session-context and import tests. Fix: wrap `mkdtempSync` with `realpathSync`. 2. macOS `Bun.which()` returns null for proto shims: on ARM64 runners where bun/git are installed via proto, `Bun.which` can't find them. Fix: `test.skipIf` guards on PATH-presence tests. 3. Windows timeout: `bun test` (5s default) vs `bun run test` (60s from package.json). Fix: use `bun run test` in the release-binaries workflow Windows step. Signed-off-by: Rhuan Barreto --- .claude/agent-memory/archgate-developer/MEMORY.md | 3 +++ .github/workflows/release-binaries.yml | 2 +- tests/commands/adr/import.test.ts | 11 +++++++++-- tests/commands/session-context/claude-code.test.ts | 6 ++++-- tests/commands/session-context/copilot.test.ts | 8 ++++++-- tests/commands/session-context/cursor.test.ts | 8 ++++++-- tests/commands/session-context/opencode.test.ts | 8 ++++++-- tests/helpers/platform.test.ts | 10 ++++++++-- 8 files changed, 43 insertions(+), 13 deletions(-) diff --git a/.claude/agent-memory/archgate-developer/MEMORY.md b/.claude/agent-memory/archgate-developer/MEMORY.md index 6787a483..c6f0f978 100644 --- a/.claude/agent-memory/archgate-developer/MEMORY.md +++ b/.claude/agent-memory/archgate-developer/MEMORY.md @@ -58,6 +58,9 @@ Skipping steps 2 or 3 is a workflow violation. The user should NEVER have to inv - **`Bun.env` modifications in parallel test files leak into integration test subprocesses** — Bun test runner runs all test files in a single process sharing `Bun.env`. Tests that set `Bun.env.HOME`, `Bun.env.GIT_CONFIG_NOSYSTEM`, or `Bun.env.GIT_CONFIG_GLOBAL` (e.g., `auth.test.ts`, `credential-store.test.ts`) modify the shared environment. Integration tests that spawn CLI subprocesses via `runCli()` spread `process.env` (which IS `Bun.env`) into the child, inheriting the leaked values. Symptom: git operations in the subprocess fail with "not a git repo" or similar, but the test passes in isolation. Fix: integration tests that rely on git must explicitly reset git-related env vars in the `runCli` call: `runCli(args, dir, { GIT_CONFIG_NOSYSTEM: "", GIT_CONFIG_GLOBAL: "" })`. Applied in `tests/integration/check.test.ts` for the `--base` tests. - **Cross-command I/O sharing: export from the existing command file, don't create shared files** — When two commands need to share I/O functions (console.log with styleText), you CANNOT put them in `src/helpers/` (ARCH-002 forbids console.log in helpers) or create a new file under `src/commands//` without a register function (ARCH-001 requires register\*Command export, ARCH-016 requires docs heading). The correct pattern: export the shared functions from the command file that already defines them (e.g., `plugin/install.ts` exports `installForEditor()` and `printManualInstructions()`) and import them in the other command. Applied in `upgrade.ts` importing from `./plugin/install`. +- **macOS `/var` → `/private/var` symlink breaks temp dir path comparisons in tests** — On macOS, `/var` is a symlink to `/private/var`. `mkdtempSync(join(tmpdir(), ...))` returns `/var/folders/...` but `process.cwd()` after `chdir()` resolves the symlink to `/private/var/folders/...`. Tests that compare `tempDir` against paths derived from `process.cwd()` or `findProjectRoot()` will fail. Fix: always wrap `mkdtempSync` with `realpathSync` in test setup: `tempDir = realpathSync(mkdtempSync(join(tmpdir(), "archgate-test-")))`. This normalizes the path upfront. Discovered in v0.38.0/v0.39.0 release builds — PR CI runs on ubuntu-latest only, so macOS-specific issues are invisible until the release workflow. +- **Always use `bun run test`, never bare `bun test`, in CI workflows** — The package.json `test` script includes `--timeout 60000`, but bare `bun test` uses Bun's default 5000ms timeout. Tests that perform filesystem operations or spawn subprocesses (e.g., session-context tests) can exceed 5s on slow CI runners. The `release-binaries.yml` Windows step originally used `bun test` and hit timeout failures. Same principle as "never use `bunx prettier` directly" — always prefer `bun run