|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Run QA tests for each document in docs/qa/ using codex exec |
| 3 | +set -euo pipefail |
| 4 | + |
| 5 | +# ============================================================ |
| 6 | +# Prompt template — edit here to change what codex exec runs |
| 7 | +# ============================================================ |
| 8 | +# Available placeholder: {file} — replaced with the relative path of each QA doc |
| 9 | +PROMPT_TEMPLATE='读取{file}的文档,执行QA测试。 |
| 10 | +
|
| 11 | +环境信息: |
| 12 | + Portal: http://localhost:3000 (admin / Admin123!) |
| 13 | + Keycloak: http://localhost:8081 (admin / admin) |
| 14 | + Mailpit: http://localhost:8025 |
| 15 | + Grafana: http://localhost:3001 |
| 16 | + Prometheus: http://localhost:9090' |
| 17 | + |
| 18 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 19 | +PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" |
| 20 | +QA_DIR="$PROJECT_ROOT/docs/qa" |
| 21 | + |
| 22 | +# Colors for output |
| 23 | +GREEN='\033[0;32m' |
| 24 | +RED='\033[0;31m' |
| 25 | +YELLOW='\033[0;33m' |
| 26 | +CYAN='\033[0;36m' |
| 27 | +NC='\033[0m' # No Color |
| 28 | + |
| 29 | +# Counters |
| 30 | +total=0 |
| 31 | +passed=0 |
| 32 | +failed=0 |
| 33 | +failed_files=() |
| 34 | + |
| 35 | +echo -e "${CYAN}========================================${NC}" |
| 36 | +echo -e "${CYAN} Auth9 QA Test Runner${NC}" |
| 37 | +echo -e "${CYAN}========================================${NC}" |
| 38 | +echo "" |
| 39 | + |
| 40 | +# Collect all .md files under docs/qa/, excluding README.md |
| 41 | +mapfile -t qa_files < <(find "$QA_DIR" -name '*.md' ! -name 'README.md' | sort) |
| 42 | + |
| 43 | +if [[ ${#qa_files[@]} -eq 0 ]]; then |
| 44 | + echo -e "${YELLOW}No QA documents found in $QA_DIR${NC}" |
| 45 | + exit 0 |
| 46 | +fi |
| 47 | + |
| 48 | +echo -e "Found ${#qa_files[@]} QA document(s) to process." |
| 49 | +echo "" |
| 50 | + |
| 51 | +for file in "${qa_files[@]}"; do |
| 52 | + total=$((total + 1)) |
| 53 | + # Convert to relative path from project root |
| 54 | + rel_path="${file#"$PROJECT_ROOT"/}" |
| 55 | + |
| 56 | + # Build prompt by replacing {file} placeholder |
| 57 | + prompt="${PROMPT_TEMPLATE//\{file\}/$rel_path}" |
| 58 | + |
| 59 | + echo -e "${CYAN}----------------------------------------${NC}" |
| 60 | + echo -e "${CYAN}[$total/${#qa_files[@]}] Processing: ${rel_path}${NC}" |
| 61 | + echo -e "${CYAN}----------------------------------------${NC}" |
| 62 | + |
| 63 | + if codex exec -m gpt-5.1-codex-mini --full-auto "$prompt"; then |
| 64 | + passed=$((passed + 1)) |
| 65 | + echo -e "${GREEN}✓ PASSED: ${rel_path}${NC}" |
| 66 | + else |
| 67 | + failed=$((failed + 1)) |
| 68 | + failed_files+=("$rel_path") |
| 69 | + echo -e "${RED}✗ FAILED: ${rel_path}${NC}" |
| 70 | + fi |
| 71 | + |
| 72 | + echo "" |
| 73 | +done |
| 74 | + |
| 75 | +# Summary |
| 76 | +echo -e "${CYAN}========================================${NC}" |
| 77 | +echo -e "${CYAN} Summary${NC}" |
| 78 | +echo -e "${CYAN}========================================${NC}" |
| 79 | +echo -e "Total: $total" |
| 80 | +echo -e "${GREEN}Passed: $passed${NC}" |
| 81 | +echo -e "${RED}Failed: $failed${NC}" |
| 82 | + |
| 83 | +if [[ ${#failed_files[@]} -gt 0 ]]; then |
| 84 | + echo "" |
| 85 | + echo -e "${RED}Failed files:${NC}" |
| 86 | + for f in "${failed_files[@]}"; do |
| 87 | + echo -e " ${RED}- $f${NC}" |
| 88 | + done |
| 89 | + exit 1 |
| 90 | +fi |
| 91 | + |
| 92 | +echo "" |
| 93 | +echo -e "${GREEN}All QA tests passed!${NC}" |
0 commit comments