Add tech stack badges #9
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: CI | |
| on: | |
| push: | |
| branches: [main, master] | |
| pull_request: | |
| branches: [main, master] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16-alpine | |
| env: | |
| POSTGRES_USER: test | |
| POSTGRES_PASSWORD: test | |
| POSTGRES_DB: testdb | |
| ports: ["5432:5432"] | |
| options: >- | |
| --health-cmd "pg_isready -U test" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| cache: pip | |
| - name: Install dependencies | |
| run: | | |
| pip install "bcrypt<4.0" | |
| pip install -r requirements.txt | |
| pip install pytest pytest-asyncio pytest-cov httpx | |
| - name: Run tests with coverage | |
| env: | |
| DATABASE_URL: postgresql+asyncpg://test:test@localhost:5432/testdb | |
| ANTHROPIC_API_KEY: test-key | |
| APP_ENV: test | |
| run: | | |
| pytest -v --cov=app --cov-report=xml --cov-fail-under=60 | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./coverage.xml | |
| - name: Generate coverage badge | |
| run: | | |
| pip install coverage-badge | |
| coverage-badge -o coverage.svg -f | |
| echo "COVERAGE=$(cat coverage.svg | grep -oP '(?<=<text[^>]*>)[^<]+' | head -1)" >> $GITHUB_ENV | |
| - name: Upload coverage badge | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-badge | |
| path: coverage.svg | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install ruff | |
| run: pip install ruff | |
| - name: Run ruff | |
| run: ruff check app tests | |
| docker: | |
| runs-on: ubuntu-latest | |
| needs: [test, lint] | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build Docker image | |
| run: docker build -t doc-intel-api . | |
| - name: Test Docker image | |
| run: | | |
| docker run -d --name test -p 8000:8000 -e ANTHROPIC_API_KEY=test doc-intel-api | |
| sleep 10 | |
| curl -f http://localhost:8000/health/live | |
| docker stop test |