CI / ci (push) Canceled after 0s
Port classis full-test.sh (071966e) as Museion's one-command verify loop: run/start/status/summary over detached xcodebuild, per-run pinned xcresult bundles with atomic run-dir allocation (#33/#179), xcresulttool-authoritative counts (#31/#178), zero-match filters fail (#31/#134), --serialized rerun is the record (#30/#147), per- test timeouts + wedge observability (#134). Default scope: MuseionTests. install-hooks.sh + pre-push: no push while any run is live, lint gate scoped to the push's Swift files (bare swiftlint . exits 2 on main — spike/ + one tests file), autofix-rewrite guard. New-ref pushes lint the merge-base delta vs refs/remotes/origin/main and fail closed on unscopable history; a full-ref spelling defeats refs/tags shadowing. scripts/test-full-test.sh: 23-check acceptance rig with an executed-count guard. Four finish-audit rounds; every guard flip-verified both directions. Suite 692/692 through the rail itself. Closes #190
103 lines
4.6 KiB
Bash
Executable File
103 lines
4.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# pre-push — lint gate + no-push-while-testing guard + autofix-tree guard (#190).
|
|
#
|
|
# Ports the classis pre-push (classis #679/#684 classes) to Museion:
|
|
# 1. no push while a full-test run is live — concurrent load flakes the
|
|
# real-process suites (#30), and pushing mid-verification defeats the run;
|
|
# 2. lint gate scoped to the push's own Swift files — failing closed on
|
|
# violations there (the repo tree carries pre-existing findings a bare
|
|
# repo-wide gate could never clear);
|
|
# 3. autofix guard — a lint autofix pass that rewrites files AFTER
|
|
# verification must not ride the push untested: the push fails, the
|
|
# rewrite gets reviewed and re-verified via scripts/full-test.sh.
|
|
# Pre-existing unrelated dirt only warns.
|
|
#
|
|
# Installed via scripts/install-hooks.sh (git config core.hooksPath scripts/hooks).
|
|
|
|
set -euo pipefail
|
|
|
|
ROOT="$(git rev-parse --show-toplevel)"
|
|
cd "$ROOT"
|
|
|
|
# GUI git clients (Xcode, …) inherit launchd's sparse PATH, which lacks
|
|
# Homebrew — resolve the lint tools from the standard tool dirs.
|
|
# Append-only: the caller's PATH keeps priority.
|
|
for dir in /opt/homebrew/bin /usr/local/bin; do
|
|
if [[ -d "$dir" && ":$PATH:" != *":$dir:"* ]]; then
|
|
PATH="$PATH:$dir"
|
|
fi
|
|
done
|
|
export PATH
|
|
|
|
# 1. Never push while ANY full-test run is live: concurrent load flakes the
|
|
# real-process suites (#30), and pushing mid-verification defeats the run.
|
|
# Concurrent runs each pin their own dir (#190) — `current` only names the
|
|
# newest, so scan every run dir for a live pid.
|
|
live=""
|
|
for d in _build/full-test/*/; do
|
|
[[ -f "${d}pid" ]] || continue
|
|
p="$(cat "${d}pid")"
|
|
kill -0 "$p" 2>/dev/null && live="$live $d(pid $p)"
|
|
done
|
|
if [[ -n $live ]]; then
|
|
echo "pre-push: full-test run(s) live:$live — wait for them, then push." >&2
|
|
exit 1
|
|
fi
|
|
|
|
# 2. Lint gate, scoped to THIS PUSH's Swift files (#190): the repo tree
|
|
# carries pre-existing swiftlint findings (warning noise repo-wide,
|
|
# error-severity in spike/ experiments and one tests file) — a bare
|
|
# `swiftlint .` gate can never pass here and would block every push.
|
|
# The gate is the push's own files; no Swift in the push → nothing to gate.
|
|
before="$(git status --porcelain)"
|
|
zero=0000000000000000000000000000000000000000
|
|
# Default-branch base for NEW-ref scoping: the project's default branch at
|
|
# origin, as a FULL ref — short names resolve refs/tags/ first, so a fetched
|
|
# tag "origin/main" would shadow the remote ref. Hardcoded, not $1-derived:
|
|
# pushes to other remotes or by URL are still scoped against origin/main,
|
|
# which is correct for this project's delta. A remote with a divergent
|
|
# default would need its own scoping — add per-remote resolution then.
|
|
default_ref="refs/remotes/origin/main"
|
|
swift_files=()
|
|
while read -r lref lsha rref rsha; do
|
|
[[ "$lsha" == "$zero" ]] && continue # ref deletion — no content to lint
|
|
if [[ "$rsha" == "$zero" ]]; then
|
|
# NEW ref: lint the delta against the default branch, never the whole
|
|
# tree (pre-existing violations could never clear it). No resolvable
|
|
# base FAILS CLOSED — a silent skip is a vacuous pass (#31/#134 class).
|
|
base="$(git merge-base "$lsha" "$default_ref" 2>/dev/null || true)"
|
|
[[ -n "$base" ]] || {
|
|
echo "pre-push: no common history with $default_ref — cannot scope the lint gate (orphan branch or missing default ref); refusing." >&2
|
|
exit 1
|
|
}
|
|
range=("$base" "$lsha")
|
|
else
|
|
range=("$rsha" "$lsha")
|
|
fi
|
|
while IFS= read -r f; do swift_files+=("$f"); done < <(git diff --name-only --diff-filter=ACMR "${range[@]}" -- '*.swift')
|
|
done
|
|
# NOTE: lints the WORKING-TREE copies of the pushed files, not the pushed
|
|
# blobs — a local uncommitted fix lints clean while the broken blob ships.
|
|
# Inherent to worktree pre-push hooks; blob-lint via `git show` if it bites.
|
|
if [[ ${#swift_files[@]} -gt 0 ]]; then
|
|
if ! { swiftformat "${swift_files[@]}" && swiftlint lint --quiet "${swift_files[@]}"; }; then
|
|
echo "pre-push: linters failed — fix the violations above, then push again." >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# 3. Autofix guard: if the pass MODIFIED anything, the pushed commits no
|
|
# longer match the verified tree. Review, re-verify (scripts/full-test.sh),
|
|
# commit, push again. Pre-existing unrelated dirt only warns.
|
|
after="$(git status --porcelain)"
|
|
if [[ $before != "$after" ]]; then
|
|
echo "pre-push: linters MODIFIED the working tree:" >&2
|
|
git status --short >&2
|
|
echo "Review these, re-run scripts/full-test.sh, commit the results, push again." >&2
|
|
exit 1
|
|
fi
|
|
if [[ -n $after ]]; then
|
|
echo "pre-push: note — unrelated uncommitted changes present (not blocked):" >&2
|
|
git status --short >&2
|
|
fi
|