Skip to content

Commit 7907496

Browse files
author
SDLC Bot
committed
ci: add reproducible test runner, fix requirements pins, use venv in workflow
1 parent 41cde4c commit 7907496

File tree

3 files changed

+193
-0
lines changed

3 files changed

+193
-0
lines changed

.github/workflows/python-test.yml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
name: Python Tests (consolidated)
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
inputs:
10+
run_providers:
11+
description: 'Set to true to run the providers matrix (manual run)'
12+
required: false
13+
default: 'false'
14+
15+
jobs:
16+
static-analysis:
17+
name: Static analysis & unit tests (one python)
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.11'
25+
- name: Cache pip
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.cache/pip
29+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
30+
restore-keys: |
31+
${{ runner.os }}-pip-
32+
- name: Install dependencies for static
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install -r requirements.txt
36+
pip install pytest pytest-cov mypy
37+
- name: Run unit tests with coverage
38+
run: |
39+
PYTHONPATH=. pytest --cov=src/ --cov-report=xml
40+
- name: Upload coverage to Codecov
41+
uses: codecov/codecov-action@v4
42+
with:
43+
files: ./coverage.xml
44+
fail_ci_if_error: false
45+
- name: Run mypy static analysis
46+
run: mypy src/
47+
48+
tests:
49+
name: Run tests matrix
50+
runs-on: ubuntu-latest
51+
strategy:
52+
matrix:
53+
python-version: [3.11, 3.12]
54+
steps:
55+
- uses: actions/checkout@v4
56+
- name: Set up Python
57+
uses: actions/setup-python@v4
58+
with:
59+
python-version: ${{ matrix.python-version }}
60+
- name: Cache pip
61+
uses: actions/cache@v4
62+
with:
63+
path: ~/.cache/pip
64+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }}
65+
restore-keys: |
66+
${{ runner.os }}-pip-
67+
- name: Install dependencies
68+
run: |
69+
python -m pip install --upgrade pip
70+
python -m venv .venv_ci
71+
. .venv_ci/bin/activate
72+
pip install --upgrade pip setuptools wheel
73+
pip install -r requirements.txt
74+
- name: Run tests
75+
env:
76+
PYTHONPATH: .
77+
run: |
78+
python -m pytest -q
79+
80+
deepagent-test:
81+
name: DeepAgent focused tests (fast)
82+
runs-on: ubuntu-latest
83+
needs: tests
84+
steps:
85+
- uses: actions/checkout@v4
86+
- name: Set up Python
87+
uses: actions/setup-python@v4
88+
with:
89+
python-version: 3.12
90+
- name: Cache pip
91+
uses: actions/cache@v4
92+
with:
93+
path: ~/.cache/pip
94+
key: ${{ runner.os }}-pip-3.12-${{ hashFiles('**/requirements.txt') }}
95+
restore-keys: |
96+
${{ runner.os }}-pip-
97+
- name: Install test deps only
98+
run: |
99+
python -m pip install --upgrade pip
100+
python -m venv .venv_ci
101+
. .venv_ci/bin/activate
102+
pip install --upgrade pip setuptools wheel
103+
pip install pytest python-dotenv
104+
- name: Run deepagent unit tests
105+
env:
106+
PYTHONPATH: .
107+
run: |
108+
python -m pytest -q test/unit/test_deepagent.py test/unit/test_deepagent_providers.py
109+
110+
provider-smoke:
111+
name: Provider smoke (manual)
112+
runs-on: ubuntu-latest
113+
if: github.event_name == 'workflow_dispatch'
114+
steps:
115+
- uses: actions/checkout@v4
116+
- name: Set up Python
117+
uses: actions/setup-python@v4
118+
with:
119+
python-version: 3.12
120+
- name: Install provider packages
121+
run: |
122+
python -m pip install --upgrade pip
123+
python -m venv .venv_ci
124+
. .venv_ci/bin/activate
125+
pip install --upgrade pip setuptools wheel
126+
pip install langchain-google-genai langchain-community langchain-ollama python-dotenv
127+
- name: Quick deepagent smoke (dry-run disabled)
128+
env:
129+
PYTHONPATH: .
130+
run: |
131+
python -c "from src.agents import deepagent; a=deepagent.SDLCFlexibleAgent(provider='gemini', model='chat-bison-001', dry_run=True); print('constructed', getattr(a, 'llm', None))"
132+
133+
providers:
134+
name: Providers matrix (optional)
135+
runs-on: ubuntu-latest
136+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.run_providers == 'true'
137+
strategy:
138+
matrix:
139+
provider: [gemini, openai, ollama]
140+
steps:
141+
- uses: actions/checkout@v4
142+
- name: Set up Python
143+
uses: actions/setup-python@v4
144+
with:
145+
python-version: 3.12
146+
- name: Install provider packages
147+
run: |
148+
python -m pip install --upgrade pip
149+
pip install -r requirements.txt
150+
pip install langchain-google-genai langchain-community langchain-ollama
151+
- name: Run provider smoke for matrix provider
152+
env:
153+
PYTHONPATH: .
154+
run: |
155+
python -c "from src.agents import deepagent; p='${{ matrix.provider }}'; d = deepagent.SDLCFlexibleAgent(provider=p, dry_run=True); print('provider', p, 'dry_run', getattr(d, 'dry_run', False))"

requirements.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
langchain==0.3.27
3+
# Note: `langchain-deepagent` is not published on PyPI at the pinned version and
4+
# caused CI install failures. It's intentionally omitted here; install any
5+
# deepagent/local adapters manually or in provider-specific CI jobs.
6+
7+
# Keep provider adapters optional; install them per-job if needed
8+
# Provider adapters (optional) - pinned to validated versions from the dev environment
9+
langchain-google-genai==2.1.9
10+
langchain-community==0.3.27
11+
# Ollama adapter left unpinned (install per-job if needed)
12+
langchain-ollama==0.3.6
13+
14+
# python-dotenv used by the module when running locally
15+
python-dotenv==1.1.1
16+
17+
# Test/runtime helpers
18+
pytest==8.4.1

scripts/run-tests.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Lightweight test runner that creates an isolated venv, installs pinned deps,
5+
# and runs pytest for the repository. Designed for CI and local reproducibility.
6+
7+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
8+
VENV_DIR="$ROOT_DIR/.venv_ci"
9+
10+
echo "Using venv: $VENV_DIR"
11+
12+
if [ ! -d "$VENV_DIR" ]; then
13+
python3 -m venv "$VENV_DIR"
14+
fi
15+
16+
"$VENV_DIR/bin/python" -m pip install --upgrade pip setuptools wheel
17+
"$VENV_DIR/bin/python" -m pip install -r "$ROOT_DIR/requirements.txt"
18+
"$VENV_DIR/bin/python" -m pip install pytest==8.4.1
19+
20+
PYTHONPATH="$ROOT_DIR" "$VENV_DIR/bin/python" -m pytest "$@"

0 commit comments

Comments
 (0)