-
-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (100 loc) · 3.37 KB
/
ci.yml
File metadata and controls
120 lines (100 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Pipeline de Integración Continua
on:
push:
branches: [main]
paths-ignore:
- '**.md'
- 'docs/**'
- '.github/*.md'
- 'LICENSE*'
- '.gitignore'
pull_request:
branches: [main]
paths-ignore:
- '**.md'
- 'docs/**'
- '.github/*.md'
- 'LICENSE*'
- '.gitignore'
jobs:
# ============================================================================
# Verificación de Estilo de Código
# ============================================================================
verificar-estilo:
name: "Verificar Estilo de Código"
runs-on: ubuntu-latest
steps:
- name: Clonar repositorio
uses: actions/checkout@v4
- name: Configurar Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Instalar herramientas de formateo
run: pip install black isort
- name: Verificar formateo con Black
run: black --check --diff src/ tests/
- name: Verificar orden de imports con isort
run: isort --check-only --diff src/ tests/
# ============================================================================
# Tests Unitarios
# ============================================================================
ejecutar-tests:
name: "Ejecutar Tests Unitarios"
runs-on: ubuntu-latest
needs: verificar-estilo
steps:
- name: Clonar repositorio
uses: actions/checkout@v4
- name: Configurar Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Instalar dependencias
run: |
pip install pytest
pip install -e .
- name: Ejecutar suite de tests
run: pytest tests/ -v
# ============================================================================
# Análisis de Seguridad
# ============================================================================
analizar-seguridad:
name: "Análisis de Vulnerabilidades"
runs-on: ubuntu-latest
needs: ejecutar-tests
steps:
- name: Clonar repositorio
uses: actions/checkout@v4
- name: Configurar Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Actualizar pip
run: pip install --upgrade pip
- name: Instalar pip-audit
run: pip install pip-audit
- name: Instalar dependencias del proyecto
run: pip install -e .
- name: Ejecutar auditoría de seguridad
run: pip-audit --desc on --ignore-vuln CVE-2025-8869
# ============================================================================
# Build de Imagen Docker
# ============================================================================
construir-docker:
name: "Construir Imagen Docker"
runs-on: ubuntu-latest
needs: ejecutar-tests
steps:
- name: Clonar repositorio
uses: actions/checkout@v4
- name: Configurar Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Construir imagen de producción
run: docker build -f docker/Dockerfile.api -t cortex-ka:test .
- name: Verificar que el contenedor inicia correctamente
run: |
docker run --rm -d --name cortex-test -p 8000:8000 cortex-ka:test
sleep 5
docker logs cortex-test
docker stop cortex-test || true