|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, master ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, master ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + services: |
| 14 | + postgres: |
| 15 | + image: postgres:15 |
| 16 | + env: |
| 17 | + POSTGRES_USER: postgres |
| 18 | + POSTGRES_PASSWORD: postgres |
| 19 | + POSTGRES_DB: test_llm_analytics |
| 20 | + options: >- |
| 21 | + --health-cmd pg_isready |
| 22 | + --health-interval 10s |
| 23 | + --health-timeout 5s |
| 24 | + --health-retries 5 |
| 25 | + ports: |
| 26 | + - 5432:5432 |
| 27 | + |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Set up Python |
| 32 | + uses: actions/setup-python@v5 |
| 33 | + with: |
| 34 | + python-version: '3.9' |
| 35 | + |
| 36 | + - name: Install dependencies |
| 37 | + run: | |
| 38 | + python -m pip install --upgrade pip |
| 39 | + pip install -r requirements.txt |
| 40 | +
|
| 41 | + - name: Install pgvector |
| 42 | + run: | |
| 43 | + pip install pgvector |
| 44 | + sudo apt-get update |
| 45 | + sudo apt-get install -y postgresql-15-pgvector |
| 46 | +
|
| 47 | + - name: Create .env file |
| 48 | + run: | |
| 49 | + cat > .env << EOF |
| 50 | + DATABASE_HOST=localhost |
| 51 | + DATABASE_PORT=5432 |
| 52 | + DATABASE_NAME=test_llm_analytics |
| 53 | + DATABASE_USER=postgres |
| 54 | + DATABASE_PASSWORD=postgres |
| 55 | + GROQ_API_KEY=test_key |
| 56 | + PGVECTOR_DB_NAME=test_llm_analytics |
| 57 | + PGVECTOR_DB_USER=postgres |
| 58 | + PGVECTOR_DB_PASSWORD=postgres |
| 59 | + PGVECTOR_DB_HOST=localhost |
| 60 | + PGVECTOR_DB_PORT=5432 |
| 61 | + SENTENCE_TRANSFORMER_MODEL=all-MiniLM-L6-v2 |
| 62 | + EOF |
| 63 | +
|
| 64 | + - name: Run migrations |
| 65 | + run: | |
| 66 | + python manage.py migrate |
| 67 | + env: |
| 68 | + DJANGO_SECRET_KEY: test_secret_key |
| 69 | + DATABASE_HOST: localhost |
| 70 | + DATABASE_PORT: 5432 |
| 71 | + DATABASE_NAME: test_llm_analytics |
| 72 | + DATABASE_USER: postgres |
| 73 | + DATABASE_PASSWORD: postgres |
| 74 | + |
| 75 | + - name: Run tests |
| 76 | + run: | |
| 77 | + python manage.py test core.tests --verbosity=2 |
| 78 | + env: |
| 79 | + DJANGO_SECRET_KEY: test_secret_key |
| 80 | + DATABASE_HOST: localhost |
| 81 | + DATABASE_PORT: 5432 |
| 82 | + DATABASE_NAME: test_llm_analytics |
| 83 | + DATABASE_USER: postgres |
| 84 | + DATABASE_PASSWORD: postgres |
0 commit comments