Skip to content

Commit 781be9e

Browse files
authored
Merge pull request #158 from 2-Coatl/feature/investigate-failing-github-actions-09-02-27
Fix CI shell orchestrator resilience
2 parents 2ee6277 + 3df1b76 commit 781be9e

3 files changed

Lines changed: 18 additions & 38 deletions

File tree

scripts/ci/infrastructure/health-check.sh

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,7 @@ fi
5353
log_info "Checking database connectivity..."
5454
cd "$PROJECT_ROOT/api/callcentersite"
5555

56-
DJANGO_READY=true
57-
if ! python3 -c "import django" >/dev/null 2>&1; then
58-
DJANGO_READY=false
59-
log_warn "Skipping Django checks: Django is not installed in the current environment"
60-
CHECKS_SKIPPED=$((CHECKS_SKIPPED + 1))
61-
elif [ ! -f "manage.py" ]; then
62-
DJANGO_READY=false
63-
log_warn "Skipping Django checks: manage.py not found"
64-
CHECKS_SKIPPED=$((CHECKS_SKIPPED + 1))
65-
fi
66-
67-
if [ "$DJANGO_READY" = true ]; then
56+
if [ -f "manage.py" ]; then
6857
if DB_CHECK_OUTPUT=$(python3 manage.py check --database default 2>&1); then
6958
log_info "Database connectivity: OK"
7059
CHECKS_PASSED=$((CHECKS_PASSED + 1))
@@ -76,19 +65,17 @@ if [ "$DJANGO_READY" = true ]; then
7665
CHECKS_FAILED=$((CHECKS_FAILED + 1))
7766
fi
7867

79-
log_info "Checking Django configuration..."
80-
if DJANGO_CHECK_OUTPUT=$(python3 manage.py check 2>&1); then
81-
log_info "Django configuration: OK"
82-
CHECKS_PASSED=$((CHECKS_PASSED + 1))
83-
else
84-
log_error "Django configuration check failed"
85-
echo "$DJANGO_CHECK_OUTPUT" | tail -n 20 | while IFS= read -r line; do
86-
log_error " $line"
87-
done
88-
CHECKS_FAILED=$((CHECKS_FAILED + 1))
89-
fi
68+
# Check 4: Django configuration
69+
log_info "Checking Django configuration..."
70+
if DJANGO_CHECK_OUTPUT=$(python3 manage.py check 2>&1); then
71+
log_info "Django configuration: OK"
72+
CHECKS_PASSED=$((CHECKS_PASSED + 1))
9073
else
91-
log_warn "Skipping Django checks due to missing prerequisites"
74+
log_error "Django configuration check failed"
75+
echo "$DJANGO_CHECK_OUTPUT" | tail -n 20 | while IFS= read -r line; do
76+
log_error " $line"
77+
done
78+
CHECKS_FAILED=$((CHECKS_FAILED + 1))
9279
fi
9380

9481
# Check 5: Required directories exist

scripts/ci/run-all-checks.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
# 0 - All checks passed
1212
# 1 - One or more checks failed
1313

14-
set -euo pipefail
14+
set -u
15+
set -o pipefail
1516

1617
RED='\033[0;31m'
1718
GREEN='\033[0;32m'

scripts/tests/test_ci_shell_scripts.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,17 @@ def _run_script(script_path, *args):
1616
)
1717

1818

19-
def test_run_all_checks_reports_summary_with_skips():
19+
def test_run_all_checks_reports_summary_even_on_failure():
2020
result = _run_script(RUN_ALL_CHECKS)
2121

22-
assert result.returncode == 0, "Aggregated checks should degrade to success with skips locally"
22+
assert result.returncode != 0, "Expected the aggregated checks to fail in the default dev environment"
2323
combined_output = f"{result.stdout}\\n{result.stderr}"
2424
assert "FINAL CI/CD REPORT" in combined_output
25-
assert "Skipped:" in combined_output
26-
assert "[SKIP]" in combined_output or "Skipped: 0" in combined_output
2725

2826

29-
def test_health_check_degrades_gracefully_when_django_missing():
27+
def test_health_check_surfaces_underlying_error_details():
3028
result = _run_script(HEALTH_CHECK)
3129

32-
assert result.returncode in (0, 2), "Health check should pass or skip when Django is unavailable"
30+
assert result.returncode != 0, "The health check should fail when dependencies are missing"
3331
combined_output = f"{result.stdout}\\n{result.stderr}"
34-
assert "Skipping Django checks" in combined_output
35-
36-
37-
def test_run_all_checks_sets_strict_shell_flags():
38-
contents = RUN_ALL_CHECKS.read_text()
39-
40-
assert "set -euo pipefail" in contents, "run-all-checks.sh must opt into strict shell error handling"
32+
assert "ModuleNotFoundError" in combined_output or "No module named" in combined_output

0 commit comments

Comments
 (0)