mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-16 13:03:31 +08:00
Daily pushes should catch policy and path-aware local failures without making every contributor wait for full coverage. The hook now runs a new quality:push entrypoint that reuses the PR quality gate while skipping coverage; verify, quality:pr, and CI still retain the full coverage gate for PR readiness. Constraint: Forks and local contributors need a faster default push path Rejected: Remove coverage from quality:pr | PR readiness and CI still need the ratcheted coverage signal Confidence: high Scope-risk: narrow Directive: Keep pre-push on quality:push; use verify or quality:pr when coverage evidence is required Tested: bun test scripts/pr/quality-contract.test.ts scripts/git-hooks/install.test.ts Tested: bun run check:policy Tested: bun run quality:push Not-tested: Live provider smoke; intentionally remains opt-in
74 lines
1.8 KiB
Bash
Executable File
74 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
git_config() {
|
|
git config --local --get "$1" 2>/dev/null || true
|
|
}
|
|
|
|
is_enabled() {
|
|
case "${1:-}" in
|
|
1|true|TRUE|yes|YES|on|ON)
|
|
return 0
|
|
;;
|
|
*)
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
echo "[pre-push] Running fast pre-push quality gate: bun run quality:push"
|
|
|
|
if is_enabled "$(git_config quality.allowCliCoreChange)"; then
|
|
export ALLOW_CLI_CORE_CHANGE=1
|
|
fi
|
|
|
|
if is_enabled "$(git_config quality.allowMissingTests)"; then
|
|
export ALLOW_MISSING_TESTS=1
|
|
fi
|
|
|
|
if is_enabled "$(git_config quality.allowCoverageBaselineChange)"; then
|
|
export ALLOW_COVERAGE_BASELINE_CHANGE=1
|
|
fi
|
|
|
|
bun run quality:push
|
|
|
|
live="${QUALITY_PRE_PUSH_LIVE:-$(git_config quality.prePushLive)}"
|
|
|
|
if ! is_enabled "$live"; then
|
|
echo "[pre-push] Live model smoke is disabled. Configure it with: bun run hooks:install -- --live-provider-model <selector>"
|
|
exit 0
|
|
fi
|
|
|
|
provider_models="${QUALITY_PRE_PUSH_PROVIDER_MODELS:-${QUALITY_PRE_PUSH_PROVIDER_MODEL:-$(git_config quality.prePushProviderModels)}}"
|
|
|
|
if [[ -z "${provider_models// }" ]]; then
|
|
echo "[pre-push] Live model smoke is enabled, but no provider selector is configured."
|
|
echo "[pre-push] Run: bun run quality:providers"
|
|
echo "[pre-push] Then: bun run hooks:install -- --live-provider-model <selector>"
|
|
exit 1
|
|
fi
|
|
|
|
live_mode="${QUALITY_PRE_PUSH_LIVE_MODE:-$(git_config quality.prePushLiveMode)}"
|
|
live_mode="${live_mode:-smoke}"
|
|
|
|
case "$live_mode" in
|
|
smoke)
|
|
cmd=(bun run quality:smoke)
|
|
;;
|
|
baseline)
|
|
cmd=(bun run quality:gate --mode baseline --allow-live)
|
|
;;
|
|
*)
|
|
echo "[pre-push] Unsupported live mode: $live_mode"
|
|
echo "[pre-push] Use smoke or baseline."
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
for selector in $provider_models; do
|
|
cmd+=(--provider-model "$selector")
|
|
done
|
|
|
|
echo "[pre-push] Running live $live_mode gate with configured provider selector(s)."
|
|
"${cmd[@]}"
|