Develop to Master #46
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, develop ] | |
| paths-ignore: | |
| - '**/*.md' | |
| - 'docs/**' | |
| - '.gitignore' | |
| - 'LICENSE' | |
| - 'CHANGELOG*' | |
| pull_request: | |
| branches: [ main, master, develop ] | |
| paths-ignore: | |
| - '**/*.md' | |
| - 'docs/**' | |
| - '.gitignore' | |
| - 'LICENSE' | |
| - 'CHANGELOG*' | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| env: | |
| PYTHON_VERSION: '3.11' | |
| PIP_DISABLE_PIP_VERSION_CHECK: '1' | |
| jobs: | |
| lint: | |
| name: Lint (ruff) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Set up uv (cached) | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| enable-cache: true | |
| # Invalida cuando cambie pyproject/uv.lock y separa clave para este job | |
| cache-dependency-glob: | | |
| **/pyproject.toml | |
| **/uv.lock | |
| cache-suffix: lint | |
| - name: Create virtualenv | |
| run: uv venv | |
| # Solo herramientas; no instalamos el proyecto para acelerar | |
| - name: Install lint deps (extras) | |
| run: uv sync --frozen --extra lint --no-install-project --no-dev | |
| - name: Ruff | |
| run: uv run ruff check . | |
| typing: | |
| name: Typing (mypy) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Set up uv (cached) | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: | | |
| **/pyproject.toml | |
| **/uv.lock | |
| cache-suffix: typing | |
| - name: Create virtualenv | |
| run: uv venv | |
| - name: Install typing deps (extras lint) | |
| run: uv sync --frozen --extra lint --no-install-project --no-dev | |
| - name: mypy | |
| run: uv run mypy . | |
| test: | |
| name: Tests (Ubuntu) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Set up uv (cached) | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: | | |
| **/pyproject.toml | |
| **/uv.lock | |
| cache-suffix: test | |
| - name: Create virtualenv | |
| run: uv venv | |
| # Proyecto + extras dev/test | |
| - name: Install deps | |
| run: uv sync --frozen --extra dev --extra test | |
| - name: Run tests | |
| run: > | |
| uv run pytest | |
| --cov=src | |
| --cov-report=xml | |
| --cov-report=term-missing | |
| --cov-context=test | |
| --junit-xml=pytest-results.xml | |
| --numprocesses=auto | |
| --dist=worksteal | |
| -v | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| continue-on-error: true # Don't fail CI if Codecov upload fails | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # necesario en repos privados | |
| with: | |
| files: ./coverage.xml | |
| flags: unittests | |
| fail_ci_if_error: false | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-ubuntu-py311 | |
| path: pytest-results.xml | |
| retention-days: 7 | |
| security: | |
| name: Security Scan (bandit + safety) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 7 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Set up uv (cached) | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: | | |
| **/pyproject.toml | |
| **/uv.lock | |
| cache-suffix: security | |
| - name: Create virtualenv | |
| run: uv venv | |
| - name: Install security tools | |
| run: uv pip install "bandit[toml]" safety | |
| - name: Run security scans | |
| run: | | |
| uv run bandit -r src/ -f json -o bandit-report.json || true | |
| uv run safety check --full-report --json --output safety-report.json ${SAFETY_API_KEY:+--key $SAFETY_API_KEY} || true | |
| env: | |
| SAFETY_API_KEY: ${{ secrets.SAFETY_API_KEY }} | |
| - name: Upload security reports | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: security-reports | |
| path: | | |
| bandit-report.json | |
| safety-report.json | |
| retention-days: 7 | |
| docker: | |
| name: Docker Build | |
| needs: [lint, typing, test, security] | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build (cache to GHA) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: false | |
| tags: intrinsical-rag-prototype:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |