Skip to content

Commit 58dc400

Browse files
committed
Correcting bot commit
1 parent 92bca5c commit 58dc400

33 files changed

Lines changed: 967 additions & 23 deletions
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Integration Tests
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
integration-tests:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Set up Python
12+
uses: actions/setup-python@v4
13+
with:
14+
python-version: '3.11'
15+
- name: Install system deps (docker-compose)
16+
run: |
17+
sudo apt-get update
18+
sudo apt-get install -y docker.io docker-compose-plugin
19+
- name: Install Poetry
20+
run: pip install poetry
21+
- name: Install dependencies
22+
run: poetry install --with dev
23+
- name: Start integration services
24+
run: |
25+
docker compose -f tests/integration/docker-compose.yml up -d
26+
- name: Wait for services
27+
run: |
28+
for i in {1..30}; do
29+
if curl -sS http://localhost:9200/ >/dev/null 2>&1; then break; fi
30+
sleep 1
31+
done
32+
- name: Run integration tests
33+
env:
34+
RUN_INTEGRATION: '1'
35+
run: poetry run pytest -q tests/integration -m integration
36+
- name: Tear down services
37+
if: always()
38+
run: docker compose -f tests/integration/docker-compose.yml down -v

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ Skeleton project for RAG/LLM orchestration inspired by the anomaly-detector impl
44

55
Quick start
66

7-
- Install dependencies: poetry install
8-
- Run tests: poetry run pytest -q
9-
- To run the PaS estimator locally:
107
- poetry run python tools/pas_estimate.py
118

129
Local development (quick)
@@ -48,13 +45,6 @@ python scripts/update_checklist.py --file checklist.md --index 3
4845

4946
Project structure
5047

51-
- infra/: CDK stack and infra code
52-
- src/rag_api/: FastAPI application and retriever code
53-
- src/orchestrator/: Step Functions / workflow skeleton
54-
- config/: environment YAMLs
55-
- scripts/: deployment and packaging scripts (dry-run by default)
56-
- tools/: PaS estimator and CI helpers
57-
- tests/: unit tests
5848

5949
Docker
6050

@@ -69,3 +59,13 @@ Run container (example):
6959
```bash
7060
docker run --rm -p 8000:8000 -e AWS_REGION=us-west-2 -e VECTOR_STORE_TYPE=opensearch answer-architect:local
7161
```
62+
63+
Testing strategy
64+
---------------
65+
66+
Unit tests in `tests/` are designed to run quickly and use lightweight fakes for heavy external
67+
dependencies (OpenSearch, boto3, SentenceTransformers). Integration tests that exercise real
68+
services should be placed under `tests/integration/` and run in a CI job or developer environment
69+
that installs the real dependencies.
70+
71+
See `docs/TESTING.md` for more details.

docs/CI.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
CI runbook - Answer Architect
2+
3+
This document describes the repository CI workflows and how to safely enable deploys.
4+
5+
Workflows included in this repo
6+
- CI - tests and update checklist (`.github/workflows/update-checklist.yml`)
7+
- Runs on push and pull_request to `main`/`master`.
8+
- Installs dependencies (Poetry), runs unit tests, runs `python scripts/update_checklist.py --recalc` and commits `checklist.md` when changed.
9+
- Does not perform any cloud deploys.
10+
11+
- Manual Deploy (safe) (`.github/workflows/manual-deploy.yml`)
12+
- Manual `workflow_dispatch` only. Requires typing the confirmation phrase `I_ACCEPT_COSTS` to run preflight checks.
13+
- Intentionally performs a dry-run and refuses to `apply` from Actions unless repository administrators explicitly enable CI deploy flags and environment approvals.
14+
15+
How to enable safe CI deploys (admin steps)
16+
1. Create a GitHub Environment (Settings -> Environments) with the name you will use (e.g., `production`).
17+
2. Configure required reviewers or environment protection rules so deployments to that environment require human approval.
18+
3. If you understand the risk and want to allow the apply step to run from Actions, set the repository secrets or environment variables (in the environment settings) `ALLOW_DEPLOY_IN_CI=1` and `ALLOW_AWS_DEPLOY=1`.
19+
- Warning: this is a high-risk change. Only set these when environment approvals are configured and reviewers are trained.
20+
21+
Local safe deploy checklist
22+
- Create a `.deploy-confirm` file containing `I_ACCEPT_COSTS` if you want non-interactive confirmation.
23+
- Set `ALLOW_AWS_DEPLOY=1` and `DEPLOY_CONFIRM=I_ACCEPT_COSTS` in your shell, then run `python scripts/deploy.py --environment dev --apply`.
24+
25+
Notes
26+
- The CI runbook is informational; the repository includes guardrails in `scripts/deploy.py` that block accidental deploys.
27+
- If you want me to generate admin-facing automation (GH CLI scripts) to create environments and apply protection rules, I can create them, but they require repository admin tokens to run.

