-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (102 loc) · 3.01 KB
/
Copy pathci.yml
File metadata and controls
123 lines (102 loc) · 3.01 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
121
122
123
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