-
Notifications
You must be signed in to change notification settings - Fork 0
style(utils): apply ruff --fix to src/utils #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7907496
ci: add reproducible test runner, fix requirements pins, use venv in …
e4a566f
chore(ci): add Makefile, README test docs, run ruff in CI; remove .ve…
efce146
docs: fix README markdown warnings; ci: add codecov token and pip cac…
0295ae7
ci: exclude duplicate router from mypy checks (known conflict)
18310da
chore: remove duplicate src/llm/router.py to avoid mypy duplicate-module
deb3176
chore: move test_results into test/ directory
f153082
style(utils): apply ruff --fix to src/utils
e76a6d7
Potential fix for code scanning alert no. 732: Workflow does not cont…
vinod0m 7f08b80
Potential fix for code scanning alert no. 726: Workflow does not cont…
vinod0m 05fbe0e
Merge branch 'main' into chore/lint-utils
vinod0m File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Example .env file for SDLC_core | ||
| # Set the LLM provider (default: gemini). Options: gemini, openai, ollama | ||
| LLM_PROVIDER=gemini | ||
|
|
||
| # For Gemini (Google) | ||
| # DO NOT store real API keys in the repository. | ||
| # Provide your Gemini API key via GitHub Actions secrets (recommended for CI) or configure | ||
| # it locally in your shell environment when developing. | ||
| # Example (local): | ||
| # export GOOGLE_GEMINI_API_KEY="your-key-here" | ||
| # If you prefer dotenv for local development, create a local, untracked file (for example | ||
| # `.env.local`) and load it; do NOT commit it. | ||
| # GOOGLE_GEMINI_API_KEY= | ||
|
|
||
| # For OpenAI | ||
| # Provide your OpenAI API key via GitHub Actions secrets or set it locally: | ||
| # export OPENAI_API_KEY="sk-..." | ||
| # OPENAI_API_KEY= | ||
|
|
||
| # For Ollama (local, may not require API key) | ||
| # LLM_MODEL=llama2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
|
|
||
| # GitHub CI: Provider secrets & manual provider matrix | ||
|
|
||
| This file documents the repository secrets and quick steps to run provider-specific CI jobs manually. | ||
|
|
||
| - Add `GOOGLE_GEMINI_API_KEY` to your environment before running provider jobs. | ||
|
|
||
| - GitHub Actions / Secrets | ||
|
|
||
| To store provider keys for CI, add them as repository secrets. Example using the GitHub CLI: | ||
|
|
||
| ```bash | ||
| # store a Gemini key | ||
| gh secret set GOOGLE_GEMINI_API_KEY --body "<your-gemini-key>" | ||
|
|
||
| # store an OpenAI key | ||
| gh secret set OPENAI_API_KEY --body "<your-openai-key>" | ||
|
|
||
| # optionally, store Codecov token | ||
| gh secret set CODECOV_TOKEN --body "<your-codecov-token>" | ||
| ``` | ||
|
|
||
| - Local dev note: Do not commit API keys into the repository. The project `.env` file has been sanitized and no longer contains live API keys. For local development, either export the variables in your shell or create a `.env.local` file which is gitignored. | ||
|
|
||
| - `OPENAI_API_KEY` — API key for OpenAI (if you run OpenAI provider jobs). | ||
|
|
||
| - `CODECOV_TOKEN` — (optional) Codecov token for private repos if you want coverage uploaded. Public repos usually don't need this. | ||
|
|
||
| Notes about Ollama: | ||
|
|
||
| - Ollama is a local inference server. The CI provider matrix includes `ollama` as an option but most CI runs should use `gemini` or `openai` unless you have an Ollama server available in your runner. | ||
|
|
||
| - If you want to run Ollama in CI, you must either run a self-hosted runner that has Ollama installed and running, or start an Ollama container as part of the job before running tests. | ||
|
|
||
|
|
||
| Or set them manually in the GitHub UI: | ||
| - Repo → Settings → Secrets and variables → Actions → New repository secret | ||
|
|
||
|
|
||
| How to run the provider matrix manually | ||
|
|
||
| 1. Open the repository on GitHub and go to Actions → `Python Tests (consolidated)`. | ||
| 2. Click "Run workflow" and set `run_providers` to `true` then dispatch. | ||
|
|
||
| Or use the `gh` CLI to dispatch the workflow (example): | ||
|
|
||
| ```bash | ||
| # Replace 'python-test.yml' with the workflow file name if different | ||
| gh workflow run python-test.yml -f run_providers=true | ||
| ``` | ||
|
|
||
| If you prefer to run a single provider smoke job manually (quick check) use the provider-smoke job in the workflow (via the Actions UI) or run a small script locally that constructs the agent with `dry_run=True`: | ||
|
|
||
| ```bash | ||
| # Dry-run locally (no network calls) — uses gemini by default in examples | ||
| DRY_RUN=true LLM_PROVIDER=gemini python -c "from src.agents import deepagent; a=deepagent.SDLCFlexibleAgent(provider='gemini', dry_run=True); print('dry run ok', a.agent.run('hello'))" | ||
| ``` | ||
|
|
||
| Security | ||
|
|
||
| - Never commit secrets to the repository. | ||
| - Use least-privilege credentials for CI runs when possible. | ||
|
|
||
| Troubleshooting | ||
|
|
||
| - If the `providers` matrix job fails for `ollama`, check that the runner has network access to your Ollama server or that a local Ollama container was started prior to running tests. | ||
| - For Codecov failures, ensure `CODECOV_TOKEN` is set if the repo is private. | ||
|
|
||
| Running Ollama in CI (example) | ||
|
|
||
| If you want to spin up an Ollama container in a job before running tests, you can add a step like this (example using Docker): | ||
|
|
||
| ```yaml | ||
| - name: Start Ollama container | ||
| run: | | ||
| docker run -d --name ollama -p 11434:11434 ollama/ollama:latest | ||
| # optionally wait for health endpoint | ||
| until curl -sSf http://localhost:11434/health; do sleep 1; done | ||
| ``` | ||
|
|
||
| Note: replace `ollama/ollama:latest` with the image/tag you prefer. For GitHub-hosted runners, ensure Docker is available or use a self-hosted runner with Ollama installed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| chore: move test_results into test/ and lint handlers | ||
|
|
||
| What I changed | ||
|
|
||
| - Moved `test_results/` into `test/test_results/` to group test artifacts with tests. | ||
| - Applied `ruff --fix` to `src/handlers` (small, focused linting commit). No functional changes. | ||
| - Added renamed router modules earlier to avoid mypy duplicate-module collisions. | ||
|
|
||
| Why | ||
|
|
||
| - Keeps test artifacts nested under `test/` for cleaner repo layout. | ||
| - Small, isolated linting fixes are easier to review and revert if necessary. | ||
| - Renaming router modules prevents future mypy collisions. | ||
|
|
||
| Notes for reviewers | ||
|
|
||
| - No runtime behavior changed. This is a repository hygiene change. | ||
| - If you keep CI artifacts in `test/test_results/`, update any external tooling that referenced `test_results/` directly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| CI and testability improvements for DeepAgent (dry-run, tests, CI) | ||
Check failureCode scanning / check-spelling Check File Path Error
deepagent is not a recognized word. (check-file-path)
|
||
|
|
||
| - Added dry-run / MockAgent and an EchoTool to make DeepAgent importable and testable without provider APIs. | ||
| - Added offline unit tests for DeepAgent and provider selection. Local run: 5 tests passed. | ||
| - Added reproducible test runner (`scripts/run-tests.sh`), `Makefile` targets, and updated README with instructions. | ||
| - Adjusted `requirements.txt` to remove unavailable pins and pin validated provider adapters. | ||
| - Consolidated CI workflow `.github/workflows/python-test.yml` (ruff + mypy + pytest + codecov). Provider matrix is manual and must be dispatched by a user with repo:actions permissions. | ||
|
|
||
| Static checks: `src/agents/deepagent.py` passes ruff; repo-wide ruff still reports ~115 items (plan to fix in small batches). | ||
|
|
||
| Notes: | ||
| - mypy reports a duplicate-module issue for router modules; CI excludes `src/llm/router.py` until a refactor is done. | ||
| - Provider matrix run needs a manual dispatch in Actions (set run_providers=true) or a user with proper `gh` permissions. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,7 @@ | ||
| # Python Unit Tests & Static Analysis | ||
| # This workflow runs unit tests and static code analysis | ||
| name: Python Tests and Static Analysis | ||
| name: Python Tests and Static Analysis (legacy) | ||
|
|
||
| on: | ||
| push: | ||
| paths: | ||
| - '**.py' | ||
| pull_request: | ||
| paths: | ||
| - '**.py' | ||
|
|
||
| jobs: | ||
| test-and-analyze: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| pip install pytest pytest-cov mypy | ||
| - name: Run unit tests | ||
| run: pytest --cov=src/ --cov-report=xml | ||
| - name: Run mypy static analysis | ||
| run: mypy src/ | ||
| # This workflow has been consolidated into .github/workflows/python-test.yml. | ||
| # Left here for documentation/history. The consolidated workflow runs static analysis | ||
| # and a test matrix plus a focused deepagent test stage. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,174 @@ | ||
| name: Python Tests (consolidated) | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
| workflow_dispatch: | ||
| inputs: | ||
| run_providers: | ||
| description: 'Set to true to run the providers matrix (manual run)' | ||
| required: false | ||
| default: 'false' | ||
|
|
||
| jobs: | ||
| static-analysis: | ||
| name: Static analysis & unit tests (one python) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
| - name: Cache pip | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.cache/pip | ||
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pip- | ||
| - name: Install dependencies for static | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| pip install pytest pytest-cov mypy | ||
| - name: Run ruff (lint) | ||
| run: | | ||
| python -m pip install ruff | ||
| python -m ruff check src/ | ||
| - name: Run unit tests with coverage | ||
| run: | | ||
| PYTHONPATH=. pytest --cov=src/ --cov-report=xml | ||
| - name: Upload coverage to Codecov | ||
| uses: codecov/codecov-action@v4 | ||
| with: | ||
| files: ./coverage.xml | ||
| fail_ci_if_error: false | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| - name: Run mypy static analysis | ||
| run: mypy src/ --ignore-missing-imports --exclude "src/llm/router.py" | ||
|
|
||
| tests: | ||
| name: Run tests matrix | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: [3.11, 3.12] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Cache pip | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.cache/pip | ||
| key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pip- | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m venv .venv_ci | ||
| . .venv_ci/bin/activate | ||
| pip install --upgrade pip setuptools wheel | ||
| pip install -r requirements.txt | ||
| - name: Run tests | ||
| env: | ||
| PYTHONPATH: . | ||
| run: | | ||
| python -m pytest -q | ||
|
|
||
| deepagent-test: | ||
|
||
| name: DeepAgent focused tests (fast) | ||
| runs-on: ubuntu-latest | ||
| needs: tests | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: 3.12 | ||
| - name: Cache pip | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.cache/pip | ||
| key: ${{ runner.os }}-pip-3.12-${{ hashFiles('**/requirements.txt') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pip- | ||
| - name: Install test deps only | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m venv .venv_ci | ||
| . .venv_ci/bin/activate | ||
| pip install --upgrade pip setuptools wheel | ||
| pip install pytest python-dotenv | ||
| - name: Run deepagent unit tests | ||
| env: | ||
| PYTHONPATH: . | ||
| run: | | ||
| python -m pytest -q test/unit/test_deepagent.py test/unit/test_deepagent_providers.py | ||
|
|
||
| provider-smoke: | ||
|
||
| name: Provider smoke (manual) | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'workflow_dispatch' | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: 3.12 | ||
| - name: Install provider packages | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m venv .venv_ci | ||
| . .venv_ci/bin/activate | ||
| pip install --upgrade pip setuptools wheel | ||
| pip install langchain-google-genai langchain-community langchain-ollama python-dotenv | ||
| - name: Cache pip for provider-smoke | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.cache/pip | ||
| key: ${{ runner.os }}-pip-provider-smoke-${{ hashFiles('**/requirements.txt') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pip- | ||
| - name: Quick deepagent smoke (dry-run disabled) | ||
| env: | ||
| PYTHONPATH: . | ||
| run: | | ||
| 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))" | ||
|
|
||
| providers: | ||
|
||
| name: Providers matrix (optional) | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.run_providers == 'true' | ||
| strategy: | ||
| matrix: | ||
| provider: [gemini, openai, ollama] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Cache pip | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.cache/pip | ||
| key: ${{ runner.os }}-pip-providers-${{ matrix.provider }}-${{ hashFiles('**/requirements.txt') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pip- | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: 3.12 | ||
| - name: Install provider packages | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| pip install langchain-google-genai langchain-community langchain-ollama | ||
| - name: Run provider smoke for matrix provider | ||
| env: | ||
| PYTHONPATH: . | ||
| run: | | ||
| 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))" | ||
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: Python Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| tests: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: [3.12] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| - name: Run tests | ||
| env: | ||
| PYTHONPATH: . | ||
| run: | | ||
| python -m pytest -q | ||
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| lib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| home = /bin | ||
| include-system-site-packages = false | ||
| version = 3.12.3 | ||
| executable = /usr/bin/python3.12 | ||
| command = /bin/python3 -m venv /workspaces/SDLC_core/.venv |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.