diff --git a/AGENTS.md b/AGENTS.md index 2bf925d..460e67d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -56,12 +56,13 @@ Tests in `go-runner/src/integration_tests.rs` use real Go projects from `go-runn - `CODSPEED_RUNNER_MODE` — `walltime` (default), `simulation`, or `memory` - `CODSPEED_PROFILE_FOLDER` — where results are written (default: `/tmp`) - `CODSPEED_LOG` — log level filter (default: `info`) +- `GOCACHE`, `GOMODCACHE` — used as is when set (default: fresh temp dirs per run) ## Gotchas - `instrument-hooks.go` requires cgo (`import "C"`). The runner sets `CGO_ENABLED=1` and checks for a C compiler before building. Without this, Go silently excludes the file causing "undefined: InstrumentHooks" errors. - The runner uses `$GOROOT/bin/go` directly (not PATH) to avoid infinite recursion with the runner binary intercepting `go test`. -- The runner sets custom `GOCACHE` and `GOMODCACHE` to temp dirs to avoid cache conflicts. +- The runner sets custom `GOCACHE` and `GOMODCACHE` to temp dirs to avoid cache conflicts, unless they are already set. - Overlay patches are maintained as `.patch` files alongside the full `.go` files in `go-runner/overlay/`. Use `update-patch.sh` to regenerate. ## Release Process diff --git a/go-runner/src/runner/mod.rs b/go-runner/src/runner/mod.rs index e8d92c2..27f80b1 100644 --- a/go-runner/src/runner/mod.rs +++ b/go-runner/src/runner/mod.rs @@ -66,9 +66,13 @@ fn run_cmd>( cmd.args(&cli.packages); cmd.current_dir(dir); - // Create isolated Go caches to avoid conflicts when tests run concurrently - cmd.env("GOCACHE", _dir.path().join("gocache")); - cmd.env("GOMODCACHE", _dir.path().join("gomodcache")); + // Create isolated Go caches to avoid conflicts when tests run concurrently. + // Caches set by the user are kept, so CI can restore the build cache between runs. + for (var, cache_dir) in [("GOCACHE", "gocache"), ("GOMODCACHE", "gomodcache")] { + if std::env::var_os(var).is_none_or(|v| v.is_empty()) { + cmd.env(var, _dir.path().join(cache_dir)); + } + } // The overlay includes instrument-hooks.go which uses cgo (`import "C"`). // If CGO_ENABLED=0 (e.g. no C compiler on a bare metal runner), Go silently