From 4bff6c4ad70b66bc60c4f1e294cb03c3db1d9336 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 3 Jan 2026 21:36:49 +0000 Subject: [PATCH] Add validate_all.sh script for comprehensive testing - Create validate_all.sh to run all validation checks - Provide clear summary with pass/fail counts - Update scripts/README.md with validate_all documentation - Fix logging.sh path resolution for sourcing Co-authored-by: jmiller-moko <230051081+jmiller-moko@users.noreply.github.com> --- scripts/README.md | 39 +++++++++- scripts/lib/logging.sh | 10 ++- scripts/run/validate_all.sh | 141 ++++++++++++++++++++++++++++++++++++ 3 files changed, 187 insertions(+), 3 deletions(-) create mode 100755 scripts/run/validate_all.sh diff --git a/scripts/README.md b/scripts/README.md index 16c77db..69be32f 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -219,6 +219,38 @@ INFO: Smoke tests completed successfully INFO: ========================================= ``` +### `validate_all.sh` +Runs all validation scripts and provides a comprehensive report: +- Executes all required validation checks +- Executes all optional validation checks +- Provides colored output with pass/fail indicators +- Returns summary with counts + +Usage: +```bash +./scripts/run/validate_all.sh +``` + +Example output: +``` +=== Repository Validation Suite === +INFO: Running all validation checks... + +=== Required Checks === +[SUCCESS] ✓ manifest +[SUCCESS] ✓ xml_wellformed + +=== Optional Checks === +[SUCCESS] ✓ no_secrets +[SUCCESS] ✓ php_syntax +WARN: ✗ tabs (warnings/issues found) + +=== Validation Summary === + Required checks passed: 2/2 + Optional checks passed: 2/8 +[SUCCESS] SUCCESS: All required checks passed +``` + ## Best Practices ### Writing New Scripts @@ -256,7 +288,12 @@ INFO: ========================================= ### Testing Scripts Locally -Run validation scripts before committing: +Run all validation scripts: +```bash +./scripts/run/validate_all.sh +``` + +Run individual validation scripts: ```bash ./scripts/validate/manifest.sh ./scripts/validate/php_syntax.sh diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index 6b83ce7..e2e4cb2 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -35,8 +35,14 @@ set -eu -# Resolve script directory properly -SCRIPT_LIB_DIR="$(cd "$(dirname "$0")" && pwd)" +# Resolve script directory properly - works when sourced +if [ -n "${SCRIPT_DIR:-}" ]; then + # Already set by caller + SCRIPT_LIB_DIR="${SCRIPT_DIR}/lib" +else + # Determine from this file's location + SCRIPT_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)" +fi # Shared utilities . "${SCRIPT_LIB_DIR}/common.sh" diff --git a/scripts/run/validate_all.sh b/scripts/run/validate_all.sh new file mode 100755 index 0000000..d121c9b --- /dev/null +++ b/scripts/run/validate_all.sh @@ -0,0 +1,141 @@ +#!/usr/bin/env bash + +# ============================================================================ +# Copyright (C) 2025 Moko Consulting +# +# This file is part of a Moko Consulting project. +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program (./LICENSE.md). +# ============================================================================ + +# ============================================================================ +# FILE INFORMATION +# ============================================================================ +# DEFGROUP: Script.Run +# INGROUP: Repository.Validation +# REPO: https://github.com/mokoconsulting-tech/moko-cassiopeia +# PATH: /scripts/run/validate_all.sh +# VERSION: 01.00.00 +# BRIEF: Run all validation scripts and report results +# NOTE: Helpful for developers to run all checks before committing +# ============================================================================ + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)" +. "${SCRIPT_DIR}/lib/common.sh" +. "${SCRIPT_DIR}/lib/logging.sh" + +# ---------------------------------------------------------------------------- +# Configuration +# ---------------------------------------------------------------------------- + +REQUIRED_CHECKS=( + "manifest" + "xml_wellformed" +) + +OPTIONAL_CHECKS=( + "changelog" + "language_structure" + "license_headers" + "no_secrets" + "paths" + "php_syntax" + "tabs" + "version_alignment" +) + +# ---------------------------------------------------------------------------- +# Run validations +# ---------------------------------------------------------------------------- + +log_section "Repository Validation Suite" +log_info "Running all validation checks..." +log_separator + +required_passed=0 +required_failed=0 +optional_passed=0 +optional_failed=0 + +# Required checks +log_section "Required Checks" +for check in "${REQUIRED_CHECKS[@]}"; do + script="${SCRIPT_DIR}/validate/${check}.sh" + if [ ! -f "${script}" ]; then + log_error "Script not found: ${script}" + required_failed=$((required_failed + 1)) + continue + fi + + log_step "Running: ${check}" + if "${script}" >/dev/null 2>&1; then + log_success "✓ ${check}" + required_passed=$((required_passed + 1)) + else + log_error "✗ ${check} (FAILED)" + required_failed=$((required_failed + 1)) + fi +done + +echo "" + +# Optional checks +log_section "Optional Checks" +for check in "${OPTIONAL_CHECKS[@]}"; do + script="${SCRIPT_DIR}/validate/${check}.sh" + if [ ! -f "${script}" ]; then + log_warn "Script not found: ${script}" + continue + fi + + log_step "Running: ${check}" + if "${script}" >/dev/null 2>&1; then + log_success "✓ ${check}" + optional_passed=$((optional_passed + 1)) + else + log_warn "✗ ${check} (warnings/issues found)" + optional_failed=$((optional_failed + 1)) + fi +done + +# ---------------------------------------------------------------------------- +# Summary +# ---------------------------------------------------------------------------- + +echo "" +log_separator +log_section "Validation Summary" +log_separator + +log_kv "Required checks passed" "${required_passed}/${#REQUIRED_CHECKS[@]}" +log_kv "Required checks failed" "${required_failed}" +log_kv "Optional checks passed" "${optional_passed}/${#OPTIONAL_CHECKS[@]}" +log_kv "Optional checks with issues" "${optional_failed}" + +log_separator + +if [ "${required_failed}" -gt 0 ]; then + log_error "FAILED: ${required_failed} required check(s) failed" + exit 1 +else + log_success "SUCCESS: All required checks passed" + if [ "${optional_failed}" -gt 0 ]; then + log_warn "Note: ${optional_failed} optional check(s) found issues" + fi + exit 0 +fi