predeploy-runner-abhishek 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ """
2
+ predeploy_runner package
3
+ """
4
+ from predeploy_runner.runner import verify_environment, check_tcp_service
5
+
6
+ __all__ = ["verify_environment", "check_tcp_service"]
7
+ __version__ = "0.1.0"
@@ -0,0 +1,88 @@
1
+ """
2
+ Simple, reusable pre-deployment gate runner tailored for Day 4 Film Review Platform.
3
+ Performs:
4
+ 1. Environment variables check
5
+ 2. TCP connectivity check (Database, Redis, etc.)
6
+ """
7
+ import os
8
+ import sys
9
+ import socket
10
+ from typing import List, Tuple
11
+ from urllib.parse import urlparse
12
+
13
+ # Default required environment variables for Day 4 Film Review Platform
14
+ DEFAULT_REQUIRED_VARS = [
15
+ "TOKEN_ACCESS_TOKEN_EXPIRE_MINUTES",
16
+ "TOKEN_REFRESH_TOKEN_EXPIRE_DAYS",
17
+ "API_VERSION",
18
+ "REDIS_URL",
19
+ "AWS_SECRET_ID",
20
+ "AWS_SECRETS_ENDPOINT_URL",
21
+ ]
22
+
23
+
24
+ def verify_environment(required_vars: List[str]) -> Tuple[bool, List[str]]:
25
+ """Check that all required environment variables are set and non-empty."""
26
+ missing = [var for var in required_vars if not os.getenv(var)]
27
+ return len(missing) == 0, missing
28
+
29
+
30
+ def check_tcp_service(host: str, port: int, timeout: float = 3.0) -> bool:
31
+ """Verify TCP connectivity to a host and port."""
32
+ try:
33
+ with socket.create_connection((host, port), timeout=timeout):
34
+ return True
35
+ except OSError:
36
+ return False
37
+
38
+
39
+ def check_url_connectivity(url: str, default_port: int = 80, timeout: float = 3.0) -> bool:
40
+ """Extract host and port from URL and verify TCP reachability."""
41
+ if not url:
42
+ return False
43
+ parsed = urlparse(url)
44
+ host = parsed.hostname or "localhost"
45
+ port = parsed.port or default_port
46
+ return check_tcp_service(host, port, timeout=timeout)
47
+
48
+
49
+ def main() -> None:
50
+ """CLI Entrypoint for pre-deploy gate checks."""
51
+ print("==========================================================")
52
+ print("==> [Pre-Deployment Gate] Step 1: Environment Variables")
53
+ print("==========================================================")
54
+
55
+ # Allow custom comma-separated list, or use Day 4 defaults
56
+ custom_vars = os.getenv("PREDEPLOY_REQUIRED_VARS")
57
+ if custom_vars:
58
+ vars_to_check = [v.strip() for v in custom_vars.split(",") if v.strip()]
59
+ else:
60
+ vars_to_check = DEFAULT_REQUIRED_VARS
61
+
62
+ ok, missing = verify_environment(vars_to_check)
63
+ if not ok:
64
+ print(f"[FATAL] Pre-deployment checks failed! Missing variables: {', '.join(missing)}", file=sys.stderr)
65
+ print("Refusing to start application in an unconfigured state.", file=sys.stderr)
66
+ sys.exit(1)
67
+
68
+ print(f"[SUCCESS] All {len(vars_to_check)} required environment variables are present.")
69
+
70
+ # Step 2: Check Redis URL reachability if specified
71
+ redis_url = os.getenv("REDIS_URL")
72
+ if redis_url:
73
+ print("==========================================================")
74
+ print("==> [Pre-Deployment Gate] Step 2: Redis Service Reachability")
75
+ print("==========================================================")
76
+ # If reachable or skipped in test mode
77
+ if check_url_connectivity(redis_url, default_port=6379, timeout=2.0):
78
+ print("[SUCCESS] Redis service connection verified.")
79
+ else:
80
+ print(f"[WARNING] Could not connect to Redis at {redis_url} (ignoring if mock/local).")
81
+
82
+ print("==========================================================")
83
+ print("==> [Pre-Deployment Gate] All pre-deployment checks passed!")
84
+ print("==========================================================")
85
+
86
+
87
+ if __name__ == "__main__":
88
+ main()
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.5
2
+ Name: predeploy-runner-abhishek
3
+ Version: 0.1.0
4
+ Summary: A lightweight, reusable pre-deployment gate runner for Python services
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+
8
+ # Pre-Deployment Runner
9
+
10
+ A lightweight, reusable pre-deployment gate runner for Python services.
11
+
12
+ ## Overview
13
+
14
+ Validates environment variables and health status before starting critical services.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ uv add predeploy-runner-abhishek
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ Set `PREDEPLOY_REQUIRED_VARS` as a comma-separated list:
25
+
26
+ ```bash
27
+ export PREDEPLOY_REQUIRED_VARS="DATABASE_URL,REDIS_URL,API_PORT"
28
+ pre-deploy-runner
29
+ ```
@@ -0,0 +1,6 @@
1
+ predeploy_runner/__init__.py,sha256=lupWh0rkBochs2qxw1BOr71GU7lumGPBDjS0NcOJBYs,184
2
+ predeploy_runner/runner.py,sha256=BUvzywuOovDkNDlxF4h5UVNW2JsjehF1MZ5C9cWlhJI,3314
3
+ predeploy_runner_abhishek-0.1.0.dist-info/METADATA,sha256=tXHFqap-VSx_l8gvaM56Ovtlec1C-Qbml_b-QId0xAA,637
4
+ predeploy_runner_abhishek-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
5
+ predeploy_runner_abhishek-0.1.0.dist-info/entry_points.txt,sha256=BTLsqKw2ZD9MN5_fCo4ZVqADypjxIl_ZPKgRntiXLBM,67
6
+ predeploy_runner_abhishek-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ pre-deploy-runner = predeploy_runner.runner:main