test fixes #2
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
| # .github/workflows/main.yml | |
| name: Main | |
| on: | |
| push: | |
| pull_request: | |
| jobs: | |
| tests: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 45 | |
| env: | |
| OLLAMA_HOST: http://localhost:11434 | |
| OLLAMA_MODEL: mistral | |
| REDIS_HOST: redis | |
| POSTGRES_HOST: postgres | |
| POSTGRES_DB: dendrite | |
| POSTGRES_USER: dendrite | |
| POSTGRES_PASSWORD: dendrite_pass | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # Optional: speed up your tests image pip installs (host cache). | |
| - name: Cache pip | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Start services (Compose) | |
| run: | | |
| docker compose up -d redis postgres ollama | |
| echo "Waiting for Redis..." | |
| for i in {1..30}; do | |
| if docker compose exec -T redis redis-cli ping | grep -q PONG; then | |
| echo "Redis ready"; break | |
| fi | |
| if [ $i -eq 30 ]; then echo "Redis failed to start"; exit 1; fi | |
| sleep 1 | |
| done | |
| echo "Waiting for Postgres..." | |
| for i in {1..60}; do | |
| if docker compose exec -T postgres pg_isready -U "$POSTGRES_USER" >/dev/null 2>&1; then | |
| echo "Postgres ready"; break | |
| fi | |
| if [ $i -eq 60 ]; then echo "Postgres failed to start"; exit 1; fi | |
| sleep 1 | |
| done | |
| echo "Waiting for Ollama API..." | |
| for i in {1..120}; do | |
| if curl -sSf http://localhost:11434/api/tags >/dev/null; then | |
| echo "Ollama up"; break | |
| fi | |
| if [ $i -eq 120 ]; then | |
| echo "Ollama failed to start"; docker compose logs ollama; exit 1 | |
| fi | |
| sleep 1 | |
| done | |
| - name: Pull a tiny model for CI | |
| run: | | |
| set -e | |
| curl -sS -X POST "$OLLAMA_HOST/api/pull" -d "{\"name\":\"$OLLAMA_MODEL\"}" | |
| # wait until it appears in /api/tags | |
| for i in {1..600}; do | |
| curl -s "$OLLAMA_HOST/api/tags" | grep -q "$OLLAMA_MODEL" && break || sleep 1 | |
| done | |
| - name: Build tests image | |
| run: docker compose build tests | |
| - name: Run pytest in tests service | |
| run: docker compose run --rm tests pytest -v | |
| - name: Teardown | |
| if: always() | |
| run: docker compose down -v |