This commit introduces a new /core:qa command to automate the quality assurance process. The command can be run with the following options: - No flags: Runs the full QA suite (linting and tests). - --quick: Runs only the linters for a fast feedback loop. - --fix: Runs the full QA suite and iteratively attempts to fix issues using the project's auto-formatter. The command detects the project type (Go or PHP) and runs the appropriate QA tools. This addresses the user's request to have an automated and iterative QA command.
89 lines
1.4 KiB
Bash
Executable file
89 lines
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
# Core QA command logic
|
|
|
|
# --- Flags ---
|
|
FIX=false
|
|
QUICK=false
|
|
while [[ "$#" -gt 0 ]]; do
|
|
case "$1" in
|
|
--fix)
|
|
FIX=true
|
|
shift
|
|
;;
|
|
--quick)
|
|
QUICK=true
|
|
shift
|
|
;;
|
|
*)
|
|
# Unknown arg, shift past it
|
|
shift
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# --- Project Detection ---
|
|
PROJECT_TYPE=""
|
|
if [ -f "go.mod" ]; then
|
|
PROJECT_TYPE="go"
|
|
elif [ -f "composer.json" ]; then
|
|
PROJECT_TYPE="php"
|
|
else
|
|
echo "Could not determine project type (go.mod or composer.json not found)."
|
|
exit 1
|
|
fi
|
|
|
|
# --- QA Functions ---
|
|
run_qa() {
|
|
if [ "$PROJECT_TYPE" = "go" ]; then
|
|
core go qa
|
|
else
|
|
core php qa
|
|
fi
|
|
}
|
|
|
|
run_lint() {
|
|
if [ "$PROJECT_TYPE" = "go" ]; then
|
|
core go lint
|
|
else
|
|
core php pint --test
|
|
fi
|
|
}
|
|
|
|
run_fix() {
|
|
if [ "$PROJECT_TYPE" = "go" ]; then
|
|
core go fmt
|
|
else
|
|
core php pint
|
|
fi
|
|
}
|
|
|
|
# --- Main Logic ---
|
|
if [ "$QUICK" = true ]; then
|
|
echo "Running in --quick mode (lint only)..."
|
|
run_lint
|
|
exit $?
|
|
fi
|
|
|
|
echo "Running QA for $PROJECT_TYPE project..."
|
|
MAX_ITERATIONS=3
|
|
for i in $(seq 1 $MAX_ITERATIONS); do
|
|
echo "--- Iteration $i ---"
|
|
run_qa
|
|
EXIT_CODE=$?
|
|
|
|
if [ $EXIT_CODE -eq 0 ]; then
|
|
echo "✓ QA Passed"
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$FIX" = false ]; then
|
|
echo "✗ QA Failed"
|
|
exit $EXIT_CODE
|
|
fi
|
|
|
|
echo "QA failed. Attempting to fix..."
|
|
run_fix
|
|
done
|
|
|
|
echo "✗ QA failed after $MAX_ITERATIONS iterations."
|
|
exit 1
|