feat: actualizar pytest-asyncio a la versión 1.0.0 en las dependencia… #42
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/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| quality: | |
| name: Calidad de código | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: ./.github/actions/setup-python | |
| - name: Black | |
| run: black --check api/ tests/ | |
| - name: Flake8 | |
| run: flake8 api/ tests/ | |
| - name: MyPy | |
| run: mypy api/ | |
| test: | |
| name: Tests unitarios e integración | |
| runs-on: ubuntu-latest | |
| services: | |
| redis: | |
| image: redis:7-alpine | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: ./.github/actions/setup-python | |
| - name: Ejecutar tests | |
| env: | |
| REDIS_URL: redis://localhost:6379/0 | |
| GROQ_API_KEY: test-key | |
| OPENROUTER_API_KEY: test-key | |
| API_KEY: test-api-key | |
| run: | | |
| pytest --cov=api --cov-report=xml --cov-report=term-missing | |
| - name: Subir cobertura | |
| uses: codecov/codecov-action@v4.6.0 | |
| with: | |
| file: ./coverage.xml | |
| fail_ci_if_error: false | |
| if: github.event_name == 'push' | |
| build: | |
| name: Build y seguridad | |
| runs-on: ubuntu-latest | |
| needs: [quality, test] | |
| if: github.event_name == 'push' | |
| permissions: | |
| contents: read | |
| security-events: write | |
| actions: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3.7.1 | |
| - name: Build imagen | |
| uses: docker/build-push-action@v6.9.0 | |
| with: | |
| context: . | |
| load: true | |
| tags: modelrouter:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Install Trivy | |
| run: | | |
| sudo apt-get install -y wget apt-transport-https gnupg | |
| wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key \ | |
| | gpg --dearmor \ | |
| | sudo tee /usr/share/keyrings/trivy.gpg > /dev/null | |
| echo "deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb generic main" \ | |
| | sudo tee /etc/apt/sources.list.d/trivy.list | |
| sudo apt-get update | |
| sudo apt-get install -y trivy | |
| - name: Trivy scan | |
| uses: aquasecurity/trivy-action@0.35.0 | |
| with: | |
| image-ref: modelrouter:${{ github.sha }} | |
| format: "sarif" | |
| output: "trivy-results.sarif" | |
| severity: "CRITICAL,HIGH" | |
| exit-code: "0" | |
| trivyignores: ".trivyignore" | |
| skip-setup-trivy: true | |
| env: | |
| TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db:2 | |
| - name: Upload SARIF | |
| uses: github/codeql-action/upload-sarif@v4 | |
| with: | |
| sarif_file: "trivy-results.sarif" | |
| category: "trivy-container-scan" | |
| if: always() | |
| continue-on-error: true |