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
@@ -773,9 +773,24 @@ echo "--- the greped phrase, against the real apm ---"
|
||||
# The genuine output is then replayed into the real hook through the mock, so
|
||||
# what is asserted is the hook's own matching logic against real apm text —
|
||||
# no pattern is duplicated here to drift out of sync.
|
||||
#
|
||||
# "The real apm" is this repo's pinned one, run through scripts/lib/apm.sh as
|
||||
# `uv run --project <repo root> --frozen apm` (ADR-0034), never whatever apm is
|
||||
# on PATH: that may be an older global install whose wording is not what this
|
||||
# repo ships against. Sourced in a subshell so the helper's git-env scrub and
|
||||
# its functions stay out of this suite's shell. The probe is skipped only when
|
||||
# that apm cannot be run at all (no uv, or `uv sync --frozen` never ran).
|
||||
probe_apm() {
|
||||
(
|
||||
# shellcheck source=scripts/lib/apm.sh
|
||||
source "$REPO_ROOT/scripts/lib/apm.sh"
|
||||
run_apm "$@"
|
||||
)
|
||||
}
|
||||
SKIP_REASON=""
|
||||
if ! command -v apm > /dev/null 2>&1 || ! command -v git > /dev/null 2>&1; then
|
||||
SKIP_REASON="SKIP: apm and git are both required to verify the hook's phrase match against real \`apm outdated\` output — everything above ran, this axis did not"
|
||||
if ! command -v git > /dev/null 2>&1 \
|
||||
|| ! ( source "$REPO_ROOT/scripts/lib/apm.sh" && require_apm_version ) > /dev/null 2>&1; then
|
||||
SKIP_REASON="SKIP: git and the repo-pinned apm (uv sync --frozen) are both required to verify the hook's phrase match against real \`apm outdated\` output — everything above ran, this axis did not"
|
||||
echo " $SKIP_REASON"
|
||||
else
|
||||
PROBE="$(mktemp -d)"
|
||||
@@ -821,13 +836,14 @@ else
|
||||
done
|
||||
echo "deployments: []"
|
||||
} > "$PROBE/consumer/apm.lock.yaml"
|
||||
# env cannot run a shell function, so probe_apm is re-declared in a child bash.
|
||||
(
|
||||
cd "$PROBE/consumer" &&
|
||||
env HOME="$PROBE/home" \
|
||||
GIT_CONFIG_GLOBAL="$PROBE/gitconfig" \
|
||||
GIT_CONFIG_NOSYSTEM=1 \
|
||||
GIT_TERMINAL_PROMPT=0 \
|
||||
apm outdated 2>&1
|
||||
bash -c "$(declare -f probe_apm); REPO_ROOT=\"\$1\"; probe_apm outdated" _ "$REPO_ROOT" 2>&1
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user