forked from deftdot/devops-leaders-course-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_checks.sh
More file actions
executable file
·53 lines (44 loc) · 1.04 KB
/
run_checks.sh
File metadata and controls
executable file
·53 lines (44 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
set +e # Continue on errors
declare -A results
failures=()
run_step() {
local name=$1
local cmd=$2
echo
echo "--- $name ---"
eval "$cmd"
local rc=$?
results["$name"]=$rc
if [ $rc -ne 0 ]; then
failures+=("$name")
fi
}
echo "============================"
echo " Running Simplified Test Suite"
echo "============================"
run_step "Unit Tests" "pytest -v test_main.py"
run_step "Formatting Check (black)" "black --line-length 120 --check ."
run_step "Security Check (bandit)" "bandit -r . --exclude ./venv -lll"
run_step "Dependency Audit (pip-audit)" "pip-audit -r requirements.txt"
echo
echo "============================"
echo " Summary"
echo "============================"
for name in "${!results[@]}"; do
status="[FAIL]"
[ "${results[$name]}" -eq 0 ] && status="[PASS]"
printf "%s %s\n" "$status" "$name"
done
if [ ${#failures[@]} -gt 0 ]; then
echo
echo "Failures:"
for step in "${failures[@]}"; do
echo " - $step"
done
exit 1
else
echo
echo "All checks passed successfully."
exit 0
fi