Ignore .env #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
| name: Tests | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Install dependencies | |
| run: uv sync --extra dev | |
| - name: Run all tests with coverage | |
| run: uv run pytest -v --cov=app --cov-report=xml --cov-report=term | |
| docker-integration: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Create test environment file | |
| run: | | |
| cat > .env.test <<EOF | |
| POSTGRES_USER=test | |
| POSTGRES_PASSWORD=test | |
| POSTGRES_DB=myapp_test | |
| DEBUG=true | |
| EOF | |
| - name: Build and start services | |
| run: docker compose -f docker-compose.dev.yml --env-file .env.test up -d --build | |
| - name: Wait for services to be ready | |
| run: | | |
| echo "Waiting for services to start..." | |
| timeout 60 bash -c 'until curl -f http://localhost:8000/api/health > /dev/null 2>&1; do sleep 2; done' | |
| echo "Services are ready!" | |
| - name: Sanity check API endpoints | |
| run: | | |
| echo "Testing health endpoint..." | |
| curl -f http://localhost:8000/api/health | |
| echo "Testing items endpoint..." | |
| curl -f http://localhost:8000/api/items | |
| - name: Show logs on failure | |
| if: failure() | |
| run: docker compose -f docker-compose.dev.yml logs | |
| - name: Tear down services | |
| if: always() | |
| run: docker compose -f docker-compose.dev.yml down -v |