File tree Expand file tree Collapse file tree
projects/01_api_health_check Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3737 - name : Verify health check detects failures
3838 run : |
3939 # This should fail and return exit code 1
40+ set +e # Temporarily allow failures
4041 bash projects/01_api_health_check/bash/run.sh https://httpbin.org/status/500 || exit_code=$?
42+ set -e # Re-enable exit on error
43+
4144 if [ "$exit_code" != "1" ]; then
42- echo "Health check should exit with code 1 on failure"
45+ echo "Health check should exit with code 1 on failure, got: $exit_code "
4346 exit 1
4447 fi
4548 echo "✓ Health check correctly exits non-zero on failure"
Original file line number Diff line number Diff line change @@ -54,6 +54,11 @@ output/sample_output.json
5454```
5555---
5656
57+ ## CI/CD
58+
59+ This repository uses GitHub Actions for continuous integration.
60+ All automation scripts are tested on push to ensure reliability.
61+
5762## Notes
5863
5964The script exits with a non-zero status when a health check fails, making it
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22set -euo pipefail
33
4- # Run from the project directory or repo root.
4+ # Resolve directories
55SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
66PROJECT_DIR=" $( cd " ${SCRIPT_DIR} /.." && pwd) "
77REPO_ROOT=" $( cd " ${PROJECT_DIR} /../.." && pwd) "
88
99OUTPUT_DIR=" ${PROJECT_DIR} /output"
1010mkdir -p " ${OUTPUT_DIR} "
1111
12+ # Arguments with defaults
1213URL=" ${1:- https:// httpbin.org/ status/ 200} "
1314TIMEOUT=" ${2:- 10} "
1415
15- # Timestamp safe for filenames
16+ # Timestamp for output file
1617TS=" $( date +" %Y%m%d_%H%M%S" ) "
1718OUT_FILE=" ${OUTPUT_DIR} /healthcheck_${TS} .json"
1819
19- source " ${REPO_ROOT} /.venv/Scripts/activate"
20+ # Activate virtual environment (cross-platform)
21+ if [ -f " ${REPO_ROOT} /.venv/Scripts/activate" ]; then
22+ # Windows (Git Bash)
23+ source " ${REPO_ROOT} /.venv/Scripts/activate"
24+ elif [ -f " ${REPO_ROOT} /.venv/bin/activate" ]; then
25+ # Linux/macOS
26+ source " ${REPO_ROOT} /.venv/bin/activate"
27+ else
28+ echo " Error: Virtual environment not found at ${REPO_ROOT} /.venv"
29+ exit 1
30+ fi
2031
32+ # Run health check
2133python " ${PROJECT_DIR} /src/health_check.py" \
2234 --url " ${URL} " \
2335 --timeout " ${TIMEOUT} " \
2436 --out " ${OUT_FILE} "
2537
26- echo " Saved: ${OUT_FILE} "
38+ echo " Saved: ${OUT_FILE} "
Original file line number Diff line number Diff line change 44from datetime import datetime , timezone
55from pathlib import Path
66from typing import Any , Dict , Optional
7- from unittest import result
87
98import requests
109
You can’t perform that action at this time.
0 commit comments