mirror of
https://github.com/coder/coder.git
synced 2026-10-16 14:48:56 +08:00
test: add memory guard and heap profiles for CI timeouts Add a memory guard to `cli`, `agent`, and `enterprise/cli` to diagnose recurring macOS `test-go-pg` timeouts. Recent logs show runaway memory usage and heavy swapping, but the allocation source remains unknown. - Check Go runtime memory once per second, with per-process CI limits of 5 GiB on macOS and 6 GiB on Linux and Windows. Disabled when `CODER_TEST_MEMORY_LIMIT_MIB` is unset. - On exceeding the limit, save a heap profile, attempt a second profile after forced GC with a five-second wait limit, then panic with memory usage, profile paths, and all goroutine stacks. - Upload heap profiles from unsuccessful CI jobs on every OS, retaining them for seven days. - Test guard lifecycle, environment parsing, panic diagnostics, profile validity, and post-GC allocation attribution. Validate with race tests, vet, lint, and a manual macOS test. Refs https://linear.app/codercom/issue/PLAT-251/flake-test-go-pg-macos-job-timeoutcancelled Refs https://github.com/coder/internal/issues/1365