fix(ci): use Python virtual environment for PEP 668 compliance
Some checks failed
Deploy Frontend / build-and-deploy (push) Successful in 4m2s
DSPy RAG Evaluation / Layer 1 - Unit Tests (push) Failing after 9m53s
DSPy RAG Evaluation / Layer 3 - Integration Tests (push) Has been skipped
DSPy RAG Evaluation / Layer 2 - DSPy Module Tests (push) Has been skipped
DSPy RAG Evaluation / Layer 4 - Comprehensive Evaluation (push) Has been skipped
DSPy RAG Evaluation / Quality Gate (push) Failing after 1s

- Create venv at /opt/venv in each job
- Source venv/bin/activate before pip install and pytest commands
- Add python3-full package for complete venv support
- Fixes 'externally-managed-environment' error on Debian Bookworm
This commit is contained in:
kempersc 2026-01-13 12:54:41 +01:00
parent c5fb9ec88e
commit 38db05656a

View file

@ -41,6 +41,7 @@ on:
env: env:
SERVER_IP: '91.98.224.44' SERVER_IP: '91.98.224.44'
SERVER_USER: 'root' SERVER_USER: 'root'
VENV_PATH: '/opt/venv'
jobs: jobs:
# ========================================================================== # ==========================================================================
@ -49,27 +50,30 @@ jobs:
unit-tests: unit-tests:
name: Layer 1 - Unit Tests name: Layer 1 - Unit Tests
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Note: No container block - use default node:20-bookworm with Python installed via apt
timeout-minutes: 10 timeout-minutes: 10
steps: steps:
- uses: https://github.com/actions/checkout@v4 - uses: https://github.com/actions/checkout@v4
- name: Install Python - name: Setup Python with virtual environment
run: | run: |
apt-get update apt-get update
apt-get install -y python3 python3-pip python3-venv apt-get install -y python3 python3-pip python3-venv python3-full
python3 --version python3 -m venv ${{ env.VENV_PATH }}
echo "Python version: $(python3 --version)"
echo "Venv created at ${{ env.VENV_PATH }}"
- name: Install dependencies - name: Install dependencies
run: | run: |
python3 -m pip install --upgrade pip source ${{ env.VENV_PATH }}/bin/activate
python3 -m pip install -e ".[dev]" pip install --upgrade pip
python3 -m pip install rapidfuzz pip install -e ".[dev]"
pip install rapidfuzz
- name: Run Layer 1 unit tests - name: Run Layer 1 unit tests
run: | run: |
python3 -m pytest tests/dspy_gitops/test_layer1_unit.py \ source ${{ env.VENV_PATH }}/bin/activate
python -m pytest tests/dspy_gitops/test_layer1_unit.py \
-v --tb=short \ -v --tb=short \
--junit-xml=layer1-results.xml --junit-xml=layer1-results.xml
@ -86,7 +90,6 @@ jobs:
dspy-module-tests: dspy-module-tests:
name: Layer 2 - DSPy Module Tests name: Layer 2 - DSPy Module Tests
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Note: No container block - use default node:20-bookworm with Python installed via apt
timeout-minutes: 20 timeout-minutes: 20
needs: unit-tests needs: unit-tests
@ -96,22 +99,25 @@ jobs:
steps: steps:
- uses: https://github.com/actions/checkout@v4 - uses: https://github.com/actions/checkout@v4
- name: Install Python - name: Setup Python with virtual environment
run: | run: |
apt-get update apt-get update
apt-get install -y python3 python3-pip python3-venv apt-get install -y python3 python3-pip python3-venv python3-full
python3 -m venv ${{ env.VENV_PATH }}
- name: Install dependencies - name: Install dependencies
run: | run: |
python3 -m pip install --upgrade pip source ${{ env.VENV_PATH }}/bin/activate
python3 -m pip install -e ".[dev]" pip install --upgrade pip
python3 -m pip install dspy-ai httpx rapidfuzz litellm pip install -e ".[dev]"
pip install dspy-ai httpx rapidfuzz litellm
- name: Run Layer 2 DSPy tests - name: Run Layer 2 DSPy tests
env: env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: | run: |
python3 -m pytest tests/dspy_gitops/test_layer2_dspy.py \ source ${{ env.VENV_PATH }}/bin/activate
python -m pytest tests/dspy_gitops/test_layer2_dspy.py \
-v --tb=short \ -v --tb=short \
--junit-xml=layer2-results.xml --junit-xml=layer2-results.xml
@ -128,23 +134,24 @@ jobs:
integration-tests: integration-tests:
name: Layer 3 - Integration Tests name: Layer 3 - Integration Tests
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Note: No container block - use default node:20-bookworm with Python installed via apt
timeout-minutes: 15 timeout-minutes: 15
needs: unit-tests needs: unit-tests
steps: steps:
- uses: https://github.com/actions/checkout@v4 - uses: https://github.com/actions/checkout@v4
- name: Install system dependencies - name: Setup Python with virtual environment
run: | run: |
apt-get update apt-get update
apt-get install -y openssh-client curl python3 python3-pip python3-venv apt-get install -y openssh-client curl python3 python3-pip python3-venv python3-full
python3 -m venv ${{ env.VENV_PATH }}
- name: Install Python dependencies - name: Install Python dependencies
run: | run: |
python3 -m pip install --upgrade pip source ${{ env.VENV_PATH }}/bin/activate
python3 -m pip install -e ".[dev]" pip install --upgrade pip
python3 -m pip install httpx pytest-asyncio pip install -e ".[dev]"
pip install httpx pytest-asyncio
- name: Setup SSH for tunnel - name: Setup SSH for tunnel
run: | run: |
@ -177,7 +184,8 @@ jobs:
OXIGRAPH_ENDPOINT: "http://127.0.0.1:7878" OXIGRAPH_ENDPOINT: "http://127.0.0.1:7878"
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: | run: |
python3 -m pytest tests/dspy_gitops/test_layer3_integration.py \ source ${{ env.VENV_PATH }}/bin/activate
python -m pytest tests/dspy_gitops/test_layer3_integration.py \
-v --tb=short \ -v --tb=short \
--junit-xml=layer3-results.xml --junit-xml=layer3-results.xml
@ -194,7 +202,6 @@ jobs:
comprehensive-eval: comprehensive-eval:
name: Layer 4 - Comprehensive Evaluation name: Layer 4 - Comprehensive Evaluation
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Note: No container block - use default node:20-bookworm with Python installed via apt
timeout-minutes: 60 timeout-minutes: 60
needs: [unit-tests, dspy-module-tests, integration-tests] needs: [unit-tests, dspy-module-tests, integration-tests]
@ -204,16 +211,18 @@ jobs:
steps: steps:
- uses: https://github.com/actions/checkout@v4 - uses: https://github.com/actions/checkout@v4
- name: Install system dependencies - name: Setup Python with virtual environment
run: | run: |
apt-get update apt-get update
apt-get install -y openssh-client curl python3 python3-pip python3-venv apt-get install -y openssh-client curl python3 python3-pip python3-venv python3-full
python3 -m venv ${{ env.VENV_PATH }}
- name: Install Python dependencies - name: Install Python dependencies
run: | run: |
python3 -m pip install --upgrade pip source ${{ env.VENV_PATH }}/bin/activate
python3 -m pip install -e ".[dev]" pip install --upgrade pip
python3 -m pip install dspy-ai httpx rapidfuzz pandas pytest-json-report litellm pip install -e ".[dev]"
pip install dspy-ai httpx rapidfuzz pandas pytest-json-report litellm
- name: Setup SSH for tunnel - name: Setup SSH for tunnel
run: | run: |
@ -235,7 +244,8 @@ jobs:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
OXIGRAPH_ENDPOINT: "http://127.0.0.1:7878" OXIGRAPH_ENDPOINT: "http://127.0.0.1:7878"
run: | run: |
python3 -m pytest tests/dspy_gitops/test_layer4_comprehensive.py \ source ${{ env.VENV_PATH }}/bin/activate
python -m pytest tests/dspy_gitops/test_layer4_comprehensive.py \
-v --tb=short \ -v --tb=short \
--junit-xml=layer4-results.xml \ --junit-xml=layer4-results.xml \
--json-report \ --json-report \
@ -243,7 +253,8 @@ jobs:
- name: Generate metrics summary - name: Generate metrics summary
run: | run: |
python3 -c " source ${{ env.VENV_PATH }}/bin/activate
python -c "
import json import json
from datetime import datetime from datetime import datetime
@ -319,4 +330,3 @@ jobs:
echo "============================================" echo "============================================"
echo " All required quality gates passed!" echo " All required quality gates passed!"
echo "============================================" echo "============================================"