-
Notifications
You must be signed in to change notification settings - Fork 0
173 lines (144 loc) · 4.92 KB
/
Copy pathci.yml
File metadata and controls
173 lines (144 loc) · 4.92 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
# ── Job 1: Lint (fast gate) ───────────────────────────────────────────────
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-lint-${{ hashFiles('backend/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-lint-
${{ runner.os }}-pip-
- name: Install ruff
run: pip install ruff
- name: Ruff lint check
run: ruff check backend/app/ --select=E,F,W --ignore=E501,F401,E402
- name: Ruff format check
run: ruff format --check backend/app/
# ── Job 2: Test (depends on lint) ─────────────────────────────────────────
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 20
needs: lint
env:
SECRET_KEY: test-secret-key-for-ci
USE_SQLITE: "true"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-test-${{ hashFiles('backend/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-test-
${{ runner.os }}-pip-
- name: Install CPU-only PyTorch
run: |
pip install --no-cache-dir \
torch==2.2.2 \
torchaudio==2.2.2 \
--index-url https://download.pytorch.org/whl/cpu
- name: Install dependencies
run: pip install -r backend/requirements.txt
- name: Run tests
run: cd backend && python -m pytest tests/ -v --tb=short -x --junitxml=test-results.xml
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: backend/test-results.xml
retention-days: 30
# ── Job 3: Type check (parallel with test) ────────────────────────────────
typecheck:
name: Type Check
runs-on: ubuntu-latest
timeout-minutes: 10
needs: lint
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-typecheck-${{ hashFiles('backend/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-typecheck-
${{ runner.os }}-pip-
- name: Install mypy and dependencies
run: |
pip install mypy
pip install -r backend/requirements.txt
- name: Run mypy on critical paths
run: mypy backend/app/core/ backend/app/agents/ --ignore-missing-imports
# ── Job 4: Security audit (parallel with test) ────────────────────────────
security:
name: Security
runs-on: ubuntu-latest
timeout-minutes: 10
needs: lint
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-security-${{ hashFiles('backend/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-security-
${{ runner.os }}-pip-
- name: Install security tools and dependencies
run: |
pip install pip-audit bandit
pip install -r backend/requirements.txt
- name: Run pip-audit for dependency vulnerabilities
run: pip-audit
- name: Run bandit for code security
run: bandit -r backend/app/ -ll
# ── Job 5: Docker build (depends on test) ─────────────────────────────────
docker-build:
name: Docker Build
runs-on: ubuntu-latest
timeout-minutes: 20
needs: test
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: ./backend
file: ./backend/Dockerfile
push: false
tags: redline-ai:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max