mirror of
https://github.com/multica-ai/multica.git
synced 2026-09-28 13:23:48 +08:00
* MUL-7280: ci(backend): cache race builds per commit and shard pkg/agent onto its own runner backend-tests never warmed its Go build cache: setup-go shares one go.sum-keyed entry across every Linux job, go-vulnerability-scan saved a 95 MB one first, and the test job race-compiled the whole module from scratch on every run. Own the caches explicitly (modules by go.sum, race build objects by commit SHA with prefix fallback, published from main only), compile build and vet in race mode so the objects are shared, and pin -count=1 so a rolling cache cannot replay results against a changed schema. pkg/agent ran as a 139s serial tail at -parallel 2; it is timer-bound and reads no database, so it moves to its own runner without service containers. test-go.sh gains --only regular|agent for that split; the default still runs both halves. Co-authored-by: multica-agent <github@multica.ai> * MUL-7280: ci(backend): make backend-tests the sole Go cache writer and key build objects by image backend-agent-tests restored the module cache through the combined actions/cache action with the same go.sum key as backend-tests. Being faster, it saved first with only pkg/agent's slice of the module graph, and backend-tests then failed to reserve the immutable key: the same first-writer-wins problem this change set out to fix. The agent job now restores both caches read-only, leaving backend-tests as the only writer. The build-cache key also gains ImageOS. Cached cgo and race objects are linked against the runner image's glibc, so an entry must not cross an Ubuntu release when ubuntu-latest rolls forward; setup-go keys on ImageOS for the same reason (actions/setup-go#368). ImageOS is a runner environment variable rather than a context value, so each job resolves the key prefix once in a shell step and the restore and save steps reuse it. Co-authored-by: multica-agent <github@multica.ai> --------- Co-authored-by: J <bohan@devv.ai> Co-authored-by: multica-agent <github@multica.ai>
60 lines
1.5 KiB
Bash
60 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
set -eu
|
|
|
|
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
REPO_ROOT=$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)
|
|
GUARD_SCRIPT="$SCRIPT_DIR/go-test-with-agent-cli-guard.sh"
|
|
|
|
usage() {
|
|
echo "usage: $0 [--race] [--only regular|agent]" >&2
|
|
}
|
|
|
|
# The suite is two `go test` invocations: every package outside pkg/agent at
|
|
# the default parallelism, then pkg/agent throttled (see below). `--only`
|
|
# selects one half so CI can give each its own runner; the default still runs
|
|
# both for `make test`, check.sh, and the release workflow.
|
|
go_test_args=(test)
|
|
only=all
|
|
while [ "$#" -gt 0 ]; do
|
|
case "$1" in
|
|
--race)
|
|
go_test_args+=(-race)
|
|
shift
|
|
;;
|
|
--only)
|
|
case "${2:-}" in
|
|
regular|agent) only=$2 ;;
|
|
*)
|
|
usage
|
|
exit 2
|
|
;;
|
|
esac
|
|
shift 2
|
|
;;
|
|
*)
|
|
usage
|
|
exit 2
|
|
;;
|
|
esac
|
|
done
|
|
|
|
cd "$REPO_ROOT/server"
|
|
|
|
if [ "$only" != agent ]; then
|
|
packages=$(go list ./...)
|
|
regular_packages=()
|
|
for package in $packages; do
|
|
case "$package" in
|
|
*/pkg/agent|*/pkg/agent/*) ;;
|
|
*) regular_packages+=("$package") ;;
|
|
esac
|
|
done
|
|
"$GUARD_SCRIPT" -- go "${go_test_args[@]}" "${regular_packages[@]}"
|
|
fi
|
|
|
|
if [ "$only" != regular ]; then
|
|
# Subprocess-backed agent tests have hard deadlines. Limit both package and
|
|
# within-package parallelism so race builds do not starve their parent loops.
|
|
"$GUARD_SCRIPT" -- go "${go_test_args[@]}" -p 2 -parallel 2 ./pkg/agent/...
|
|
fi
|