Merge pull request #82 from security-commons-nl/docs/sync-findings-ui #305
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
| name: Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| backend-tests: | |
| name: Backend tests (pytest) | |
| runs-on: ubuntu-latest | |
| # PostgreSQL met pgvector als service. Matcht productie (PostgreSQL 16 + | |
| # pgvector-extensie voor embeddings in ims_knowledge_chunks). | |
| services: | |
| postgres: | |
| image: pgvector/pgvector:pg16 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: ims | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| defaults: | |
| run: | |
| working-directory: backend | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.11" | |
| cache: pip | |
| cache-dependency-path: backend/requirements.txt | |
| - name: Install dependencies | |
| run: pip install -r requirements.txt | |
| - name: Create ims_test database + enable pgvector | |
| run: | | |
| PGPASSWORD=postgres psql -h localhost -U postgres -d ims -c "CREATE DATABASE ims_test;" | |
| PGPASSWORD=postgres psql -h localhost -U postgres -d ims_test -c "CREATE EXTENSION IF NOT EXISTS vector;" | |
| - name: Run database migrations against ims_test | |
| env: | |
| POSTGRES_SERVER: localhost | |
| POSTGRES_PORT: 5432 | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: ims_test | |
| JWT_SECRET_KEY: test-secret-key-not-for-production | |
| AI_API_BASE: http://localhost:11434/v1 | |
| AI_MODEL_NAME: mistral | |
| run: alembic upgrade head | |
| - name: Run tests with coverage | |
| env: | |
| # conftest.py doet settings.DATABASE_URL.replace("/ims", "/ims_test"), | |
| # dus POSTGRES_DB=ims hier zorgt dat tests naar ims_test wijzen. | |
| POSTGRES_SERVER: localhost | |
| POSTGRES_PORT: 5432 | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: ims | |
| JWT_SECRET_KEY: test-secret-key-not-for-production | |
| AI_API_BASE: http://localhost:11434/v1 | |
| AI_MODEL_NAME: mistral | |
| run: | | |
| pytest --tb=short -q \ | |
| --cov=app \ | |
| --cov-report=xml:coverage.xml \ | |
| --cov-report=term | |
| - name: Upload coverage | |
| if: always() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: backend-coverage | |
| path: backend/coverage.xml | |
| if-no-files-found: ignore | |
| retention-days: 14 | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: pytest-results | |
| path: backend/pytest-results.xml | |
| if-no-files-found: ignore |