88 lines
2.4 KiB
YAML
88 lines
2.4 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop ]
|
|
pull_request:
|
|
branches: [ main, develop ]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
postgres:
|
|
image: pgvector/pgvector:pg17
|
|
env:
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: codeforge_test
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Cache pip packages
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
|
|
- name: Setup test database
|
|
env:
|
|
PGPASSWORD: postgres
|
|
run: |
|
|
psql -h localhost -U postgres -d codeforge_test -c "CREATE EXTENSION IF NOT EXISTS vector"
|
|
psql -h localhost -U postgres -d codeforge_test -f app/core/schema.sql
|
|
|
|
- name: Run unit tests
|
|
env:
|
|
TEST_POSTGRES_HOST: localhost
|
|
TEST_POSTGRES_PORT: 5432
|
|
TEST_POSTGRES_DB: codeforge_test
|
|
TEST_POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
run: |
|
|
pytest tests/ -m unit -v --cov=app --cov-report=xml --cov-report=term-missing
|
|
|
|
- name: Run integration tests (without Ollama)
|
|
env:
|
|
TEST_POSTGRES_HOST: localhost
|
|
TEST_POSTGRES_PORT: 5432
|
|
TEST_POSTGRES_DB: codeforge_test
|
|
TEST_POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
run: |
|
|
pytest tests/ -m "integration and not embeddings" -v --cov=app --cov-append --cov-report=xml --cov-report=term-missing
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v3
|
|
with:
|
|
file: ./coverage.xml
|
|
flags: unittests
|
|
name: codecov-umbrella
|
|
fail_ci_if_error: false
|
|
|
|
- name: Generate coverage badge
|
|
run: |
|
|
coverage report --format=markdown > coverage.md
|
|
echo "## Test Coverage" >> $GITHUB_STEP_SUMMARY
|
|
cat coverage.md >> $GITHUB_STEP_SUMMARY
|
|
|