feat(scripts): run the apm gates through the uv-pinned apm
Add scripts/lib/apm.sh, the one place the repo spells its apm command: `uv run --project <repo root> --frozen apm`. --project comes from the helper's own location, so it names the repo root even when apm runs inside plugins/<name>/. Sourcing it keeps the git-env scrub (#204), and require_apm_version fails with a clear message, naming `uv sync --frozen`, when the resolved apm is below 0.39.2, unreadable, or uv is missing. APM overrides the command, as ADR-0034 provides. apm-audit-ci.sh and apm-pack-check-clean.sh use it. The audit script's matching logic is unchanged; only its verified-against note now records 0.39.3. tests/test-apm-gate-invocation.sh is seam B: a fake uv and a stub apm first on a PATH without the real ones. It proves the command shape, --project from a plugin directory, the scrub, and the version floor. test-apm-hooks-git-env.sh reaches its stub through a fake uv, and the real-apm probe in test-apm-current-hook.sh now runs the pinned apm. Refs: #271 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
1 parent
d15688ee99
commit
7291b46271
6 files changed
+345
-18
No files matched your search
@@ -13,10 +13,15 @@
|
||||
# and `git checkout` inside a fresh `mktemp -d` -- and each hook script is run
|
||||
# from a linked worktree of a throwaway repo with GIT_DIR exported the way git
|
||||
# exports it. Nothing here touches the repo this suite lives in.
|
||||
#
|
||||
# The hooks run apm as `uv run --project <repo root> --frozen apm` (ADR-0034,
|
||||
# scripts/lib/apm.sh), so a fake `uv` sits beside the stub and hands everything
|
||||
# after `apm` to it. tests/test-apm-gate-invocation.sh pins that command shape;
|
||||
# this suite only needs the call to land on the stub.
|
||||
set -euo pipefail
|
||||
|
||||
# This suite builds its own repos; it must never inherit the caller's.
|
||||
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_COMMON_DIR
|
||||
unset APM GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_COMMON_DIR
|
||||
export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
@@ -34,7 +39,8 @@ g() { git -c user.name=fixture -c [email protected] "$@"; }
|
||||
|
||||
# Builds <dir>/main (two commits on `main`) and <dir>/wt, a linked worktree on
|
||||
# branch `feature`, with a plugins/demo/ package dir so the audit script's
|
||||
# per-package loop has something to iterate. Also writes <dir>/bin/apm, the stub.
|
||||
# per-package loop has something to iterate. Also writes <dir>/bin/apm, the stub,
|
||||
# and <dir>/bin/uv, the fake that reaches it.
|
||||
make_fixture() {
|
||||
local dir="$1"
|
||||
mkdir -p "$dir/bin"
|
||||
@@ -51,8 +57,18 @@ make_fixture() {
|
||||
local locked
|
||||
locked="$(g -C "$dir/main" rev-parse HEAD~1)"
|
||||
|
||||
cat > "$dir/bin/uv" <<EOF
|
||||
#!/usr/bin/env bash
|
||||
[[ "\${1:-}" == run && "\${5:-}" == apm ]] || { echo "fake uv: unexpected argv: \$*" >&2; exit 97; }
|
||||
shift 5
|
||||
exec "$dir/bin/apm" "\$@"
|
||||
EOF
|
||||
chmod +x "$dir/bin/uv"
|
||||
|
||||
# --version answers above the gates' 0.39.2 floor and records nothing.
|
||||
cat > "$dir/bin/apm" <<EOF
|
||||
#!/usr/bin/env bash
|
||||
if [[ "\${1:-}" == --version ]]; then echo "apm version 0.39.3"; exit 0; fi
|
||||
printf '%s\n' "\${GIT_DIR-<unset>}" >> "$dir/apm-saw-git-dir"
|
||||
tmp="\$(mktemp -d)"
|
||||
( cd "\$tmp" && git init -q . >/dev/null 2>&1; git checkout -q --detach $locked >/dev/null 2>&1 ) || true
|
||||
|
||||
Reference in new issue
Block a user