PhysicalWM / OVOW /scripts /release /check_release.sh
Ravenveil's picture
backup 06_ovow_code 2026-11-08 10:30:30 (part 8)
ef0b17d verified
Raw History Blame Contribute Delete
4.77 kB
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
cd "$ROOT"
command -v git >/dev/null 2>&1 || { echo "[ERROR] git is required" >&2; exit 2; }
command -v python3 >/dev/null 2>&1 || { echo "[ERROR] python3 is required" >&2; exit 2; }
git rev-parse --is-inside-work-tree >/dev/null 2>&1 || {
echo "[ERROR] release check must run from a Git checkout" >&2
exit 2
}
failures=0
pass() { echo "[PASS] $*"; }
fail() { echo "[FAIL] $*" >&2; failures=$((failures + 1)); }
allow_dirty=0
if [[ "${1:-}" == "--allow-dirty" ]]; then
allow_dirty=1
fi
if [[ "$allow_dirty" -eq 0 ]] && [[ -n "$(git status --porcelain)" ]]; then
fail "working tree is not clean"
else
pass "working tree policy"
fi
required=(
LICENSE NOTICE THIRD_PARTY.md README.md README_zh.md
engine/LICENSE
engine/oneposeviagen/fpose/fpose/LICENSE
engine/oneposeviagen/SpaTrackerV2/LICENSE.txt
engine/oneposeviagen/Amodal3R/LICENSE.txt
engine/oneposeviagen/Orientation/orientation_estimation/pose_refinement/LICENSE
engine/oneposeviagen/Orientation/orientation_estimation/data_preprocessing/LICENSE
third_party/Motion324/LICENSE.md
third_party/sam3/LICENSE
third_party/RoMaV2/LICENSE
)
missing=0
for f in "${required[@]}"; do
if [[ ! -f "$f" ]]; then
echo " missing: $f" >&2
missing=$((missing + 1))
fi
done
if [[ "$missing" -eq 0 ]]; then pass "required license and release documents"; else fail "$missing required documents missing"; fi
tracked="$(git ls-files)"
restricted_re='(^|/)(engine/oneposeviagen/locate/models|engine/oneposeviagen/DynamicPose|engine/oneposeviagen/Orientation/wonder3d_oa/multi_view_generation)(/|$)'
restricted="$(printf '%s\n' "$tracked" | grep -Ei "$restricted_re" || true)"
if [[ -z "$restricted" ]]; then
pass "non-redistributable and excluded component paths"
else
printf '%s\n' "$restricted" >&2
fail "restricted component paths are tracked"
fi
artifact_re='(^|/)(\.env$|\.gradio/|\.idea/|\.vscode/|temp_local/|scripts/logs/|outputs?/|ckpts?/|checkpoints?/|dist/|docs/legacy/)|\.(pt|ckpt|safetensors|so|o|pyc|log|pid|pem|key)$'
artifacts="$(printf '%s\n' "$tracked" | grep -Ei "$artifact_re" | grep -Ev '(^|/)\.env\.example$' || true)"
if [[ -z "$artifacts" ]]; then
pass "local configuration, weights, logs, credentials and build artifacts"
else
printf '%s\n' "$artifacts" >&2
fail "local/generated artifacts are tracked"
fi
secret_re='(sk-[A-Za-z0-9_-]{16,}|AKIA[0-9A-Z]{16}|AKID[A-Za-z0-9]{13,}|gh[pousr]_[A-Za-z0-9]{20,}|hf_[A-Za-z0-9]{20,}|AIza[0-9A-Za-z_-]{30,}|xox[baprs]-[A-Za-z0-9-]{10,}|BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY|https?://[^/[:space:]]+:[^/@[:space:]]+@)'
secrets="$(git grep -l -I -E "$secret_re" -- . ':(exclude)scripts/release/check_release.sh' ':(exclude)scripts/release/check_archive.sh' || true)"
if [[ -z "$secrets" ]]; then
pass "common credential signatures"
else
printf '%s\n' "$secrets" >&2
fail "credential-like values detected"
fi
private_path_re='(/dev_[A-Za-z0-9_]+/|/data[0-9]*/(home|miniconda3|anaconda3)/|/root/\.(conda|cache)/|/(home|Users)/[a-z][A-Za-z0-9._-]*/(project|projects|code|work|workspace)/|\b(tos|oss|cos|obs|bos|hdfs|afs)://)'
extra_file="$(dirname "${BASH_SOURCE[0]}")/private_patterns.txt"
if [[ -f "$extra_file" ]]; then
extra="$(grep -vE '^\s*(#|$)' "$extra_file" | paste -sd'|' -)"
[[ -n "$extra" ]] && private_path_re="${private_path_re%\'}|$extra'"
fi
private_paths="$(git grep -l -I -E "$private_path_re" -- . ':(exclude)scripts/release/check_release.sh' ':(exclude)scripts/release/check_archive.sh' || true)"
if [[ -z "$private_paths" ]]; then
pass "developer-specific paths and internal storage URLs"
else
printf '%s\n' "$private_paths" >&2
fail "developer-specific paths or internal URLs detected"
fi
if [[ "$allow_dirty" -eq 1 ]] && ! git rev-parse --verify HEAD >/dev/null 2>&1; then
pass "Git whitespace checks deferred for the initial vendored import"
elif git diff --check --cached && git diff --check; then
pass "Git whitespace checks"
else
fail "Git whitespace checks"
fi
bash_bad=0
while IFS= read -r -d '' f; do
if ! bash -n "$f"; then bash_bad=$((bash_bad + 1)); fi
done < <(git ls-files -z '*.sh')
if [[ "$bash_bad" -eq 0 ]]; then pass "Shell syntax"; else fail "$bash_bad Shell files failed syntax validation"; fi
pycache="$(mktemp -d)"
pywarnings="$(mktemp)"
trap 'rm -rf -- "$pycache"; rm -f -- "$pywarnings"' EXIT
if PYTHONPYCACHEPREFIX="$pycache" python3 -m compileall -q \
engine masking scripts third_party 2>"$pywarnings"; then
pass "Python syntax"
else
sed -n '1,120p' "$pywarnings" >&2
fail "Python syntax"
fi
if [[ "$failures" -ne 0 ]]; then
echo "Release audit failed with $failures finding(s)." >&2
exit 1
fi
echo "Release audit passed."