File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,11 +53,14 @@ log_info "Checking database connectivity..."
5353cd " $PROJECT_ROOT /api/callcentersite"
5454
5555if [ -f " manage.py" ]; then
56- if python3 manage.py check --database default & > /dev/null ; then
56+ if DB_CHECK_OUTPUT= $( python3 manage.py check --database default 2>&1 ) ; then
5757 log_info " Database connectivity: OK"
5858 CHECKS_PASSED=$(( CHECKS_PASSED + 1 ))
5959 else
6060 log_error " Database connectivity failed"
61+ echo " $DB_CHECK_OUTPUT " | tail -n 20 | while IFS= read -r line; do
62+ log_error " $line "
63+ done
6164 CHECKS_FAILED=$(( CHECKS_FAILED + 1 ))
6265 fi
6366else
6770
6871# Check 4: Django configuration
6972log_info " Checking Django configuration..."
70- if python3 manage.py check & > /dev/null ; then
73+ if DJANGO_CHECK_OUTPUT= $( python3 manage.py check 2>&1 ) ; then
7174 log_info " Django configuration: OK"
7275 CHECKS_PASSED=$(( CHECKS_PASSED + 1 ))
7376else
7477 log_error " Django configuration check failed"
78+ echo " $DJANGO_CHECK_OUTPUT " | tail -n 20 | while IFS= read -r line; do
79+ log_error " $line "
80+ done
7581 CHECKS_FAILED=$(( CHECKS_FAILED + 1 ))
7682fi
7783
Original file line number Diff line number Diff line change 1111# 0 - All checks passed
1212# 1 - One or more checks failed
1313
14- set -e
14+ set -u
15+ set -o pipefail
1516
1617RED=' \033[0;31m'
1718GREEN=' \033[0;32m'
@@ -77,13 +78,30 @@ run_check() {
7778
7879 chmod +x " $check_script "
7980
81+ local exit_code
82+ local output=" "
83+ local previous_errexit=0
84+
85+ if [[ $- == * e* ]]; then
86+ previous_errexit=1
87+ set +e
88+ fi
89+
8090 if [ " $VERBOSE " = true ]; then
8191 " $check_script "
92+ exit_code=$?
8293 else
83- " $check_script " > /dev/null 2>&1
94+ output=$( " $check_script " 2>&1 )
95+ exit_code=$?
8496 fi
8597
86- local exit_code=$?
98+ if [ $previous_errexit -eq 1 ]; then
99+ set -e
100+ fi
101+
102+ if [ " $VERBOSE " != true ] && [ $exit_code -ne 0 ] && [ -n " $output " ]; then
103+ echo " $output "
104+ fi
87105
88106 if [ $exit_code -eq 0 ]; then
89107 log_info " $check_name : PASS"
Original file line number Diff line number Diff line change 1+ import subprocess
2+ from pathlib import Path
3+
4+ REPO_ROOT = Path (__file__ ).resolve ().parents [2 ]
5+ RUN_ALL_CHECKS = REPO_ROOT / "scripts" / "ci" / "run-all-checks.sh"
6+ HEALTH_CHECK = REPO_ROOT / "scripts" / "ci" / "infrastructure" / "health-check.sh"
7+
8+
9+ def _run_script (script_path , * args ):
10+ return subprocess .run (
11+ ["bash" , str (script_path ), * args ],
12+ cwd = REPO_ROOT ,
13+ stdout = subprocess .PIPE ,
14+ stderr = subprocess .PIPE ,
15+ text = True ,
16+ )
17+
18+
19+ def test_run_all_checks_reports_summary_even_on_failure ():
20+ result = _run_script (RUN_ALL_CHECKS )
21+
22+ assert result .returncode != 0 , "Expected the aggregated checks to fail in the default dev environment"
23+ combined_output = f"{ result .stdout } \\ n{ result .stderr } "
24+ assert "FINAL CI/CD REPORT" in combined_output
25+
26+
27+ def test_health_check_surfaces_underlying_error_details ():
28+ result = _run_script (HEALTH_CHECK )
29+
30+ assert result .returncode != 0 , "The health check should fail when dependencies are missing"
31+ combined_output = f"{ result .stdout } \\ n{ result .stderr } "
32+ assert "ModuleNotFoundError" in combined_output or "No module named" in combined_output
You can’t perform that action at this time.
0 commit comments