fix #4
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: | | |
| # Use CPU profile for CI (no GPU available) | |
| docker compose --profile cpu up -d redis postgres ollama-cpu | |
| 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" | |
| docker compose logs redis | |
| exit 1 | |
| fi | |
| sleep 1 | |
| done | |
| echo "Waiting for Postgres..." | |
| for i in {1..90}; do | |
| # First check if postgres is accepting connections | |
| if docker compose exec -T postgres pg_isready -U "$POSTGRES_USER" -d "$POSTGRES_DB" >/dev/null 2>&1; then | |
| # Also verify we can actually connect (init scripts completed) | |
| if docker compose exec -T postgres psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT 1" >/dev/null 2>&1; then | |
| echo "Postgres ready"; break | |
| fi | |
| fi | |
| if [ $i -eq 90 ]; then | |
| echo "Postgres failed to start" | |
| echo "Container status:" | |
| docker compose ps postgres | |
| echo "Postgres logs:" | |
| docker compose logs postgres | |
| exit 1 | |
| fi | |
| sleep 2 | |
| 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-cpu; 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 --profile cpu run --rm tests pytest -v | |
| - name: Teardown | |
| if: always() | |
| run: docker compose down -v |