Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 155 additions & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
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 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
- name: Run mypy static analysis
run: mypy src/

tests:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
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:

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

deepagent is not a recognized word. (unrecognized-spelling)
Comment on lines +54 to +85

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 months ago

To fix the problem, add a permissions block at the root of the workflow file, specifying the minimum required permissions. For most CI jobs that only check out code and run tests, contents: read is sufficient. This block should be added immediately after the name: line and before the on: block, so it applies to all jobs unless overridden. No additional imports or definitions are needed; this is a YAML configuration change.

Suggested changeset 1
.github/workflows/python-test.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml
--- a/.github/workflows/python-test.yml
+++ b/.github/workflows/python-test.yml
@@ -1,3 +1,5 @@
+permissions:
+  contents: read
 name: Python Tests (consolidated)
 
 on:
EOF
@@ -1,3 +1,5 @@
permissions:
contents: read
name: Python Tests (consolidated)

on:
Copilot is powered by AI and may make mistakes. Always verify output.
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

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

deepagent is not a recognized word. (unrecognized-spelling)
env:
PYTHONPATH: .
run: |
python -m pytest -q test/unit/test_deepagent.py test/unit/test_deepagent_providers.py

Check warning

Code scanning / check-spelling

Candidate Pattern Warning

Line matches candidate pattern \\b(?i)py(?!gments|gmy|lon|ramid|ro|th)(?=[a-z]{2,}) (candidate-pattern)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

deepagent is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

deepagent is not a recognized word. (unrecognized-spelling)

provider-smoke:
Comment on lines +86 to +115

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 months ago

To fix the problem, add a permissions block to the deepagent-test job in .github/workflows/python-test.yml, setting it to the minimum required permissions. Since the job only checks out code and runs tests, it only needs contents: read. This change should be made directly under the deepagent-test: job definition, before the runs-on key. No other changes are required.


Suggested changeset 1
.github/workflows/python-test.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml
--- a/.github/workflows/python-test.yml
+++ b/.github/workflows/python-test.yml
@@ -84,6 +84,8 @@
 
   deepagent-test:
     name: DeepAgent focused tests (fast)
+    permissions:
+      contents: read
     runs-on: ubuntu-latest
     needs: tests
     steps:
EOF
@@ -84,6 +84,8 @@

deepagent-test:
name: DeepAgent focused tests (fast)
permissions:
contents: read
runs-on: ubuntu-latest
needs: tests
steps:
Copilot is powered by AI and may make mistakes. Always verify output.
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

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

langchain is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

genai is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

langchain is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

langchain is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

ollama is not a recognized word. (unrecognized-spelling)
- name: Quick deepagent smoke (dry-run disabled)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

deepagent is not a recognized word. (unrecognized-spelling)
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))"

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

llm is not a recognized word. (unrecognized-spelling)

providers:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 months ago

To fix the problem, add a permissions block to the workflow YAML file. The block should be placed at the top level (before jobs:) so that it applies to all jobs in the workflow, unless a job overrides it. For this workflow, the jobs only need to read repository contents (to check out code), so the minimal required permission is contents: read. This change should be made at the root of the file, after the name: and before the on: block. No additional imports or definitions are needed.

Suggested changeset 1
.github/workflows/python-test.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml
--- a/.github/workflows/python-test.yml
+++ b/.github/workflows/python-test.yml
@@ -1,5 +1,8 @@
 name: Python Tests (consolidated)
 
+permissions:
+  contents: read
+
 on:
   push:
     branches: [ main ]
EOF
@@ -1,5 +1,8 @@
name: Python Tests (consolidated)

permissions:
contents: read

on:
push:
branches: [ main ]
Copilot is powered by AI and may make mistakes. Always verify output.
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]

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

openai is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

ollama is not a recognized word. (unrecognized-spelling)
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
pip install -r requirements.txt
pip install langchain-google-genai langchain-community langchain-ollama

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

langchain is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

genai is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

langchain is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

ollama is not a recognized word. (unrecognized-spelling)
- 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))"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 months ago

To fix the problem, add a permissions block to the workflow file .github/workflows/python-test.yml. The best way is to add it at the top level (just after the name: and before jobs:), so it applies to all jobs unless overridden. The minimal required permission for running tests is contents: read, which allows jobs to read repository contents but not modify them. No additional imports or definitions are needed; this is a YAML configuration change.


Suggested changeset 1
.github/workflows/python-test.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml
--- a/.github/workflows/python-test.yml
+++ b/.github/workflows/python-test.yml
@@ -1,5 +1,8 @@
 name: Python Tests (consolidated)
 
+permissions:
+  contents: read
+
 on:
   push:
     branches: [ main ]
EOF
@@ -1,5 +1,8 @@
name: Python Tests (consolidated)

permissions:
contents: read

on:
push:
branches: [ main ]
Copilot is powered by AI and may make mistakes. Always verify output.
18 changes: 18 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

langchain==0.3.27
# Note: `langchain-deepagent` is not published on PyPI at the pinned version and
# caused CI install failures. It's intentionally omitted here; install any
# deepagent/local adapters manually or in provider-specific CI jobs.

# Keep provider adapters optional; install them per-job if needed
# Provider adapters (optional) - pinned to validated versions from the dev environment
langchain-google-genai==2.1.9
langchain-community==0.3.27
# Ollama adapter left unpinned (install per-job if needed)
langchain-ollama==0.3.6

# python-dotenv used by the module when running locally
python-dotenv==1.1.1

# Test/runtime helpers
pytest==8.4.1
20 changes: 20 additions & 0 deletions scripts/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail

Check warning

Code scanning / check-spelling

Candidate Pattern Warning

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

euo is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

pipefail is not a recognized word. (unrecognized-spelling)

# Lightweight test runner that creates an isolated venv, installs pinned deps,
# and runs pytest for the repository. Designed for CI and local reproducibility.

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
VENV_DIR="$ROOT_DIR/.venv_ci"

echo "Using venv: $VENV_DIR"

if [ ! -d "$VENV_DIR" ]; then
python3 -m venv "$VENV_DIR"
fi

"$VENV_DIR/bin/python" -m pip install --upgrade pip setuptools wheel
"$VENV_DIR/bin/python" -m pip install -r "$ROOT_DIR/requirements.txt"
"$VENV_DIR/bin/python" -m pip install pytest==8.4.1

PYTHONPATH="$ROOT_DIR" "$VENV_DIR/bin/python" -m pytest "$@"
Loading