Add enterprise features: timeout handling, duration tracking, and health checking

- Add timeout handling to PHP syntax validation
- Add execution duration tracking to smoke_test and validate_all
- Create script_health.sh to validate enterprise standards compliance
- Enhance error messages with better context and actionable guidance
- Add log_duration helper function to common.sh
- Update ENTERPRISE.md and README.md with new features
- All scripts now follow complete enterprise standards

Co-authored-by: jmiller-moko <230051081+jmiller-moko@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-03 23:12:40 +00:00
parent f2b8bc9003
commit 0341131f18
8 changed files with 307 additions and 11 deletions

View File

@@ -35,6 +35,8 @@
set -euo pipefail
# Validation timeout (seconds) - prevents hanging on problematic files
TIMEOUT="${VALIDATION_TIMEOUT:-30}"
SRC_DIR="${SRC_DIR:-src}"
json_escape() {
@@ -56,17 +58,34 @@ fi
failed=0
checked=0
failed_files=()
while IFS= read -r -d '' f; do
checked=$((checked+1))
if ! php -l "$f" >/dev/null; then
failed=1
# Use timeout if available to prevent hangs
if command -v timeout >/dev/null 2>&1; then
if ! timeout "${TIMEOUT}" php -l "$f" >/dev/null 2>&1; then
failed=1
failed_files+=("$f")
fi
else
if ! php -l "$f" >/dev/null 2>&1; then
failed=1
failed_files+=("$f")
fi
fi
done < <(find "${SRC_DIR}" -type f -name '*.php' -print0)
if [ "${failed}" -ne 0 ]; then
printf '{"status":"fail","error":"php_lint_failed","files_checked":%s}
' "${checked}"
{
printf '{"status":"fail","error":"php_lint_failed","files_checked":%s,"failed_count":%s,"failed_files":[' "${checked}" "${#failed_files[@]}"
for i in "${!failed_files[@]}"; do
printf '%s' "$(json_escape "${failed_files[$i]}")"
[ "$i" -lt $((${#failed_files[@]} - 1)) ] && printf ','
done
printf ']}\n'
}
exit 1
fi