docs/DEPLOY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Safe deploy runbook Answer Architect
1+
# Safe deploy runbook - Answer Architect
22

33
This document describes the safe, audited steps to deploy the Answer Architect infrastructure.
44

docs/ENV_SETUP.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Environment setup
2+
3+
Quick steps to prepare a developer workstation for Answer Architect:
4+
5+
1. Install Python 3.11. Example with pyenv:
6+
7+
```bash
8+
pyenv install 3.11.4
9+
pyenv local 3.11.4
10+
```
11+
12+
2. Install Poetry and project deps:
13+
14+
```bash
15+
curl -sSL https://install.python-poetry.org | python3 -
16+
poetry install
17+
```
18+
19+
3. (Optional) Install AWS CLI v2 and configure profile for managed LLM access if needed:
20+
21+
```bash
22+
# follow AWS docs for your OS; verify:
23+
aws --version
24+
```
25+
26+
4. Quick check:
27+
28+
```bash
29+
python scripts/check_env.py
30+
```

docs/TESTING.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Testing strategy for Answer Architect
2+
3+
Unit tests
4+
----------
5+
- Fast.
6+
- Live under `tests/`.
7+
- Use `tests/conftest.py` to inject lightweight fakes for heavy external dependencies (boto3, opensearchpy, sentence_transformers, pgvector/psycopg2, aws_requests_auth, tiktoken).
8+
- Keep unit tests focused on logic and structure, not external service behavior.
9+
10+
Integration tests
11+
-----------------
12+
- Place under `tests/integration/`.
13+
- These should be run in an environment that installs the real dependencies (e.g., via Poetry or a reproducible Docker image).
14+
- Integration tests may require running local or cloud services (OpenSearch, PostgreSQL with pgvector, Bedrock-mock) or using testcontainers to spin up required services.
15+
16+
Running tests locally
17+
---------------------
18+
- Run unit tests quickly:
19+
20+
```bash
21+
poetry install --with dev
22+
poetry run pytest tests/ -q
23+
```
24+
25+
- Run integration tests (example, requires real services):
26+
27+
```bash
28+
poetry install --with dev
29+
poetry run pytest tests/integration/ -q
30+
```
31+
32+
CI
33+
--
34+
- Keep unit tests fast and run them on every PR.
35+
- Run integration tests in a separate job that provisions required services and installs full dependencies.

pytest.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[pytest]
2+
markers =
3+
asyncio: mark async tests (pytest-asyncio)
4+
latency: mark tests that assert latency budgets
5+
integration: mark tests that require external services (OpenSearch/Postgres)
14.4 KB
Binary file not shown.
0 Bytes
Binary file not shown.

scripts/check_env.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env python3
2+
"""Check developer environment for required toolchain versions.
3+
4+
Usage: python scripts/check_env.py
5+
Exits 0 if checks pass, non-zero otherwise.
6+
"""
7+
from __future__ import annotations
8+
9+
import shutil
10+
import subprocess
11+
import sys
12+
13+
14+
def check_python(min_major: int = 3, min_minor: int = 11) -> bool:
15+
v = sys.version_info
16+
ok = (v.major > min_major) or (v.major == min_major and v.minor >= min_minor)
17+
print(f"Python: {v.major}.{v.minor}.{v.micro} -> {'OK' if ok else 'FAIL (need >=%d.%d)' % (min_major, min_minor)}")
18+
return ok
19+
20+
21+
def check_executable(name: str) -> bool:
22+
path = shutil.which(name)
23+
print(f"{name}: {'found at ' + path if path else 'NOT FOUND'}")
24+
return bool(path)
25+
26+
27+
def check_aws_cli(min_version: tuple[int, int, int] = (2, 27, 50)) -> bool:
28+
if not check_executable("aws"):
29+
return False
30+
try:
31+
out = subprocess.check_output(["aws", "--version"], stderr=subprocess.STDOUT)
32+
s = out.decode("utf-8", errors="ignore")
33+
# Example: aws-cli/2.7.18 Python/3.9.16 Linux/5.15.0
34+
parts = s.split()[0].split("/")
35+
if len(parts) >= 2:
36+
ver = parts[1]
37+
nums = tuple(int(p) for p in ver.split(".")[:3])
38+
ok = nums >= min_version
39+
print(f"AWS CLI: {ver} -> {'OK' if ok else 'FAIL (need >=%s)' % ('.'.join(map(str,min_version)))}")
40+
return ok
41+
except Exception as e:
42+
print("Error checking aws --version:", e)
43+
return False
44+
45+
46+
def main() -> None:
47+
ok = True
48+
ok = check_python() and ok
49+
ok = check_executable("poetry") and ok
50+
ok = check_aws_cli() and ok
51+
if not ok:
52+
print("One or more environment checks failed.")
53+
sys.exit(2)
54+
print("Environment OK")
55+
56+
57+
if __name__ == "__main__":
58+
main()

0 commit comments

Comments
 (0)