Skip to content

Commit 14e2baf

Browse files
committed
feat: agrega configuración de CI/CD y acción para configurar el entorno de Python
1 parent c42f54a commit 14e2baf

2 files changed

Lines changed: 110 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: 'Setup Python Environment'
2+
description: 'Configura Python y dependencias con cache'
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Configurar Python
8+
uses: actions/setup-python@v5
9+
with:
10+
python-version: '3.11'
11+
cache: 'pip'
12+
13+
- name: Instalar dependencias
14+
shell: bash
15+
run: |
16+
python -m pip install --upgrade pip
17+
pip install .

.github/workflows/ci.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
types: [opened, synchronize, reopened]
9+
10+
jobs:
11+
quality:
12+
name: Calidad de código
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup Python
19+
uses: ./.github/actions/setup-python
20+
21+
- name: Black
22+
run: black --check lexguard/ tests/
23+
24+
- name: Flake8
25+
run: flake8 lexguard/ tests/
26+
27+
- name: MyPy
28+
run: mypy lexguard/
29+
30+
test:
31+
name: Tests unitarios e integración
32+
runs-on: ubuntu-latest
33+
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- name: Setup Python
38+
uses: ./.github/actions/setup-python
39+
40+
- name: Ejecutar tests
41+
run: |
42+
pytest --cov=lexguard --cov-report=xml --cov-report=term-missing
43+
44+
- name: Subir cobertura
45+
uses: codecov/codecov-action@v4.6.0
46+
with:
47+
file: ./coverage.xml
48+
fail_ci_if_error: false
49+
if: github.event_name == 'push'
50+
51+
build:
52+
name: Build y seguridad
53+
runs-on: ubuntu-latest
54+
needs: [quality, test]
55+
if: github.event_name == 'push'
56+
57+
permissions:
58+
contents: read
59+
security-events: write
60+
actions: read
61+
62+
steps:
63+
- uses: actions/checkout@v4
64+
65+
- name: Set up Docker Buildx
66+
uses: docker/setup-buildx-action@v3.7.1
67+
68+
- name: Build imagen
69+
uses: docker/build-push-action@v6.9.0
70+
with:
71+
context: .
72+
load: true
73+
tags: lexguard:${{ github.sha }}
74+
cache-from: type=gha
75+
cache-to: type=gha,mode=max
76+
77+
- name: Trivy scan
78+
uses: aquasecurity/trivy-action@0.28.0
79+
with:
80+
image-ref: lexguard:${{ github.sha }}
81+
format: "sarif"
82+
output: "trivy-results.sarif"
83+
severity: "CRITICAL,HIGH"
84+
exit-code: "0"
85+
trivyignores: ".trivyignore"
86+
87+
- name: Upload SARIF
88+
uses: github/codeql-action/upload-sarif@v4
89+
with:
90+
sarif_file: "trivy-results.sarif"
91+
category: "trivy-container-scan"
92+
if: always()
93+
continue-on-error: true

0 commit comments

Comments
 (0)